Bluetooth presence (via HC05 and Jeenode)

90 replies [Last post]
garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011

Well here is my rough attempt at BT presence detection. The scripting works fine but I'm struggling with getting the Iphone to respond to the INQ call unless its displaying the Dicovery screen. Not particularly usefull!.

Not sure if there is a way round this yet but I have posted this rough draft anyhow as andorid users, etc, might have more luck.

The HC05 device i purchased had 6 connections on the breakout board. 3.3V, 5V, Rx, Tx, ground and Key. these fit quite neatly onto a jeenode port using the A pin for the key (used to switch the module into command mode), digital and Interupt pins for Rx and Tx, power and ground as described.

The jeenode code communucates using software serial leaving the hardware serial for dedugging, etc.

It sends the AT+INQ command every 30 seconds and forwards the first 10 characters of any addresses found via seperate payloads back to the HAH xapserial via the HAHcentral node. If none found "OOOOOOOOOO" is sent anyway for the lua script to deal with and ensure the node doesn't get "reaped".

This is messy but with my basic BT knowledge it appears the BT addresses can be of varying lengths so for simplicity I have just sent the first 10 characters for now.

The addresses to search are currently coded in the blueNode.lua file. These should really be in the jeenodeApplet so that the configuration is seperated but I havent got round to this bit yet.

Your jeenodeApplet will need modifying as per the example.

As soon as an address matching those in the blueNode.lua are seen, the associated endpoint switches ON, if the address is not seen for 5mins the endpoint is switched off.

I have tested and it seems to work OK, if a bit rough round the edges.

I'm off to try to fix the iphone issue, will tidy more if I get it sorted.

 

Garry.

AttachmentSize
jeenodeApplet.lua564 bytes
bluenode.lua1.32 KB
BlueNode.ino_.txt5.51 KB
allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
At the risk of teaching you

At the risk of teaching you to suck eggs, I had trouble getting a response from my iPhones until I had paired them with an old bluetooth headset.

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Bluetooth dongle arrived - time to hack.

Gary that code looks pretty good.  My bluebooth dongle arrived today so I'll give it a bash.
I've got a couple of bluetooth phones laying about; Nokia and a couple of Palms.  No iStuff.

My misson: I want to put the blue sensor in my shed so when I walk in if the light levels are low it will automatically turn on the lights for as long as I'm present and off when I leave.  Also when we drive into the garage at night it will detect us and turn on the lights, but not for burglars they'll have to stumble around and find the light switch themselves.   I guess I could also detect the roller door RF (UP) signal and enable the lights based on that too... so many options !

Should be fun.

Brett

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Bluetooth lives.

Hacked up a couple of sketches.   BlueTerm which is just a terminal emulator via the Arduino so you can type AT command manually.  BlueNode which is my version of a proximity detector node, I've not done any of the backend LUA sketch work.

http://livebox-hah.googlecode.com/svn/trunk/userapps/arduino/Bluetooth/

Interesting in that Garys sketch only has room for a 10 chars for the Bluetooth device however I found that 12 chars where needed.

Some sample debug output from my sketch.

ASYNC> AT+INQ
+INQ:12:37:E90912,520204,7FFF
device=12:37:E90912 type=520204 rssi=7FFF
+INQ:1D:FE:720479,7A020C,7FFF
device=1D:FE:720479 type=7A020C rssi=7FFF

Responding to myself:

A bluetooth address breaks down like this: NAP:UAP:LAP

From here http://homepages.inf.ed.ac.uk/group/sli_archive/slip0304_b/resources/com...

Addresses

Each Bluetooth device is assigned a 48-bit address consisting of three parts: a 24-bit lower address part (LAP), an 8-bit upper address part (UAP), and a 16-bit so-called non-significant address part (NAP). LAP and UAP address parts are used in several places in the Baseband protocol. The 32-bit concatenation of the upper and lower address parts is also used and is abbreviated as ULAP.

This makes it easier the 32bit concatenation (ULAP) is now the same size a MAC address (4 bytes) and this is all that is required for unique identification.   A mac is easier to push about and use as its familar.....

Time to sleep - I will rework this payload with this in mind, that will simplify the backend sketch too.

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Thanks Brett for the address

Thanks Brett for the address explanation. I didn't spend too long on this but the data sheet shown the following as examples INQ responses which confused me.

 

+INQ:1234:56:0,1F1F,FFC1 +INQ:1234:56:0,1F1F,FFC0 +INQ:1234:56:0,1F1F,FFC1 +INQ:2:72:D2224,3F0104,FFAD +INQ:1234:56:0,1F1F,FFBE +INQ:1234:56:0,1F1F,FFC2 +INQ:1234:56:0,1F1F,FFBE +INQ:2:72:D2224,3F0104,FFBC OK 

These didn't seem to be consistent. To test the principle I therefore just took the first ten characters as I figured it would be good enough for proof of concept.

must admit the ios devices are flaky on this, not sure I will get it going on my system robustly :( 

never mind, was fun playing anyhow.

Garry

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Decoding and sending the Bluetooth device NAP:UAP:LAP id.

Gary - I'm getting up to speed myself and I did examine your code for some guidance so thanks for the trail blazing it saved me some research time.

I updated my .INO sketch so the payload represents the device format more succintly.  Sending a variable length ASCII string just doesn't feel right to me.

// RF Transmission payload.
struct {
  union {
    struct {
      unsigned int nap:16;
      unsigned int uap:8;
      unsigned int lap:24;
    };
    uint8_t device[6];
  };
} payload;

We can break apart this device string into the payload struct for transmission.
A bluetooth device address breaks down like this: NAP:UAP:LAP

+INQ:1D:FE:720479,7A020C,7FFF

      uint16_t nap;
      uint8_t uap;
      uint32_t lap;
      sscanf(arg[0],"%hx:%hhx:%x", &nap, &uap, &lap);
   
      payload.nap = nap;
      payload.uap = uap;
      payload.lap = (lap & 0xffffff); // 24 bits.


The bluenode.lua backend also simpifies to match

local nap,uap,lap = jeenode.bitslicer(data,16,8,24)

Now we have these piece and we can rebuild the NAP:UAP:LAP (device) hex string with ease, it also means we only need to send 6 bytes, and always 6 bytes, over RF (less is better).

local device = string.format("%x:%x:%x", nap, uap, lap)

That's feels about right.

Brett

brett
Offline
Providence, United States
Joined: 9 Jan 2010
I finished hacking away and

I finished hacking away and this works well for me.   My old crusty Nokia 6230i (circa 2006) phone sends a response to the AT+INQ command every 30 seconds, at the 35 second interval if it didn't it would be reaped and the presence endpoint would be reset to "off".

I my smart phone sucks as it powers down every damn thing when it sleeps, Bluetooth included.  Sometimes you just beat the old tech.  :)

I've commited my source as this seems stable.

http://livebox-hah.googlecode.com/svn/trunk/userapps/hah/xap-plugboard/x...
http://livebox-hah.googlecode.com/svn/trunk/userapps/arduino/Bluetooth/B...

Sample configuration of how the jeenodeApplet is setup is inside the lua file.

NOTE:  the bluenode.lua sample is based upon the 311.1 beta which uses 'instance=' in place of 'base=' so that its host agnostic (part of my pending changes for release).     For those on 311 you would use base=

Brett

brett
Offline
Providence, United States
Joined: 9 Jan 2010
ERK - I just realized I

ERK - I just realized I screwed up the TTL is on ALL endpoint for a NODE and as this BlueNode now has multiple endpoint that may come and go I need to rework the expiry logic some more.

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Brett,Had a good look through

Brett,

Had a good look through your code and as always it looks ridiculously tidy. I takes me about an hour of googling to work out what you've done and how it works but it's great learning.

cheers

Garry

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Added custom reaper on the BT

Added custom reaper on the BT endpoints for the LUA side - now we are cooking.
Gary I do try to make my code readable and commented for others to use as examples.

Brett

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Cheers Brett, you do comment

Cheers Brett, you do comment well, I didn't mean it in that way!

Its always clear what is happening, it's the functions that I've never heard of that I end up googling how to use.

This for example was a beauty!

 

sscanf(arg[0],"%hx:%hhx:%x", &nap, &uap, &lap);

    
Would never have found this in order to try and use it!
Garry

 

magill
Offline
Joined: 27 Apr 2012
HC-05 problems

Hi Guys

Great work!!

I have been messing with this module on a breadboard for some time, but have a problem. When I issue the AT+INQ i get an error(16) response which according to the spec means means ‘ SPP lib hasn’t been initialized ‘. I then issue AT+INIT which is accepted and then when I issue AT+INQ the module falls out of command mode back to pairing mode. I'm a bit stuck. Any ideas?

John

bobonline19
Offline
Joined: 4 Apr 2013
I was just logging in to say

I was just logging in to say about the same. Garry and Brett very impressed with your work (and speed of development). I'm with John barely getting the AT commands to work stage with my module.

A possible problem with the HC-05 is that the AT+INQ command seems to me to be just doing a Bluetooth discovery? There does not seem to be a l2ping equivalent command. The difference between the two is that the discovery requires the phone (target device) to have the discoverable option on and is blanket asking "any devices out there" where as the ping is sent to targetted Bluetooth addresses and the Bluetooth device should respond (with optional ping time) whether it is discoverable or not. It also seems with iPhones that they have to be paired (not necessarily connected) with at least one device for Bluetooth to remain on and hence respond to pings.

I guess if the architecture is right we can have different technologies reporting the raw Bluetooth addresses (HC-05 or Bluetooth dongle) via xap and use the same script for processing

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
John, what baud rate are you

John, what baud rate are you using? I don't get the error (16) unless i reset. Is the key pin high on power up?

Bob, i agree that the INQ is not great on the iOS devices, can't comment on others. If this is not the ideal way then we could easily mod the scripts for other units that can send a ping. Main diff would be either hard coding device address into sketch (sounds wrong) or sending the device addresses to the jeenode on startup.

Garry

magill
Offline
Joined: 27 Apr 2012
HC-05

Garry I have spent a fair bit of time fighting with this unit and am beginning to suspect that I've got a dud.

I am running at 38400 baud and have hard wired the key pin high.

The unit accepts all AT commands and responds with version info etc but I get error(16) with an INQ request and if I send INIT and then INQ it falls back to pairing mode.

Bob are you getting similar behaviour?

John

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
John,can you wire onto an

John,

can you wire onto an arguino/jeenode and flash my sketch?. If you monitor the serial output you should see inq responses. At least we know the script works on my unit so may help test if your is a dud?!

 

G.

 

one other thought. With the script, the key pin probably doesn't go high until after power on. Have you tried doing it that way?

magill
Offline
Joined: 27 Apr 2012
GarryI've tried every sketch

Garry

I've tried every sketch (yours included) and every combination of commands, but no response. It's a new HC-05 I think.

thanks anyway

John

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Bob I found that "smart"

Bob I found that "smart" phones are too smart for their own good these days
a) they don't leave the BT enabled when they power down.  Crap.
b) things like the iSuck's even have a requirement that its paired. wtf.

Try pulling out the oldest phone you have that has Bluetooth.  I got my best results using an 8 year old phone, strangely this is the phone I use each day as I shun the "smarts" that don't add any value except suck the live out of your battery and mess with the standards.

I does seem that all HC-05 devices are not created equal.  Mine for example didn't like the AT+INIT command.  I'll take a photo of the chips and post later.

I had another though about the bluenode.lua sketch.  It would be nice that if a device is discovered just because its not explicity mentioned as an endpoint when the BlueNode{} is setup you'd want to see it anyway.

If you register the device with a name that will be used otherwise one will be made up that will be the device.
For example:

local nodes = {
   [18] = BlueNode{instance="bluetooth:presence",
                   endpoints={
                      ["1d:fe:720479"] = "brett.1"
                }
           }
}

The device 1d:fe:720479 is setup so we get this -> dbzoo.livebox.bluetooth:presence.brett.1
As the device 12:37:e90912 is not setup we would get this -> dbzoo.livebox.bluetooth:presence.12.37.e90912

With the endpoint being dynamically created based upon its device identifier.  This means in its simpliest form you can setup this as your node and ALL your bluetooth devices will be auto discovered and appear as presence endpoints.  Woo.

   [18] = BlueNode{instance="bluetooth:presence"}

If you want to name the device as an explicit endpoint you can then use the form above...  cool.

Brett

brett
Offline
Providence, United States
Joined: 9 Jan 2010
new bluenode.lua nodule that does dynamic bluebooth endpoints

I committed a new bluenode.lua nodule that does dynamic bluebooth endpoint creation, without you having to define the devices ahead of time in your jeenodeapplet.lua - works for me.

Brett

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
I'm not using an HC-05

but on the general point of smartphones shutting bluetooth down when asleep, I'm pretty convinced that I can l2ping a sleeping iPhone 4S and also a sleeping iPhone 3GS from the Raspi USB dongle setup.

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Allan,I think your right for

Allan,

I think your right for pinging. Issue is hc05 can't do this (at least I ain't found a way) and ios devices only respond to an inquire scan when discoverable. :(

brett
Offline
Providence, United States
Joined: 9 Jan 2010
I've posted up some notes

I've posted up some notes http://www.dbzoo.com/livebox/hah_hahnode/bluenode

There must be a way to make ios devices respond to inquiry scans.  Aren't they permenantly discoverable?   There is a setting on most devices to enable/disable this mode.

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Hi Brett, just following your

Hi Brett,

 

just following your notes on the BT intergration, i've hit a plugboard error on my jeenode applet

 

line 9 is "BlueNode = require("xap.bluenode").BlueNode"

im running beta - Build: 311.3/3.4

--[[
    JeeNode to xAP Endpoint mapping
--]]

--_DEBUG=1
module(...,package.seeall)
local monitor = require("xap.jeenode").monitor
RoomNode = require("xap.roomnode").RoomNode
BlueNode = require("xap.bluenode").BlueNode

 

 

lua: /etc/plugboard/jeenodeApplet.lua:9: attempt to index a boolean value
stack traceback:
        /etc/plugboard/jeenodeApplet.lua:9: in main chunk
        [C]: in function 'require'
        /etc_ro_fs/plugboard/plugboard.lua:23: in function 'fun'
        /usr/share/lua/5.1/pl/tablex.lua:388: in function 'foreach'
        /etc_ro_fs/plugboard/plugboard.lua:66: in main chunk
        [C]: ?
Loading /etc/plugboard/jeenodeApplet.lua    

brett
Offline
Providence, United States
Joined: 9 Jan 2010
The blue node has a reaper at

The blue node has a reaper at the tail end of it and instead of returning the class (aka table) its returning true/false as the last function is not a class method.   I've corrected that 311.4. Strange I never hit that problem when I was testing on my dev linux box with LUA locally.  Anyway easily fixed.

Thanks for the feed back Andrew.

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks Brett, No more

Thanks Brett,

 

No more jeenodeApplet errors now :)

Im also getting an error with what i can assume in the bluenodeApplet.lua but im not 100% positive

Line 24 of the applet is actually blank

lua: /etc_ro_fs/plugboard/plugboard.lua:24: attempt to index local 'applet' (a boolean value)
stack traceback:
        /etc_ro_fs/plugboard/plugboard.lua:24: in function 'fun'
        /usr/share/lua/5.1/pl/tablex.lua:388: in function 'foreach'
        /etc_ro_fs/plugboard/plugboard.lua:66: in main chunk
        [C]: ?
Loading /etc/plugboard/bluenodeApplet.lua       #

thanks

Andrew

brett
Offline
Providence, United States
Joined: 9 Jan 2010
I'm not winning with this

I'm not winning with this one
Instead of requiring like this:

BlueNode = require("xap.bluenode").BlueNode

Change it to this:

BlueNode = require("xap.bluenode")

That is because the module itself is returning the correct object you don't need to reach into and get it.

Umm. there is no blueNodeApplet.lua - that code you pasted (which I removed) is the decoder.  It should not appear in your plugboard directory at all.  Its already on your livebox in /usr/share/lua/5.1/xap/bluenode.lua

The only configuration you need is http://www.dbzoo.com/livebox/hah_hahnode/bluenode#configuration

Brett

mark_baldwin
Offline
Blackburn, United Kingdom
Joined: 19 May 2012
iPhone

From what I can gather bluetooth can be kept on as a background service for an app using an option in xcode but that would require an app to be written to do that. I have an Apple dev account and can therefore create an app but that would then need to be uploaded to the app store for everyone else to use....hmmmm

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
unless you jailbreak :) in

unless you jailbreak :) in which case you dont need the apple devs license

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Andrew did that change get

Andrew did that change get your bluenode sorted?

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Hi Brett,Apologies for the

Hi Brett,

Apologies for the late reply, I ended up crashing the livebox and had to recover with the RGWRepair tool back to 287.dwb,

i put that down to filling memory possible with a debug running in plugboard but cant be 100% sure as i also attempted your latest beta update to 311.4

Anyway that aside i am back up and running seem to be receiving a lot of invalid xap messages, my instance is set to a null, and my hostname is set to livebox

Error Message: Invalid name/value pairing. Address components cannot be empty strings.
Message Line#: 7 - source=dbzoo..jeenode:room1.light
Received From: 192.168.1.12:3077

xap-header
{
v=12
hop=1
uid=FF00D801
class=xAPBSC.info
source=dbzoo..jeenode:room1.light
}
input.state
{
state=?
text=?
}

Error Message: Invalid name/value pairing. Address components cannot be empty strings.
Message Line#: 7 - source=dbzoo..Plugboard
Received From: 192.168.1.12:3078

xap-hbeat
{
v=12
hop=1
uid=FF00D800
class=xap-hbeat.alive
source=dbzoo..Plugboard
interval=60
port=3644
}

Also, i had to add .RoomNode to the RoomNode = require("xap.roomnode") to my jeenodeapplet.lua V4 otherwise it will fail to run

# xap-plugboard
lua: /etc/plugboard/jeenodeApplet.lua:30: attempt to call global 'RoomNode' (a table value)
stack traceback:
        /etc/plugboard/jeenodeApplet.lua:30: in main chunk
        [C]: in function 'require'
        /etc_ro_fs/plugboard/plugboard.lua:23: in function 'fun'
        /usr/share/lua/5.1/pl/tablex.lua:388: in function 'foreach'
        /etc_ro_fs/plugboard/plugboard.lua:66: in main chunk
        [C]: ?
Loading /etc/plugboard/jeenodeApplet.lua        #

Thanks

Andrew

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Andrew, try

Andrew, try adding 

 

[xap]
instance=livebox
To your /etc/xap.d/system.ini file 

 

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Gary in 311.4 beta that

Gary in 311.4 beta that instance= variable is deprecated and shouldn't be used anymore.   The HOSTNAME of the system is now the instance.  This was done so that the code could move platforms more easily.

As Andrews hostname is livebox that should be sufficent to produce dbzoo.<hostname>.item

The xAP packet being produced is from the jeenodeApplet.lua and this too has under gone a rework.

Historically the endpoints would be defined like this:

RoomNode{base="dbzoo.livebox.jeenode:1.sensor" ...}  etc..

But this hardcoded the word "livebox" which I want to avoid so the code can move freely cross system this was changed too.
http://www.dbzoo.com/livebox/hah_plugboard_v2#bsc  If you examine how endpoints are created there are now three variables that replace this:  deviceid, vendorid and instanceid.   99% of the time you only need to set the instanceid the others will default.

Now getting back to where the bug might be.  If you have etc/xap.d/system.ini with instance= set but not defined to any value this will BREAK your system.   Perhaps the bug is mine  Could you confirm?  If this is the case delete the instance= setting. 
I will do a check and only pick up value if its not an empty string.

A few things are changing in the system to allow this code to be more system agnostic in preparation for running on different hardware, unfortunately this mean there will be a little teething pain in moving to the beta and debugging for me.

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks Garry, i was adding

Thanks Garry, i was adding that as you was posting :) its cleared up the invalid messages

just trying to get my head around bretts instance mods....

VendorID.DeviceID.Instance

 

VendorID i understand is equal to "dbzoo"

DeviceID is taken from the system hostname i.e mine is set to "livebox"

Instance is taken from the instance field in the gui, or the [xap] instance setting in the system.ini

shouldnt my xap messages show as dbzoo.livebox.livebox.jeenode:room1 based on this?

also going back to the [xap] section, why does the instance need to equal the hostname?

[xap]
instance=livebox
To your /etc/xap.d/system.ini file

xap-header
{
v=12
hop=1
uid=FF00D801
class=xAPBSC.info
source=dbzoo.livebox.jeenode:room1.light
}
input.state
{
state=?
text=?
}

Thanks

 

Andrew

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks for clearing that up

Thanks for clearing that up Brett

 

i just wasnt getting the whole instance mods but as you mentioned 311.4 changes things and makes sense now

and yes you are correct, the [xap] instance needs to check for null and not process.

thanks

 

Going back to the bluenode / jeenode i appear to be picking up roomnode data but these are not being assinged to my endpoints


# microcom -s 57600 /dev/ttyUSB2

[RF12nocfg.1] A i1 g212 @ 868 MHz

Current basenode configuration:
 A i1 g212 @ 868 MHz

OK 2 5 58 29 0

xap-header
{
v=12
hop=1
uid=FF00D802
class=xAPBSC.info
source=dbzoo.livebox.jeenode:room1.temp
}
input.state
{
state=?
text=?
}

 

Andrew

mark_baldwin
Offline
Blackburn, United Kingdom
Joined: 19 May 2012
That's what we're here for

Beta testing needs to be done and that is what we're here for. 

Keep up the good work Brett. No sign of your Beagle yet?

I've been putting together a page for the wiki for creating a cross compiler for those that want to go down that route. It should allow compiling for BB, RPi etc. Fun and games but getting there.

My other option was to sit on my hands and wait for a pkg install but that would be no fun at all 

brett
Offline
Providence, United States
Joined: 9 Jan 2010
I've pushed 311.5I found a

I've pushed 311.5

I found a bug with having a defined but empty instance= setting, which you reported to be your problem.

The way you include the "nodules" for setting up decoders has changed in this update as well to unify how this is setup.

OLD:  RoomNode = require ("xap.roomnode").RoomNode
NEW: RoomNode = require ("xap.roomnode")

This streamlines the jeenode applet configuration with how the bluenode works.   The others should have been like this too.
The wiki has been updated to reflect the new world of the 311 beta as I like to update the docs as I make changes, but it means its in a funny transition period in that what is says won't work for those on the 311 prod release.  Hopefully this period won't be too long.

Thanks for letting me know about that bug... One more down !

If you update to 311.5 you'll be able to remove/null your instance= setting back out (really you don't want to use this).

Please bear with me during this transition period of 311->312

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Andrew you

Andrew you wrote:

VendorID.DeviceID.Instance

VendorID i understand is equal to "dbzoo"

DeviceID is taken from the system hostname i.e mine is set to "livebox"

Instance is taken from the instance field in the gui, or the [xap] instance setting in the system.ini

Instance is the THING, the xAP program.   Controller, Twitter, Plugboard etc...  its NOT from the ini file.
I agree. xap.d/system.ini [xap] instance=  field is misnamed it should be called deviceid= its a bug from the past.

I didn 't want to change it for fear of backward compatibility issues.  I am however up for renaming it if nobody objects so it makes more sense that its an OVERRIDE for what is normally derived from the hostname.  I should do that as I think calling it instance is actually more confusing as Andrew has pointed out.

The rules is:  The deviceid is derived from the [xap] deviceid=, if this is not present then we fallback to using the 'hostname'.
Why do I do this?  Well if you move all your LUA scripts and configuration to new hardware your hostname might not be 'livebox' but so your xAP stuff still works I let you overrride the hostname, so the transition can be seemless.   (I'm thinking ahead about migration).

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks Brett, updated to

Thanks Brett,

 

updated to 311.5 and modded jeenodeapplet.lua  with "RoomNode = require ("xap.roomnode")" all seems to run fine now both automatically and manually with xap-plugboard

Yes i agree, i think thats a good idea - change [xap] instance to deviceid

i can also confirm my [xap] setting contains no settings and my hostname is being used as the deviceid so the fallback works as you stated.

just one issue now - no data from the roomnode / bluenode being mapped to the endpoints

 

Thanks for your efforts with the beta, looking good and the saving from gui is lightening fast!

Andrew

brett
Offline
Providence, United States
Joined: 9 Jan 2010
no sign of my beagle

Mark no sign of my beagle.  I think the little puppy is on a slow boat from China.   I'm really hanging out for it too !
UPDATE: The beagle has landed (but not on Mars where it crashed and burned).

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Just getting back in to the

Just getting back in to the swing of things with the Bluenode

Im current running Bretts sketch - http://livebox-hah.googlecode.com/svn/trunk/userapps/arduino/Bluetooth/B...

i have updated the sketch from NODE_18 to NODE_ID 3 and added the bluenode references to my jeenodeapplet V4.0 as below

-- Keyed by NODE ID
local nodes = {
   [2] = RoomNode{instance="jeenode:room1", endpoints={temp=1,light=1,humi=1,moved=1,lobat=1}, ttl=900},
   [3] = BlueNode{instance="bluetooth:presence"},

From the WIKI i can see i should be receiving data resembling room node responses i.e data = "OK 18 18 0 55 18 9 233",

Do i need to flash HAH_central and configure the RFM to the correct group / id before uploading the sketch?

Also, currently looking at the debug of my jeenodeapplet and it does not appear to be reaping the bluenode

# xap-plugboard
Loading /etc/plugboard/jeenodeApplet.lua        [ JeeNode ]
build RoomNode[2]
build BlueNode[3]

Running...
Reaping RoomNode[2] alive=true ttl=900 timeout=10
Reaping RoomNode[2] alive=true ttl=900 timeout=20
Reaping RoomNode[2] alive=true ttl=900 timeout=30

thanks

Andrew

 

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Andrew,  Nope you should not

Andrew,  Nope you should not need to configure anything on the central sketch at all.
Assuming you are using group 212, which is what the bluenode sketch is using by default.

As a first step I would check with xFxViewer that you are getting a packet from xap-serial for node 3.

If you aren't then you need to step back and enable serial debugging on the blue node sketch and verify that this is working correctly.   If you are getting serial data then it's the decoder that will be the issue and you can debug into that next.

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks Brett, So the process

Thanks Brett,

 

So the process is the build a fresh room node and flash just the bluenode sketch and nothing else is required?

no other sketches and no config of the RFM module?

No xap-serial from the node as far as i can see in both xfx viewer and using microm

Debugging output

 


[BlueNode.1]3 g212 @ 868Mhz
SYNC> AT
OK
SYNC> AT+NAME=blueNode
OK
SYNC> AT+ROLE=1
OK
SYNC> AT+INQM=0,5,15
OK
ASYNC> AT+INQ
ERROR:(16)
ASYNC> AT+INQ
ERROR:(16)

Thanks

Andrew

brett
Offline
Providence, United States
Joined: 9 Jan 2010
I think you're device needs

I think you're device needs an explicit AT+INIT after the AT+ROLE=1 command is sent.   Some hardware wants it some does not.  Mine did not.

sendBluetoothCommand("AT+ROLE=1", SYNC);
sendBluetoothCommand("AT+INIT", SYNC); // try adding this line here.
sendBluetoothCommand("AT+INQM=0,5,15", SYNC);

@magill I noticed in this thread early you reported the same issue did you get around it?

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
thanks Brett, Will give it a

thanks Brett,

 

Will give it a test this evening after work

 

Andrew

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
I've added the line to the

I've added the line to the bluenode sketch and uploaded to the bluenode

the AT+INIT causes an ERROR:(17)

Are the modules discoverable in a bluetooth scan? mine doesnt appear, prehaps its a faulty module or i am not initialising it correctly


[BlueNode.1]3 g212 @ 868Mhz
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


Andrew

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Andrew,The error 17 just

Andrew,

The error 17 just means its already initialised, it wont cause any trouble. strange though how you've gone from error 16 (not initialised) to 17 (already initialised)? anyhow its working, ignore the error for now.

Devices do not show on a scan, at least not for me. If you make your phone discovorable you should now see the AT+INQ response showing an address.

 

Garry.

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks Garry, the error 16

Thanks Garry,

 

the error 16 was before Brett asked me to add the mod

My Phone is in discovery mode, heres the debug output, no valid detections yet...


[BlueNode.1]3 g212 @ 868Mhz
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
OK
OK
OK
ASYNC> AT+INQ
OK
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ



Andrew

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Andrew from that output it

Andrew from that output it looks like the AT+INQ command is working, strange about the error 17 thou.
As you say its not finding any BT devices to discover.  If you have any non-apple products I would try to discover those first.

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks Brett, Tried the

Thanks Brett,

 

Tried the following handsets

HTC Desire HD

Samsung Galaxy S4

ZTE Blade V

iPhone 4

Will see if i can dig out an old nokia from the office tommorow

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Tried a number of different

Tried a number of different handsets

Lots of

ASYNC> AT+INQ
OK
ASYNC> AT+INQ
OK

but no devices detected, i've also tested with the BlueTerm sketch but this seems to freeze before i can send any AT commands, will post some debug later from Arduino

thanks

 

Andrew

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
8 Different phones tested

8 Different phones tested now, no device address shown, just ordered a replacement HC-05 from china so have a week or two to play with this one unless its a bad one.

I noticed in the WIKI the device addresses are returned by the jeenode applet. Should i also see these device addresses in the sketch in debug mode rather than just the OK responses?


[BlueNode.1]3 g212 @ 868Mhz
SYNC> AT
OK
SYNC> AT+NAME=blueNode
OK
SYNC> AT+ROLE=1
OK
SYNC> AT+INQM=0,5,15
OK
ASYNC> AT+INQ
OK
OK
OK
OK
ASYNC> AT+INQ
OK
OK
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ
OK
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ

thanks

 

Andrew

Hardware Info