Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
livebox:hah_hahnode:bluenode [2014/01/20 08:43]
brett [Configuration]
livebox:hah_hahnode:bluenode [2014/02/18 10:42] (current)
minerva9 [Observations]
Line 1: Line 1:
 ====== BlueNode ====== ====== BlueNode ======
  
-Integration of a BlueTooth ​sensor onto a JeeNode for the purposes ​of detecting devices as they come into, and go out of, range so that events can be triggered.+Integration of a Bluetooth ​sensor onto a JeeNode for the purpose ​of detecting devices as they come into, and go out of, range so that events can be triggered.
  
 {{:​livebox:​hah_hahnode:​hc-05-top1.jpg?​280|}} {{:​livebox:​hah_hahnode:​hc-05-bottom.jpg?​280|}} {{:​livebox:​hah_hahnode:​hc-05-top1.jpg?​280|}} {{:​livebox:​hah_hahnode:​hc-05-bottom.jpg?​280|}}
Line 8: Line 8:
 ===== Theory of operation ===== ===== Theory of operation =====
  
-The BlueTooth ​unit is connected to a JeeNode and it will perform an inquiry check for available devices every 30 seconds. ​ As each device reports in its device ID will be transmitted via the RFM12B. A total of 6 bytes are needed to represent the 48 bit address, to a receiving unit.+The Bluetooth ​unit is connected to a JeeNode and it will perform an inquiry check for available devices every 30 seconds ​(adjustable).  As each device reports inits device ID will be transmitted via the RFM12B. A total of 6 bytes are needed to represent the 48 bit address, to a receiving unit.
  
 On the receiver side the RF is decoded and transmitted as an ASCII string out the serial port for decoding. On the receiver side the RF is decoded and transmitted as an ASCII string out the serial port for decoding.
Line 14: Line 14:
 [[livebox/​xap_serial]] will pickup the serial transmission from our receiver node and transmit this data as an xAP message for decoding. [[livebox/​xap_serial]] will pickup the serial transmission from our receiver node and transmit this data as an xAP message for decoding.
  
-The decoder is an Lua applet that creates a BSC endpoint dynamically sending a xAPBSC ON event when the device is first registered. ​ As long as the device updates itself within 35 seconds, the endpoint will remain alive. ​ When the device moves out of range a reaper will take care of expiring the endpoint sending an xAPBSC OFF event and removing the endpoint.+The decoder is Lua applet that creates a BSC endpoint dynamically sending a xAPBSC ON event when the device is first registered. ​ As long as the device updates itself within 35 seconds, the endpoint will remain alive. ​ When the device moves out of range a reaper will take care of expiring the endpoint sending an xAPBSC OFF event and removing the endpoint.
  
 These on/off events can then be used by other scripts to drive an action. These on/off events can then be used by other scripts to drive an action.
Line 22: Line 22:
 ===== Data Flow ===== ===== Data Flow =====
  
-A packet will arrive on the Receiver. ​ The first byte is the sender node ID, in this case its node 18.  The remaining data is the Device ID packed into 6 bytes.+With Serial debugging enabled on the bluenode sketch this is the sample output. 
 +<​code>​ 
 +[BlueNode.1] - RF disabled 
 +SYNC> AT 
 +OK 
 +SYNC> AT+NAME=blueNode 
 +OK 
 +SYNC> AT+ROLE=1 
 +OK 
 +SYNC> AT+INIT 
 +ERROR:​(17) 
 +SYNC> AT+INQM=0,​5,​15 
 +OK 
 +ASYNC> AT+INQ 
 +OK 
 ++INQ:​12:​37:​E90912,​520204,​7FFF 
 +device=12:​37:​E90912 type=520204 rssi=7FFF 
 +OK 
 +</​code>​ 
 +The ERROR:(17) can be safely ignored. That just means the SPP profile lib has already been initialized. 
 +You will notice the RF module is disabled, that's due to me running the bluetooth device attached to my Arduino which does not have any RF device on it, so I disabled that code whilst testing. 
 + 
 +A packet will arrive on the Receiver. ​ The first byte is the sender node ID, in this case it'​s ​node 18.  The remaining data is the Device ID packed into 6 bytes.
 <​code>​ <​code>​
 [HAHCentral.1]1 g212 @ 868Mhz [HAHCentral.1]1 g212 @ 868Mhz
Line 45: Line 67:
 </​code>​ </​code>​
  
-That something doing the decoding is an applet running inside [[livebox/​hah_plugboard_v2|plugboard]].+That 'something' ​doing the decoding is an applet running inside [[livebox/​hah_plugboard_v2|plugboard]].
  
 We are running the Lua decoder in debug mode so the lifecycle of an endpoint can be seen. We are running the Lua decoder in debug mode so the lifecycle of an endpoint can be seen.
Line 88: Line 110:
 </​code>​ </​code>​
  
-All going well you should see an endpoint dynamically appear in xFXViewer when your Bluetooth device comes into range.+All going wellyou should see an endpoint dynamically appear in xFXViewer when your Bluetooth device comes into range.
  
 ===== Wiring / Source ===== ===== Wiring / Source =====
Line 104: Line 126:
 We don't connect the 5v pins together, 3.3v is sufficient. We don't connect the 5v pins together, 3.3v is sufficient.
  
-The source code for the SKETCH is call BlueNode ​there is also a useful terminal emulator that uses the Arduino as a passthrough device.+The source code for the SKETCH is called ​BlueNode. There is also a useful terminal emulator that uses the Arduino as a passthrough device.
   * http://​livebox-hah.googlecode.com/​svn/​trunk/​userapps/​arduino/​Bluetooth/​   * http://​livebox-hah.googlecode.com/​svn/​trunk/​userapps/​arduino/​Bluetooth/​
  
-The LUA decoder logic is found in bluenode.lua or on your HAH system in /​usr/​share/​lua/​5.1/​xap+The Lua decoder logic is found in bluenode.lua or on your HAH system in /​usr/​share/​lua/​5.1/​xap
   * http://​livebox-hah.googlecode.com/​svn/​trunk/​userapps/​hah/​xap-plugboard/​xap   * http://​livebox-hah.googlecode.com/​svn/​trunk/​userapps/​hah/​xap-plugboard/​xap
  
Line 118: Line 140:
 module(...,​package.seeall) module(...,​package.seeall)
 local monitor = require("​xap.jeenode"​).monitor local monitor = require("​xap.jeenode"​).monitor
-RoomNode = require("​xap.roomnode"​).RoomNode+RoomNode = require("​xap.roomnode"​)
 BlueNode = require("​xap.bluenode"​) BlueNode = require("​xap.bluenode"​)
 </​code>​ </​code>​
Line 148: Line 170:
 ===== Observations ===== ===== Observations =====
  
-This code has been tested with the following ​bluetooth ​devices and the following has been observed.+This code has been tested with the following ​Bluetooth ​devices and the following has been observed.
  
-In general "Smart phones"​ have a habit of powering off the bluetooth ​device when they sleep, which sort of kills this idea stone dead.   ​Working on a way around this.+In general "Smart phones"​ have a habit of powering off the Bluetooth ​device when they sleep, which sort of kills this idea stone dead.   ​Working on a way around this.
  
 ^ Device ^ Year ^ Observation ^ ^ Device ^ Year ^ Observation ^
Line 159: Line 181:
 Ed. Sure smarts phones with all their apps are cool but they have taken their eye off the most important thing, in my opinion, which a phone should have; a long battery life and being able to make phone calls. ​ They are so worried about battery drain everything gets turned off, even things you actually want left on. Ed. Sure smarts phones with all their apps are cool but they have taken their eye off the most important thing, in my opinion, which a phone should have; a long battery life and being able to make phone calls. ​ They are so worried about battery drain everything gets turned off, even things you actually want left on.
  
-Until I can go a week on one charge I'm sticking to my trusty Nokia, where I can leave bluetooth ​on permanently without causing me duress. ​ Oh and it works with this code  :)+Until I can go a week on one charge I'm sticking to my trusty Nokia, where I can leave Bluetooth ​on permanently without causing me duress. ​ Oh and it works with this code  :)