In this blog, it shows how to modify the device parameters through the BLE connection. The example has included the NUS service, Battery Service and Thingy configuration service (TCS). On top of the TCS, some extra characteristic are added such as TX power, advertising content for non-connectable advertising) and password protection.
In additional, I provide a method how to dynamic change the advertising payload without restart the advertising module. The idea is to use the pointer instead of copying the value.

All the BLE characteristic of Thingy Configuration Services are showed as below.
- Device Name
- Advertising interval
- Connection interval (Minimum and Maximum interval)
- FW version (read)
- MTU size
- TX Power
- Connection Protection Password
- Advertising content (non-connectable advertising)
- Verify the Password

All the parameters would be stored at the internal flash of nRF52 through FDS module.
Details on the implementation
Change the Device Name
#define DEVICE_NAME "UART_ADV" /**< Name of device. Will be included in the advertising data. */
The maximum length of the device name is 10 bytes.


How to measure the battery information on the device



How to set the TX Power during the advertising
On the nrF52832, it has supported the following TX Power setting.


How to set the Password / Verify the Password after connection
- pwd_char_add — read/write for 4 digits password protection
- pwd_verify_char_add — use for verify the password


For the password verification, it is controlled by the compile switch at the sdk_config.h. The host needs to send/write the correct 4 digit password for verification within first 30 seconds (NRF_PWD_TIMEOUT_PERIOD) after connection. Otherwise, the BLE link is automatically disconnected.




How to set the non-connectable advertising payload
On this example, it supports two difference advertising mode.
- Non-connectable advertising
- Connectable undirected advertising
By pressing the button 0 during the power up, the device would run as the connectable advertising mode.

Dynamic change the Advertising content without stop/start the advertising module
Background
During the advertising init, you need to specify all the advertising parameter and then call the routine ble_advdata_encode. After that it passes the encoded data on the advertising payload.

Instead of dynamic change the advertising content, you can hardcode the enc_advdata.

And then, pass the hardcode_enc_adadata to the advertising module.

Requirement
- SDK 15.3 / S132v6.1.1
- NRF52832 DK
- IDE: Segger Embedded Studio
Source Code:
https://github.com/jimmywong2003/nrf5-modify-device-parameter-through-host
very interesting details you have remarked, appreciate it for putting up.
LikeLike
I don’t even know how I ended up here, but I thought this post
was great. I don’t know who you are but certainly you’re going to
a famous blogger if you aren’t already 😉 Cheers!
LikeLike