Author Topic: How to stop a respond to event (bluetooth)  (Read 9613 times)

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« on: September 07, 2006, 07:14:39 am »
Hello, I set up a "bluetooth detected" event to send codes to my projector and my receiver. The good news is that it works! the bad news is that while I have my bluetooth device (mobile phone) turned on, it continue to send the codes over and over... How do I stop sending the commands, or how do I send it only once?

Thanks a lot for your help in advance! :D

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #1 on: September 07, 2006, 11:31:19 am »
Hi,

I guess you have two solutions for this problem. Bluetooth_Dongle fires tree events:
- "Mobile orbiter detected" (The dongle detects the phone.)
- "Mobile orbiter linked" (The dongle successfully linked to the phone)
- "Mobile orbiter lost" (The dongle lost the connection to the phone)

Solution 1
-----------

If you have a phone supported by pluto on which you can install and use a "mobile orbiter" (symbian series 60 phones and windows mobile 2003 phones, for now), you can use "Mobile orbiter linked" events to send codes to your projector (the event is sent only once, when bluetooth_dongle connects to the PlutoMO running on your phone).

Solution 2
-----------

You can use "Mobile orbiter detected" and use an algorithm like this in your scripts:

Code: [Select]
if( intercepted "mobile orbiter detected" and CodesSent = false)
{
   CodesSent = true
   SendCodesToProjector();
}

if ( intercepted "mobile orbiter lost" and CodesSent = true)
{
   CodesSent = false;
}


Best regards,
Cristian Miron

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #2 on: September 07, 2006, 05:45:27 pm »
Thanks Chris, very clear. Ill try both tonigh since I do have a symbian s60 phone with PlutoMo installed.

Ill let you lnow If I have any trouble.
Regards,
Martin

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #3 on: September 08, 2006, 03:05:06 am »
Chris, how do I set that algorithm script? in the advance event configuration? I cant find how
Thanks

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #4 on: September 08, 2006, 02:02:26 pm »
Hi Martin,

Yes, you can run a script when an event is fired and to do this, you'll need to edit events commands from pluto-admin (Advanced -> Configuration -> Events).

Let's say you'll choose the event "phone detected". When this event is fired, you'll choose an App_Server to process "Spawn application" command. This command accepts a filename and arguments as parameters. You'll set as filename a bash script, for example, like "SendCommandToProjector.sh", and with an argument "detected" or "lost". If you don't like bash, you can choose python, perl or a c++ application to do this job.

Best regards,
Cristian Miron

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #5 on: September 08, 2006, 04:29:35 pm »
Quote from: "chris.m"
Hi Martin,

Yes, you can run a script when an event is fired and to do this, you'll need to edit events commands from pluto-admin (Advanced -> Configuration -> Events).

Let's say you'll choose the event "phone detected". When this event is fired, you'll choose an App_Server to process "Spawn application" command. This command accepts a filename and arguments as parameters. You'll set as filename a bash script, for example, like "SendCommandToProjector.sh", and with an argument "detected" or "lost". If you don't like bash, you can choose python, perl or a c++ application to do this job.

Best regards,
Cristian Miron

Is there possibility to write event handler in Ruby (like in gsd) ? It would ease such programming a lot....

Thanks in advance,

regards,

Rob.

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #6 on: September 10, 2006, 07:22:03 pm »
Hi Chris, thanks for your answer. I didnt know i had to setup a script. I dont know any of those languages. I went to Advanced- Configuration- Events; the edit command event and set appserver and then spawn application. Then I have this:
#51 Arguments (string)  
#126 Exclusive (bool)  
#13 Filename (string)  
#50 Name (string)  
#120 Retransmit (bool)  
#94 SendOnFailure (string)  
#95 SendOnSuccess (string)  
#115 Show logo (bool)
 
What do I have to do then?
Thanks a lot.

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #7 on: September 11, 2006, 10:02:41 am »
Quote
Is there possibility to write event handler in Ruby (like in gsd) ? It would ease such programming a lot....

Thanks in advance,

regards,

Rob.


Hi Rob. Right now you cannot write an event handler in Ruby. An idea would be to add this feature to gsd (the ability to intercept events) and the user will be able to create a new gdb "device" called, let's say, "Event Handler" which will intercept events and then send the desired commands. However, gsd wasn't designed to support this feature and I don' think this will be implemented in the near future.
The second solution would be to use pluto-admin to configure an event handler and run a script/application via App_Server's SpawnApplication command. If you want to write the event handler in ruby, you can type there the filename like this "/usr/bin/ruby ./script/myPlutoEventHandler" and command line parameters for script in Arguments.


Quote
Hi Chris, thanks for your answer. I didnt know i had to setup a script. I dont know any of those languages. I went to Advanced- Configuration- Events; the edit command event and set appserver and then spawn application.


Hi Martin,

This is how the parameters should look:

#51 Arguments (string)               = detected
#126 Exclusive (bool)
#13 Filename (string)        = /usr/bin/python /usr/pluto/bin/myEventHandler.py
#50 Name (string)                      = PythonEventHandler
#120 Retransmit (bool)              
#94 SendOnFailure (string)
#95 SendOnSuccess (string)
#115 Show logo (bool)

You can ignore the other parameters. What programming languages do you know ?


Best regards,
Cristian Miron

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #8 on: September 11, 2006, 03:44:59 pm »
Hi,

thanks for info. Well I like to program in Perl - I actually didn't wrote single line in Ruby - I just thought to learn it since it's integrated in GSD. Anyway integrating possibility of more script languages would be marvelous, but when the time permits....

I'll probably write Perl interface in Misterhouse. But I have important question:
- does pluto wait till that external script finishes ? One useful solution is to wait, another is just to start it and let it running...

Regards,

Rob.

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #9 on: September 11, 2006, 04:59:20 pm »
Pluto doesn't wait till the external scripts finish. There are two parameters for SpawnApplication (SendOfFailure and SendOnSuccess) which can contain a list with commands to be executed when the external script/application exits with success or failure.

Best regards,
Cristian Miron

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #10 on: September 11, 2006, 11:29:18 pm »
Thanks again Chris. So basically I have to enter the commands on SendOnFailure and SendOnSuccess. Could you send me a sample of the script and how to excecute it? (martin@interwebsa.net). It would help a lot if you explain it to me step by step considering that I dont know about bash scripts.

Thanks a lot and sorry to bother  :wink:
Martin

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #11 on: September 12, 2006, 10:37:46 am »
Hi Martin,

Let's create two bash scripts in /usr/pluto/bin and give them rights for execution (chmod +x filename):

For "Mobile Orbiter Detected" event, /usr/pluto/bin/HandleMODetected.sh :

Code: [Select]
#!/bin/bash

FCodesSent=/tmp/pluto_codes_sent

## If the file doesn't exist
if [[ ! -f "$FCodesSent" ]]; then
   touch $FCodesSent
   # send message to projector
   # /usr/pluto/bin/MessageSend dcerouter 0 <projector_Device_id> 1 <command_id> <additional parameters: pair id,value> like this
   /usr/pluto/bin/MessageSend dcerouter 0 23 1 130
fi



For "Mobile Orbiter Lost" event, /usr/pluto/bin/HandlerMOLost.sh :


On "Mobile Orbiter Lost" event:

Code: [Select]
#!/bin/bash

FCodesSent=/tmp/pluto_codes_sent

## if the file exists
if [[ -f "$FCodesSent" ]]; then
   rm -f $FCodesSent
fi


Now, let's configure the event handler.
For "mobile orbiter detected", set this arguments:

Code: [Select]
#51 Arguments (string) =
#126 Exclusive (bool)
#13 Filename (string) = /usr/pluto/bin/HandleMODetected.sh
#50 Name (string) = MODetectedHandler
#120 Retransmit (bool)
#94 SendOnFailure (string)
#95 SendOnSuccess (string)
#115 Show logo (bool)


For "mobile orbiter lost", set this arguments:

Code: [Select]
#51 Arguments (string) =
#126 Exclusive (bool)
#13 Filename (string) = /usr/pluto/bin/HandleMOLost.sh
#50 Name (string) = MOLostHandler
#120 Retransmit (bool)
#94 SendOnFailure (string)
#95 SendOnSuccess (string)
#115 Show logo (bool)



Best regards,
Cristian Miron

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #12 on: September 15, 2006, 06:23:27 am »
Thanks Chris, you've been very patience with me thanks a lot  :D

OK I figure it out how to put the script in /usr/pluto/bin and at least when I do a "dir" (using putty) I see the file HandleMODetected.sh

The script I created was for turning on the receiver in AV2 so it was like this:

Code: [Select]

#!/bin/bash

FCodesSent=/tmp/pluto_codes_sent

## If the file doesn't exist
if [[ ! -f "$FCodesSent" ]]; then
   touch $FCodesSent
   # send message to projector
   # /usr/pluto/bin/MessageSend dcerouter 0 40 1 317
fi


where 40 is the receiver ID and 317 the command ID which I tested and it did turned on the receiver in AV2.

Then in the event configuration in criteria I set PK_Room = Home Theater (the room where the receiver is configurated)

and in commands:

Code: [Select]

#51 Arguments (string) =
#126 Exclusive (bool)
#13 Filename (string) = /usr/pluto/bin/HandleMODetected.sh
#50 Name (string) = MODetectedHandler
#120 Retransmit (bool)
#94 SendOnFailure (string)
#95 SendOnSuccess (string)
#115 Show logo (bool)


Am I missing something? I have the mobile phone with bluetooth on and nothing happens  :?

Thanks a lot Chris I feel Im getting closer  8)
Martin

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #13 on: September 17, 2006, 05:16:10 pm »
Any ideas?
thanks a lot

archived

  • Hello, I'm new here
  • Posts: 0
    • View Profile
How to stop a respond to event (bluetooth)
« Reply #14 on: September 21, 2006, 12:17:56 am »
Hello Chris, could you help me on my last question?
Thanks!
Martin