I am creating a system with one BLE central device (nRF52840 DK) and many peripherals (nRF52840 Dongles). I am attempting to create a BLE central device that interfaces with the BLE peripheral template below:
https://github.com/bjornspockeli/custom_ble_service_example
I was able to create a simple custom service that controls LEDs connected so the GPIOs of an nRF52840 Dongle (ble_cus.h)
// Snippet from ble_cus.h /*************************************** * Libaries ***************************************/ #include <stdint.h> #include <stdbool.h> #include "ble.h" #include "ble_srv_common.h" /*************************************** * Macros ***************************************/ /**@brief Macro for defining a ble_hrs instance. * * @param _name Name of the instance. * @hideinitializer */ #define BLE_CUS_DEF(_name) \ static ble_cus_t _name; \ NRF_SDH_BLE_OBSERVER(_name ## _obs, \ BLE_HRS_BLE_OBSERVER_PRIO, \ ble_cus_on_ble_evt, &_name)
In doing so, I followed the following tutorial as a guide to try to make a BLE central device:
https://www.novelbits.io/ble-central-lightbulb-remote-control/
I used the ble_app_mulitlink_central example, and have added the libraries mentioned in the example. Below is a snippet from my custom service header file.
// Snippet from led_service_client.h /*************************************** * Libaries ***************************************/ #include <stdint.h> #include <stdbool.h> #include "ble.h" #include "ble_srv_common.h" #include "ble_db_discovery.h" #include "nrf_sdh_ble.h" /*************************************** * Macros ***************************************/ /**@brief Macro for defining an led_service_client instance. * * @param _name Name of the instance. * @hideinitializer */ #define BLE_LED_SERVICE_CLIENT_BLE_OBSERVER_PRIO 2 #define BLE_LED_SERVICE_CLIENT_DEF(_name) static ble_led_service_client_t _name; NRF_SDH_BLE_OBSERVER(_name ## _obs, BLE_LED_SERVICE_CLIENT_BLE_OBSERVER_PRIO, ble_led_service_client_on_ble_evt, &_name)
However, while the former compiled, the latter returned the following errors:
Building ‘ble_app_multilink_central_pca10056_s140’ from solution ‘ble_app_multilink_central_pca10056_s140’ in configuration ‘Release’ Compiling ‘main.c’ main.c unknown type name 'ble_led_service_client_t' nrf_section_iter.h nrf_sdh.h main.c stray '##' in program in definition of macro 'NRF_SECTION_ITEM_REGISTER' in expansion of macro 'NRF_SECTION_SET_ITEM_REGISTER' in expansion of macro 'NRF_SDH_BLE_OBSERVER' expected '=', ',', ';', 'asm' or '__attribute__' before '_obs' in definition of macro 'NRF_SECTION_ITEM_REGISTER' in expansion of macro 'NRF_SECTION_SET_ITEM_REGISTER' in expansion of macro 'NRF_SDH_BLE_OBSERVER' 'm_ble_led_service_client' undeclared (first use in this function); did you mean 'ble_led_service_client_t'? each undeclared identifier is reported only once for each function it appears in 'm_ble_led_service_client' undeclared (first use in this function); did you mean 'ble_led_service_client_t'? 'm_ble_led_service_client' undeclared (first use in this function); did you mean 'ble_led_service_client_t'? 'm_ble_led_service_client' undeclared (first use in this function); did you mean 'ble_led_service_client_t'? 'm_ble_led_service_client' undeclared (first use in this function); did you mean 'ble_led_service_client_t'? Compiling ‘led_service_client.c’ led_service_client.c unknown type name 'ble_led_service_client_t' nrf_section_iter.h nrf_sdh_ble.h led_service_client.h led_service_client.c stray '##' in program in definition of macro 'NRF_SECTION_ITEM_REGISTER' in expansion of macro 'NRF_SECTION_SET_ITEM_REGISTER' in expansion of macro 'NRF_SDH_BLE_OBSERVER' expected '=', ',', ';', 'asm' or '__attribute__' before '_obs' in definition of macro 'NRF_SECTION_ITEM_REGISTER' in expansion of macro 'NRF_SECTION_SET_ITEM_REGISTER' in expansion of macro 'NRF_SDH_BLE_OBSERVER' led_service_client.c expected expression before '{' token in expansion of macro 'CUSTOM_SERVICE_UUID_BASE' Compiling ‘SEGGER_RTT.c’ Compiling ‘ble_advdata.c’ Compiling ‘ble_advertising.c’ Compiling ‘ble_conn_state.c’ Compiling ‘nrf_ble_gatt.c’ Compiling ‘ble_conn_params.c’ Compiling ‘gatt_cache_manager.c’ Compiling ‘gatts_cache_manager.c’ Compiling ‘id_manager.c’ Compiling ‘peer_data_storage.c’ Build failed
Double-clicking the errors brought me this in led_service_client.h:
Things I have tried:
- Adding the same libraries/drivers in the ble_app_template to ble_app_multilink_central
- Importing the code to ble_app_uart_c (it was recommended ble_app_uart_c was a good template for central applications)
- Chaning the number of vendor specific UUIDs in sdk_config.h
- Bashing my head against a wall
Below are what I'm running:
- nRF SDK v15.0.0
- Segger Embedded Studio Release 5.4.0
I feel like it could be an error with the sdk_config.h, but I have no idea where it would be. Any help would be greatly appreciated.
Thank you in advance.