Hi,
I have read through this tutorials on how to develop custom UUID, and I have implemented it successfully.
But I need to have 2 characteristics. I have basically duplicated the codes for the custom UUID in order to have 2 characteristics.
I am not sure that is the way to do it.
When I compile, there is no error but I am not able to see the second characteristics on the nRF Connect.
Below is snippet of the code for ble_cus.h
// CUSTOM_SERVICE_UUID_BASE f364adc9-b000-4042-ba50-05ca45bf8abc : ADC9 taken as the 16bit Serivice. Added 1 to have the characteristics
#define CUSTOM_SERVICE_UUID_BASE {0xBC, 0x8A, 0xBF, 0x45, 0xCA, 0x05, 0x50, 0xBA, \
0x42, 0x40, 0x00, 0xB0, 0xC9, 0xAD, 0x64, 0xF3}
#define CUSTOM_SERVICE_UUID 0xADC9
#define CUSTOM_VALUE_CHAR_UUID 0xADCA
#define CUSTOM_VALUE2_CHAR_UUID 0xADCB /**<Added for second characteristics, and increased NRF_SDH_BLE_VS_UUID_COUNT to 2 but it didn't advertise*/
/**@brief Custom Service event type. */
typedef enum
{
BLE_CUS_EVT_NOTIFICATION_ENABLED, /**< Custom value notification enabled event. */
BLE_CUS_EVT_NOTIFICATION_DISABLED, /**< Custom value notification disabled event. */
BLE_CUS_EVT_DISCONNECTED,
BLE_CUS_EVT_CONNECTED
} ble_cus_evt_type_t;
/**@brief Custom Service event. */
typedef struct
{
ble_cus_evt_type_t evt_type; /**< Type of event. */
} ble_cus_evt_t;
// Forward declaration of the ble_cus_t type.
typedef struct ble_cus_s ble_cus_t;
/**@brief Custom Service event handler type. */
typedef void (*ble_cus_evt_handler_t) (ble_cus_t * p_bas, ble_cus_evt_t * p_evt);
/**@brief Battery Service init structure. This contains all options and data needed for
* initialization of the service.*/
typedef struct
{
ble_cus_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Custom Service. */
uint8_t initial_custom_value; /**< Initial custom value */
ble_srv_cccd_security_mode_t custom_value_char_attr_md; /**< Initial security level for first Custom characteristics attribute */
ble_srv_cccd_security_mode_t custom_value2_char_attr_md; /**< Initial security level for second Custom characteristics attribute */
} ble_cus_init_t;
/**@brief Custom Service structure. This contains various status information for the service. */
struct ble_cus_s
{
ble_cus_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Custom Service. */
uint16_t service_handle; /**< Handle of Custom Service (as provided by the BLE stack). */
ble_gatts_char_handles_t custom_value_handles; /**< Handles related to the Custom Value first characteristic. */
ble_gatts_char_handles_t custom_value2_handles; /**< Handles related to the Custom Value second characteristic. */
uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
uint8_t uuid_type;
};
/**@brief Function for initializing the Custom Service.
*
* @param[out] p_cus Custom Service structure. This structure will have to be supplied by
* the application. It will be initialized by this function, and will later
* be used to identify this particular service instance.
* @param[in] p_cus_init Information needed to initialize the service.
*
* @return NRF_SUCCESS on successful initialization of service, otherwise an error code.
*/
uint32_t ble_cus_init(ble_cus_t * p_cus, const ble_cus_init_t * p_cus_init);
/**@brief Function for handling the Application's BLE Stack events.
*
* @details Handles all events from the BLE stack of interest to the Battery Service.
*
* @note
*
* @param[in] p_cus Custom Service structure.
* @param[in] p_ble_evt Event received from the BLE stack.
*/
void ble_cus_on_ble_evt( ble_evt_t const * p_ble_evt, void * p_context);
/**@brief Function for updating the custom value.
*
* @details The application calls this function when the cutom value should be updated. If
* notification has been enabled, the custom value characteristic is sent to the client.
*
* @note
*
* @param[in] p_bas Custom Service structure.
* @param[in] Custom value
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
uint32_t ble_cus_custom_value_update(ble_cus_t * p_cus, uint8_t custom_value);
uint32_t ble_cus_custom_value2_update(ble_cus_t * p_cus, uint8_t custom_value2);
#endif // BLE_CUS_H__I also tried to change the NRF_SDH_BLE_VS_UUID_COUNT from 1 to 2 but instead the DK does not advertise.
I appreciate any guide to resolving this. Thanks.