Read / Write Error in BGAPI for BlueGiga BLE112 Modules

I am trying to implement a connection between BLE112 and BLE112 Smart Dongle BlueGiga .

These two sets support AT.
I managed to pair the two between the BLEGUI tool, as shown in the screenshot below.

enter image description here

For read operations, the console displays the following:

ble_cmd_attclient_read_by_handle connection: 0 chrhandle: 3 TX: 00030404000300 ble_rsp_attclient_read_by_handle connection: 0 result: 0 ['No Error'] RX: 00030404000000 ble_evt_attclient_attribute_value connection: 0 atthandle: 3 type: 0 value:426c75656769676120554152542044656d6f RX: 801704050003000012426c75656769676120554152542044656d6f 

The above lines mean that the client (BLED112 USB Dongle) can read the third attrbute value stored on the server (BLE112 board). This value was right there when I received it.

Now the part below shows that I tried to read the 7th attribute, which is not on the device, but I intend to create. Since the followinf read command was written by me directly on the BLEGUI console, it looks different than what it would be visible and was sent via the buttons present on the BLEGUI.

 ble_cmd_attclient_read_by_handle 0 7 TX: 00030404000700 ble_rsp_attclient_read_by_handle connection: 0 result: 0 ['No Error'] RX: 00030404000700 ble_evt_attclient_procedure_completed connection: 0 result: 401 ['The attribute handle given was not valid on this server']chrhandle: 7 RX: 800504010001040700 

I have the following questions:

  • Can I create new (user defined) attributes on the device?
  • Can I write / modify existing attributes on a device?
  • If I intend to store any data on the device, how can this be done?
+2
bluetooth-lowenergy bluegiga
source share
2 answers

Yes, you can create and download your own firmware on the BLE112 board, with the services and characteristics you have defined. A good guide to this process is the Bluegiga Application Note โ€œDeveloping Your First Smart Smart Application,โ€ which can be found here: BLE112 Documentation and Software

As for data storage, BLE112 has a permanent storage in which you can store pairs (key, value). Take a look at the Bluetooth Smart Software API Reference document for details on how to access it. This document can also be found at the above link.

+3
source share

For those who look at this question later, I will try to implement some sample code.

Can I create new (user defined) attributes on the device?

Can I write / modify existing attributes on a device?

@stathisv posted links for Bluegiga documentation, but here are some practical examples: https://github.com/sureshjoshi/ble113-firmware-examples

You need to edit the gatt.xml file, define a service (or use an existing one) and define a characteristic. For example:

 <service uuid="aaa51666-e7cb-469b-8e4d-2742f1ba7aaa" advertise="true"> <characteristic uuid="0dddd780-b042-4876-aae1-112855353ddd" id="xgatt_who"> <description>Who Am I</description> <properties read="true" notify="true" /> <value length="1" /> </characteristic> </service> 

If I intend to store any data on the device, how can this be done?

I wrote a compilation example here: https://github.com/sureshjoshi/ble113-firmware-examples/tree/master/Persistence , but the basics are as simple as the two API commands:

 # Write value to PS-store call flash_ps_save($8000, 2, value_data(0:2)) # Read value from PS-store call flash_ps_load($8000)(read_result, len, data(0:2)) 

The only real trick is $ 8000, which is the first used (permanent) memory address according to the Bluegiga documentation.

Please note that if you overwrite the BLE112 / BLE113 firmware using CC-Debugger or OTA, you erase all the information about the permanent memory.

+2
source share

All Articles