What do I need to know to add mesh functionality into a normal BLE application ?
What do I need to know to add mesh functionality into a normal BLE application ?
We currently working on a tutorial on how to merge a mesh application into our nRF5 SDK BLE example. We will update this thread when we finish. For now we provide a quick example so that you can follow.
Mesh stack operates on the timeslot feature provided by the same softdevice used on the nRF5 SDK. So it requires little modification in the Mesh stack to be integrated into a normal BLE example. In fact only modification in the application code needed.
Attached here is an example that we merge the light control server example into ble_app_uart.
Requires:
How to test:
Limitation:
Permanent storage of provisioning and configuration is not stored on flash. After reboot, the device would require provisioning again. We are working to fix this. The reason is the flash management on 2 SDKs are not the same and can conflict.
Only S132 v5.0, PCA10040, and SES is supported in the example for now.
Connection interval of BLE application have to be changed >100ms to give enough time for mesh
How to integrate into your own application:
Include all the source file from Mesh example
Include all header folders from Mesh example in Project Option -> Common -> Preprocessor -> Include Directories
Include Preprocessor Definitions in mesh example ( same setting tab as above).
Customize the simple_hal.c to not use GPIOTE_IRQHandler() as it conflicts with the gpiote driver in the SDK
Set PERSISTENT_STORAGE to 0
Edit main.c to add mesh init functions and define.
Add nrf_mesh_evt_handler to SOC observer list with NRF_SDH_SOC_OBSERVER for example:
void nrf_mesh_evt_handler(uint32_t sys_evt, void * p_context) {
nrf_mesh_on_sd_evt(sys_evt);
}
NRF_SDH_SOC_OBSERVER(m_nrf_mesh_observer, 0, nrf_mesh_evt_handler, NULL);
Add nrf_mesh_on_ble_evt((ble_evt_t *)p_ble_evt); to BLE observer list with NRF_SDH_BLE_OBSERVER; or just simply add it into ble_evt_handler(). (Optional)
Attachment:
UPDATE 12Jan2018
Example for SDK v14.2 and Mesh v1.0, nRF52840 and nRF52832:
Light switch client + ble app uart . Send BLE command on NUS service with '0' '1' '2' '3' as button press. Copy mesh SDK into mesh_sdk folder inside nRF5 SDK folder.
Light switch server + ble app proximity
@Hung Bui: I have been playing around with the variables you mentioned:
#define SCAN_INTERVAL 0x0020 /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW 0x0010 /**< Determines scan window in units of 0.625 millisecond. */
#define SCAN_TIMEOUT 0x0000 /**< Timeout when scanning. 0x0000 disables timeout. */
#define SCAN_INTERVAL 0x0050 /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW 0x0020 /**< Determines scan window in units of 0.625 millisecond. */
#define SCAN_TIMEOUT 0x0000 /**< Timeout when scanning. 0x0000 disables timeout. */
#define SCAN_INTERVAL 0x00A0 /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW 0x0050 /**< Determines scan window in units of 0.625 millisecond. */
#define SCAN_TIMEOUT 0x0000 /**< Timeout when scanning. 0x0000 disables timeout. */
Does not seem to have a lot of succes. Everytime I do something with BLE all my mesh packets are not received or processed. Also the scanning settings should not matter when I put the amount of central links to 1 and stop scanning once that 1 peripheral has been found right ?
So with TCP/IP, I2C, SPI we have ways of trouble shooting the communication using wireshark or a logic analyzer. Like you mentioned in your video @ nRFsniffer
For my application and projects succes I suspect I will need to be able to sniff BLE traffic. Does the nRF51-Dongle also support BL mesh packets and BL 5 packets ?
@Hung Bui: I have been playing around with the variables you mentioned:
#define SCAN_INTERVAL 0x0020 /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW 0x0010 /**< Determines scan window in units of 0.625 millisecond. */
#define SCAN_TIMEOUT 0x0000 /**< Timeout when scanning. 0x0000 disables timeout. */
#define SCAN_INTERVAL 0x0050 /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW 0x0020 /**< Determines scan window in units of 0.625 millisecond. */
#define SCAN_TIMEOUT 0x0000 /**< Timeout when scanning. 0x0000 disables timeout. */
#define SCAN_INTERVAL 0x00A0 /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW 0x0050 /**< Determines scan window in units of 0.625 millisecond. */
#define SCAN_TIMEOUT 0x0000 /**< Timeout when scanning. 0x0000 disables timeout. */
Does not seem to have a lot of succes. Everytime I do something with BLE all my mesh packets are not received or processed. Also the scanning settings should not matter when I put the amount of central links to 1 and stop scanning once that 1 peripheral has been found right ?
So with TCP/IP, I2C, SPI we have ways of trouble shooting the communication using wireshark or a logic analyzer. Like you mentioned in your video @ nRFsniffer
For my application and projects succes I suspect I will need to be able to sniff BLE traffic. Does the nRF51-Dongle also support BL mesh packets and BL 5 packets ?