ljaynes wrote on April 30, 2019:
I am trying to add a new service to the Nordic MQTT over BLE demo but I cannot seem to get it to work. I have posted my code below. Can someone tell me what I am doing wrong? The code runs and returns success on IotBle_CreateService but I do not see a new service when I check the BLE connection.
#define BLE_CHAR_UUID_TEST { 0x20, 0xFF}
#define BLE_CHAR_UUID_CTRL { 0x2E, 0xFF}
#define BLE_SERVICE_UUID_TEST_TYPE \
{ \
.uu.uu128 = BLE_CHAR_UUID_TEST,\
.ucType = eBTuuidType128 \
}
#define BLE_CHAR_UUID_CTRL_TYPE \
{ \
.uu.uu128 = BLE_CHAR_UUID_CTRL,\
.ucType = eBTuuidType128 \
}
static uint16_t _handlesBuffer[1];
static BTService_t _BLEServices[ 1 ] = { 0 };
static void test_callback( IotBleAttributeEvent_t * pEventParam );
static const IotBleAttributeEventCallback_t pCallBackArray[2] =
{
NULL,
test_callback,
};
static const BTAttribute_t pAttributeTable[] = {
{
.xServiceUUID = BLE_SERVICE_UUID_TEST_TYPE
},
{
.xAttributeType = eBTDbCharacteristic,
.xCharacteristic =
{
.xUuid = BLE_CHAR_UUID_CTRL_TYPE,
.xPermissions = ( IOT_BLE_CHAR_READ_PERM | IOT_BLE_CHAR_WRITE_PERM ),
.xProperties = ( eBTPropRead | eBTPropWrite )
}
}
};
void ble_init( void )
{
BTService_t pBTService;
BTStatus_t status = eBTStatusFail;
BaseType_t error = pdFAIL;
/* Initialize service */
pBTService.pusHandlesBuffer = _handlesBuffer;
pBTService.ucInstId = 1;
pBTService.xNumberOfAttributes = 1;
pBTService.pxBLEAttributes = (BTAttribute_t *)pAttributeTable;
status = IotBle_CreateService( &pBTService, (IotBleAttributeEventCallback_t *)pCallBackArray );
if (status != eBTStatusSuccess)
SEGGER_RTT_printf(0, "Error creating BLE service
");
else
SEGGER_RTT_printf(0, "Ble service created
");
}
static void test_callback( IotBleAttributeEvent_t * pEventParam )
{
SEGGER_RTT_printf(0, "Ble test callback
");
},