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