From: Emmanuel G. <mis...@re...> - 2012-03-16 14:27:36
|
Hello the list :) I want to monitor my presence using my Bluetooth cell phone so I did this : ###################################### use Net::Bluetooth; ######################################################################## # Ping BT device ######################################################################## sub Check_BT() { my $BT_obj = Net::Bluetooth->newsocket("RFCOMM"); die "socket error $!\n" unless(defined($BT_obj)); if($BT_obj->connect(@_, 1) != 0) { print_log "@_ is dead"; } else { print_log "@_ is alive"; } $BT_obj->close(); } ######################################################################## # Main ######################################################################## if (new_second 20) { &Check_BT('AC:A8:E5:18:5B:F1'); } If I restart MH it will work for the first time only, however this is working fine from the shell ?! I think I am doing something wrong with the socket inside MH but can't figure what. Any ideas ? Good day to all ! Emmanuel -- View this message in context: http://old.nabble.com/Bluetooth-Presence-Monitoring-tp33516314p33516314.html Sent from the Misterhouse - User mailing list archive at Nabble.com. |
From: Jim D. <ji...@du...> - 2012-03-17 13:43:32
|
On 03/16/2012 10:27 AM, Emmanuel Grout wrote: > > Hello the list :) > > I want to monitor my presence using my Bluetooth cell phone so I did this : > > ###################################### > use Net::Bluetooth; > > > ######################################################################## > # Ping BT device > ######################################################################## > sub Check_BT() { > my $BT_obj = Net::Bluetooth->newsocket("RFCOMM"); > die "socket error $!\n" unless(defined($BT_obj)); > if($BT_obj->connect(@_, 1) != 0) { print_log "@_ is dead"; } > else { print_log "@_ is alive"; } > $BT_obj->close(); > } > > ######################################################################## > # Main > ######################################################################## > if (new_second 20) {&Check_BT('AC:A8:E5:18:5B:F1'); } > > If I restart MH it will work for the first time only, however this is > working fine from the shell ?! > I think I am doing something wrong with the socket inside MH but can't > figure what. > > Any ideas ? > > Good day to all ! > Emmanuel Emmanuel, Using Socket code inside the main Misterhouse loop isn't going to work very well. You should read up on Process_Item in www.misterhouse.net in the Docs section. Network_Item might help to, but I'm not sure it can be used with Net::Bluetooth (I suspect not). If you have a script which does the work for you, you can have the script be called by Process_Item, and have the results dumped to a file which you can interrogate the results from. Alternatively, you could possibly put your subroutine above as a call within Process_Item and avoid using a shell script. In a nutshell, Process_Item exexutes a "fork" from misterhouse and allows things to be done in their own process thread. Hope that sends you in a better direction. Jim |
From: Emmanuel G. <mis...@re...> - 2012-03-19 08:28:08
|
Hi Jim, Great thanks for you answer. Ok I will give a try, using Process_Item. Thanks again ! Emmanuel Jim Duda wrote: > > On 03/16/2012 10:27 AM, Emmanuel Grout wrote: >> >> Hello the list :) >> >> I want to monitor my presence using my Bluetooth cell phone so I did this >> : >> >> ###################################### >> use Net::Bluetooth; >> >> >> ######################################################################## >> # Ping BT device >> ######################################################################## >> sub Check_BT() { >> my $BT_obj = Net::Bluetooth->newsocket("RFCOMM"); >> die "socket error $!\n" unless(defined($BT_obj)); >> if($BT_obj->connect(@_, 1) != 0) { print_log "@_ is dead"; } >> else { print_log "@_ is alive"; } >> $BT_obj->close(); >> } >> >> ######################################################################## >> # Main >> ######################################################################## >> if (new_second 20) {&Check_BT('AC:A8:E5:18:5B:F1'); } >> >> If I restart MH it will work for the first time only, however this is >> working fine from the shell ?! >> I think I am doing something wrong with the socket inside MH but can't >> figure what. >> >> Any ideas ? >> >> Good day to all ! >> Emmanuel > > Emmanuel, > > Using Socket code inside the main Misterhouse loop isn't going to work > very well. You should read up on Process_Item in www.misterhouse.net > in the Docs section. Network_Item might help to, but I'm not sure > it can be used with Net::Bluetooth (I suspect not). > > If you have a script which does the work for you, you can have > the script be called by Process_Item, and have the results dumped > to a file which you can interrogate the results from. > > Alternatively, you could possibly put your subroutine above as a call > within Process_Item and avoid using a shell script. In a nutshell, > Process_Item exexutes a "fork" from misterhouse and allows things to > be done in their own process thread. > > Hope that sends you in a better direction. > > Jim > > > > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > ________________________________________________________ > To unsubscribe from this list, go to: > http://sourceforge.net/mail/?group_id=1365 > > > -- View this message in context: http://old.nabble.com/Bluetooth-Presence-Monitoring-tp33516314p33529680.html Sent from the Misterhouse - User mailing list archive at Nabble.com. |
From: Greg S. <sa...@ir...> - 2012-03-19 17:16:43
|
I have put together a stand alone xPL application that will scan bluetooth devices as well as attempt to ping devices in a list supplied by a mysql database table. This lets you run multiple versions of the application for better location detail. It has been a while since I worked with it and there are separate Mac and Linux versions. Not sure I have much time to do anything with it in the near future. If there is any interest let me know. Thanks, Greg On Mar 17, 2012, at 7:43 AM, Jim Duda wrote: > On 03/16/2012 10:27 AM, Emmanuel Grout wrote: >> >> Hello the list :) >> >> I want to monitor my presence using my Bluetooth cell phone so I did this : >> >> ###################################### >> use Net::Bluetooth; >> >> >> ######################################################################## >> # Ping BT device >> ######################################################################## >> sub Check_BT() { >> my $BT_obj = Net::Bluetooth->newsocket("RFCOMM"); >> die "socket error $!\n" unless(defined($BT_obj)); >> if($BT_obj->connect(@_, 1) != 0) { print_log "@_ is dead"; } >> else { print_log "@_ is alive"; } >> $BT_obj->close(); >> } >> >> ######################################################################## >> # Main >> ######################################################################## >> if (new_second 20) {&Check_BT('AC:A8:E5:18:5B:F1'); } >> >> If I restart MH it will work for the first time only, however this is >> working fine from the shell ?! >> I think I am doing something wrong with the socket inside MH but can't >> figure what. >> >> Any ideas ? >> >> Good day to all ! >> Emmanuel > > Emmanuel, > > Using Socket code inside the main Misterhouse loop isn't going to work > very well. You should read up on Process_Item in www.misterhouse.net > in the Docs section. Network_Item might help to, but I'm not sure > it can be used with Net::Bluetooth (I suspect not). > > If you have a script which does the work for you, you can have > the script be called by Process_Item, and have the results dumped > to a file which you can interrogate the results from. > > Alternatively, you could possibly put your subroutine above as a call > within Process_Item and avoid using a shell script. In a nutshell, > Process_Item exexutes a "fork" from misterhouse and allows things to > be done in their own process thread. > > Hope that sends you in a better direction. > > Jim > > > > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > ________________________________________________________ > To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365 > > > !DSPAM:4f649547331628652212316! > |
From: Nico L. <nic...@gm...> - 2012-03-29 09:49:00
|
Greg, I also tried different ways fro bluetooth proximity detecting but never could find the perfect solution. I like to give your code a try as well. Is it in the SVN ? Regards, Nico Op 19 maart 2012 17:49 schreef Greg Satz <sa...@ir...> het volgende: > I have put together a stand alone xPL application that will scan bluetooth > devices as well as attempt to ping devices in a list supplied by a mysql > database table. This lets you run multiple versions of the application for > better location detail. It has been a while since I worked with it and > there are separate Mac and Linux versions. Not sure I have much time to do > anything with it in the near future. If there is any interest let me know. > > Thanks, > Greg > > On Mar 17, 2012, at 7:43 AM, Jim Duda wrote: > > > On 03/16/2012 10:27 AM, Emmanuel Grout wrote: > >> > >> Hello the list :) > >> > >> I want to monitor my presence using my Bluetooth cell phone so I did > this : > >> > >> ###################################### > >> use Net::Bluetooth; > >> > >> > >> ######################################################################## > >> # Ping BT device > >> ######################################################################## > >> sub Check_BT() { > >> my $BT_obj = Net::Bluetooth->newsocket("RFCOMM"); > >> die "socket error $!\n" unless(defined($BT_obj)); > >> if($BT_obj->connect(@_, 1) != 0) { print_log "@_ is dead"; } > >> else { print_log "@_ is alive"; } > >> $BT_obj->close(); > >> } > >> > >> ######################################################################## > >> # Main > >> ######################################################################## > >> if (new_second 20) {&Check_BT('AC:A8:E5:18:5B:F1'); } > >> > >> If I restart MH it will work for the first time only, however this is > >> working fine from the shell ?! > >> I think I am doing something wrong with the socket inside MH but can't > >> figure what. > >> > >> Any ideas ? > >> > >> Good day to all ! > >> Emmanuel > > > > Emmanuel, > > > > Using Socket code inside the main Misterhouse loop isn't going to work > > very well. You should read up on Process_Item in www.misterhouse.net > > in the Docs section. Network_Item might help to, but I'm not sure > > it can be used with Net::Bluetooth (I suspect not). > > > > If you have a script which does the work for you, you can have > > the script be called by Process_Item, and have the results dumped > > to a file which you can interrogate the results from. > > > > Alternatively, you could possibly put your subroutine above as a call > > within Process_Item and avoid using a shell script. In a nutshell, > > Process_Item exexutes a "fork" from misterhouse and allows things to > > be done in their own process thread. > > > > Hope that sends you in a better direction. > > > > Jim > > > > > > > > > > > ------------------------------------------------------------------------------ > > This SF email is sponsosred by: > > Try Windows Azure free for 90 days Click Here > > http://p.sf.net/sfu/sfd2d-msazure > > ________________________________________________________ > > To unsubscribe from this list, go to: > http://sourceforge.net/mail/?group_id=1365 > > > > > > !DSPAM:4f649547331628652212316! > > > > > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > ________________________________________________________ > To unsubscribe from this list, go to: > http://sourceforge.net/mail/?group_id=1365 > > |