Author Topic: Using RFID to detect proximity and run TTS using voxcommando  (Read 31477 times)

0 Members and 1 Guest are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #15 on: October 28, 2013, 09:46:29 AM »
The code will be passed as payload 1 with the event .  the command triggered by the event can access this data using {1}

I must walk the dog but when I get back I will create some sample commands for you.  I will send something within the next hour or two.

I am interested to try the Bluetooth method.  I could use this to turn the front light on at night when we return from night-time dog walkies.  :D

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #16 on: October 28, 2013, 09:48:01 AM »
But I used RFID becasue I have 4 kids who will not bring any bluetooth devices or mobile phone so I want to put this active tag into thier backpack in order to detect them when they come back home or leave from home..... ;D ;D ;D ;D ;D

 ;D But what happens if someone steals your child's backpack, or they forget their bag at a friend's place? You might need to implant the tags directly into your kids. Kalle has done this with his cat!  



:biglaugh
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #17 on: October 28, 2013, 09:54:14 AM »
Haha, and it works, but I'm sure if you go with your kids to the pet doctor to implant a RFID chip, he will get problems.  :biglaugh
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #18 on: October 28, 2013, 09:56:12 AM »
Hi James, one more question, I used previous TCP Plugin for TTS server. I can send TCP command with speaking sentence from Vera to VC then VC will read this sentence and use TTS.Speak to sepak it out. This sentence I use is a general ASC characters. I can successfully use TTS.Speak {1} to speak it out when I got TCP event. But now, after change it the updated TCP Plugin, all {1}, {2} etc should be hex converted. Can we install two separate TCP Plugin: One for ASC and another for Hex. Or I can use object one to handle ASC and another one for Hex decoded etc...Sorry for my too many questions  :bonk

Please post the XML for your commands that use TCP and TTS

note:  you can right-click a group in the command tree and select "copy" then in the forum create a code block (# button) and paste the xml in there.
« Last Edit: October 28, 2013, 10:48:43 AM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #19 on: October 28, 2013, 10:50:36 AM »
James wrote a short piece of Luup code that generate a event for each vera device in VC over UDP - so it is easy to use a RFID or a motion sensor to generate a event in VC.
I can't post this code here because it is not my code, but I'm sure James will do it.  ;)

You don't need any special luup code any more.  You just need to enable polling in the VoxCommando Vera plugin settings.  Events will be generated automatically.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #20 on: October 28, 2013, 12:29:42 PM »
Please post the XML for your commands that use TCP and TTS

note:  you can right-click a group in the command tree and select "copy" then in the forum create a code block (# button) and paste the xml in there.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #21 on: October 28, 2013, 01:28:53 PM »
Here is some sample code that shows you the two different types of TCP server we can create.  One is for generating events.  You would use this with your RFID.  The other is for accepting actions from TCP.  You could use this with Vera to send TTS actions.

Note that each TCP server must be created using a unique port.  I am using port 1000 for events, and 1001 for actions.  You can't have two servers that are both listening to the same port.

Look at the descriptions that I have put into the commands to help you understand how it works.

I am also attaching a new version of the TCP plugin dll that will hopefully work correctly for both types of messages.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="tcp server" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="267" name="RFID create tcp server" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This TCP server listens on port 1000&#xD;&#xA;It generates events when it receives TCP messages&#xD;&#xA;the event will carry the TCP message as the payload: {1}&#xD;&#xA;The event name will be &quot;RFID&quot; as specified by the &lt;GenEvent&gt; parameter when we start the server">
    <action>
      <cmdType>TCP.Server.Start</cmdType>
      <cmdString>1000&amp;&amp;RFID</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
  <command id="286" name="create general tcp server" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This TCP server listens on port 1001&#xD;&#xA;When it receives TCP messages, it tries to evaluate it it as an action for VC.&#xD;&#xA;That is because we declared the server without using the optional parameter &lt;GenEvent&gt;">
    <action>
      <cmdType>TCP.Server.Stop</cmdType>
      <cmdString>1001</cmdString>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <action>
      <cmdType>TCP.Server.Start</cmdType>
      <cmdString>1001</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
  <command id="262" name="onRFID event" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This command is triggered when the RFID event if fired.  It attempts to find the ID and then generates a new event which includes the ID in the EVENT NAME, instead of having it in the payload.">
    <action>
      <cmdType>Results.SetLastResult</cmdType>
      <cmdString>{1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>(.*?)TagID</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{#M}&amp;&amp;1</ifParams>
      <then>
        <action>
          <cmdType>VC.TriggerEvent</cmdType>
          <cmdString>TAG.{Match.1}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <event>RFID</event>
  </command>
  <command id="527" name="test TCP send RFID" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This attempts to simulate the message that would be sent by the RFID hardware">
    <action>
      <cmdType>TCP.Single.Write</cmdType>
      <cmdString>\xFB\x10\x00\x00 TagID RFGain ReadID\x01&amp;&amp;192.168.0.125&amp;&amp;1000</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
  <command id="541" name="test TCP send general actions" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This sends an action string to VC on port 1001.&#xD;&#xA;We can't include &amp;&amp; in our first parameter or this will confuse VC when it is sending the action.  So instead we encode the &amp;&amp; as \x26\x26">
    <action>
      <cmdType>TCP.Single.Write</cmdType>
      <cmdString>osd.showtext\x26\x26hello thereê&amp;&amp;192.168.0.125&amp;&amp;1001</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
</commandGroup>
« Last Edit: October 28, 2013, 03:39:14 PM by jitterjames »

manfaiho

  • Jr. Member
  • **
  • Posts: 47
  • Karma: 0
    • View Profile
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #22 on: October 28, 2013, 11:08:43 PM »
Hi James, you are so great. I like your sample. My stupid: I copy your XML codes then put it into XMLNotepad. You can see attached XML file. But when I load into VOX Edit, it prompts exception. I can read it from XML tag to understand what the actions you created for this test that sounds good. I will try it once I got this hardware these days. Thank you very much and I really love this very powerful and strong support's products.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #23 on: October 29, 2013, 05:43:34 AM »
&feature=youtube_gdata_player

manfaiho

  • Jr. Member
  • **
  • Posts: 47
  • Karma: 0
    • View Profile
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #24 on: October 29, 2013, 06:11:22 AM »
Hi James, thank your pointer. I watch it then try to drag your sample into Edit Window but it prompts me a series of error message windows. Something like weird data format: System.String or others. I don't know what's wrong. I also rebuild standard configration using basic. The problem can't be resolved. What a strange!!  :bonk :bonk :bonk

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #25 on: October 29, 2013, 07:50:15 AM »
Do following: marked the code above, hold the STRG key and then drag and drop it with the mouse to your command tree.
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #26 on: October 29, 2013, 09:12:28 AM »
First of all, let me assure you there is nothing wrong with the xml code above.

Kalle: STRG is only on German keyboards I guess?  Does it mean CTRL ?  Anyway it is not necessary for dragging code from the forum window to the VC editor tree.  It will still work but it should make no difference.

1) Highlight ALL the code in the "code block".  Do not highlight extra text outside the box
2) on your keyboard press Ctrl-C to copy the xml text (or right-click and choose "copy")
3) select any node in your VC tree. and press Ctrl-V to paste the xml text.
(or right-click anywhere on tree and choose "paste")

A new group node named "tcp server" should be created in the tree with 5 commands in it.

DO NOT copy the xml into a file first and then try to drag the file into the tree.  This will not work.

If you still get an error message, please tell us exactly what it says, or post a screen capture of the message.  Better yet, make a short video showing us what you are doing so we can figure out if you are finding some creative way to make it not work, or if there actually is some kind of bug we need to fix.  I have been copying and pasting code back and forth using all sorts of methods without any problems for a long time but maybe it relates to running Windows in an other language or something like that.

You should also let us know what version of VC and Windows you are using.
« Last Edit: October 29, 2013, 09:17:46 AM by jitterjames »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #27 on: October 29, 2013, 09:34:28 AM »
An alternative method, without using "drag and drop":



[edit: Sorry for the low quality of the video. I didn't pay attention to the settings when "publishing" it.]
« Last Edit: October 29, 2013, 09:42:51 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

manfaiho

  • Jr. Member
  • **
  • Posts: 47
  • Karma: 0
    • View Profile
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #28 on: October 29, 2013, 10:31:34 AM »
Thank all of your help. I can fix it using right mouse click to select copy then paste on Editor.

Hi James, I try to use your action: "test TCP send RFID" to generate the hexcode stream: \xFB\x10\x00\x00\x12\x4B\x02\x01\x01 where \x4B should be TagID. onRFID event is triggered but I modified your action which only execute one action: Results.SetLastResult to test whether what I send is what I receive then I can add code to do some operation to extract the sixth character (TagID) only matching comparsion (Not finish for this part yet).  Unforunately I found what I send is sometime not what I receive after copy {1} to {LastResult}. You can see my attached screen. Any problem?

Besides, if we want to only extract the sixth character from this hexcode stream, how do I use what operator to get it?  :bonk

manfaiho

  • Jr. Member
  • **
  • Posts: 47
  • Karma: 0
    • View Profile
Re: Using RFID to detect proximity and run TTS using voxcommando
« Reply #29 on: October 29, 2013, 10:44:26 AM »
Hi James, I have also tried to use Luup code to send hexcode stream to VOX.

local socket = require("socket")
host = "192.168.1.12"
c = assert(socket.connect(host, 1000))
c:send(string.char(251,16,00,00,18,75,02,01,01))
c:close()

The result is same as before, you can see attach screen.