View unanswered posts | View active topics It is currently Sun Dec 17, 2017 6:22 am



Reply to topic  [ 8 posts ] 
Sample: Read Local Devices Address and write it to the GATT 
Author Message
Site Admin

Joined: Thu Aug 02, 2012 11:36 am
Posts: 166
Hello all,
as I mentioned in the board descriptions, I wanted to use this board to discuss and show code samples dealing with the BLE112 module.
For some hardware projects it might be good to have a Unique ID e.g. the local devices BD Address to distinguish it from others which are discovered for instance by the iPhone.
Moreover hardcoding the BD Addr to a characteristic is lot of manual work to do before a product is shipped. I had this problem with the BLE Shield's firmware implementation and I was thinking how I can achieve both features:

1.) BD Address in the peripherals name
2.) BD Address in a characteristic.

Since there is no event in the BLE112 module firmware yet, where the firmware could react if a given characteristic is read, I was thinking of a possibility to write the peripherals GATT in the boot event of the BLE112 module's firmware.

After some remote hacking with Simon Taylor @Phooto, Jon Prevo @ConnectUrLife and some hints from Bluegiga's support I finished the first sample project I would like to share in this forum. A zip file containing the sample project file is attached to this post.

After you flashed the firmware e.g. to a BLE112 Eval kit, the devices name shows up as "Sample1-xxxxxxxxxxxx" where the xxx'es are substituted by the BD Address of the BLE112 modules.
Moreover there is a characteristic included, which contains the BD Address only.

The devices name is encoded as String and the BD Address Characteristic is encoded as hex values.
The HEX to Ascii encoding is taken from Bluegiga's BGScript Developer Guide.

Hope this sample will help developers to get more familiar with BGScript, as it helped me as well.

Happy coding,
Michael.


Attachments:
mkroll_mobi-BLE112-sample1.zip [93.68 KiB]
Downloaded 1263 times
Sun Aug 12, 2012 8:11 pm
Profile WWW

Joined: Fri Aug 03, 2012 9:38 pm
Posts: 18
Thanks for this, I already integrated this idea into my camera timer. Now I can easily tell the difference between each device!


Sun Aug 12, 2012 9:07 pm
Profile
Site Admin

Joined: Thu Aug 02, 2012 11:36 am
Posts: 166
Yes, this is exactly the intention of the mechanism :-)


Mon Aug 13, 2012 9:35 am
Profile WWW

Joined: Sat Sep 01, 2012 8:10 am
Posts: 7
I am very interested in this idea. I will have multiple devices in the same building and I need to know which one I am connected to.
I have been studying the example you posted and I am trying to correlate your example back to your BLE Shield files.
Can you provide some insights on how to update the BLE Shield files to accomplish this same capability with the Shield?

Also, would it be possible to create a characteristic that the user on the iPad/iPhone could write to, that value would be stored into the BLE112 non-volatile memory, and then after booting the BLE112, the BLE112 would read this value and add it to the devices name before it starts to advertise? This would allow the user to create some better human-readable device names for each of their devices (such as which room the device is in or what the device does).


Fri Sep 07, 2012 7:54 pm
Profile
Site Admin

Joined: Thu Aug 02, 2012 11:36 am
Posts: 166
What about adding the last two bytes of the BLE Shields BD Address to the end of the name?

BLE-Shield-XXXX

Once connected you can read the complete BD Address easily.

I can add this to the BLE Shield firmware v1.0.0 which is in preparation and will be released soon.

Cheers,
Michael.


Fri Sep 07, 2012 8:15 pm
Profile WWW
Site Admin

Joined: Thu Aug 02, 2012 11:36 am
Posts: 166
To quick...
Yes, there could be a characteristic for this purpose as well.
Think we can implement both features.

We need to define how the name of the Shield should look like?
The BLE Shield is advertising its primary service, so you know, that this is a BLE Shield.
Should we get rid of the name "BLE-Shield" completely, or should we just add a suffix?

Since on iOS the name is restricted to 20 bytes, we have not too much space left when we want to use "BLE-Shield" as prefix.
Ten Chars are already used, so we can 10 left.

What do you think?

Cheers,
Michael.


Fri Sep 07, 2012 8:19 pm
Profile WWW

Joined: Sat Sep 01, 2012 8:10 am
Posts: 7
Could "BLE Shield" be the default name and then the User can overwrite all 20 bytes via the characteristic (if they wanted to)?


Fri Sep 07, 2012 8:24 pm
Profile
Site Admin

Joined: Thu Aug 02, 2012 11:36 am
Posts: 166
Sure I can implement it that way.
Will try this over the weekend and let you know.

I'll start another thread on the BLE Shield board, about the Firmware adjustments for v1.0.0 which you mentioned in your emails.
It would be great if you could share the photos of the BLE Shield you built.

Cheers,
Michael.


Fri Sep 07, 2012 9:05 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.