This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to handle characteristic data?

Hello,

For me, at the moment there are two things unclear. With the help of some Nordic examples, I was able to add a Service with 3 characteristics to the used S120 BLE stack. I`m able to connect to the PCA10028 demoboard via a Smartphone. I can see the service/characteristics with the nordic master control panel (Android).

The first two characteristics are defined readable only. The 3rd characteristic is defined readable/writable.

So the first question is, how I can add data to the first two characteristics? For example, I want to write 0xFFAAFFAA to the first chracteristic. My expectation is, if I read out the first characteristic with the Smartphone, I get 0xFFAAFFAA. Where do I have to place this data to the characteristic?

The second question is, how do I get data written from the Smartphone? I tried to see the written data (for example 0xFF) with the debugger (watch window). But I wasn`t able to get the written data. In which function do I have to handle the received data? In which variable the received data is stored?

Thanks in advance for any help!

Regards!

  • A small leak will sink a great ship... Thank you Ulrich!! Now reading and writing my variables is working... By the way, is there any documentation of how to set up a new characteristic additional to the SDK? I think the missing read Flag was a copy paste error because the UART example (I copied from there) didn`t use this. I know the apllication note 36. But there is no detailed code description...

  • The property flags are not actually enforcing anything, they are just indications to the peer that this characteristic supports to be e.g. read. It should be possible to read things even without the flag set, but "intelligent" tools might hide the option to do so based on the available flags.

    To add new characteristics in addition to the SDK, I would just look closely on how the SDK is handling modules like BAS (Battery Service). They have an init() function that adds all services/characteristics and saves their handles internally. Also an on_ble_evt() function that looks through incoming events to see if something is interesting (using the saved handles to compare).

Related