update debug.cpp
- added error string - reduce default attr table size from 0xb00 to 0x800
This commit is contained in:
1 parent
98775cd9de
commit
5607011996
2 files changed
+112
-22
No files matched your search
+103
-16
@@ -218,10 +218,6 @@ void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffs
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/*
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
#if CFG_DEBUG
|
||||
|
||||
#include "ble.h"
|
||||
@@ -229,8 +225,12 @@ void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffs
|
||||
|
||||
// TODO require update when upgrading SoftDevice
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Event String
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
// Common BLE Event base
|
||||
static const char* _base_evt_str[] =
|
||||
static const char* _evt_base_str[] =
|
||||
{
|
||||
#if SD_VER < 500
|
||||
"BLE_EVT_TX_COMPLETE" ,
|
||||
@@ -239,7 +239,7 @@ static const char* _base_evt_str[] =
|
||||
"BLE_EVT_USER_MEM_RELEASE" ,
|
||||
};
|
||||
|
||||
static const char* _gap_evt_str[] =
|
||||
static const char* _evt_gap_str[] =
|
||||
{
|
||||
"BLE_GAP_EVT_CONNECTED" ,
|
||||
"BLE_GAP_EVT_DISCONNECTED" ,
|
||||
@@ -265,7 +265,7 @@ static const char* _gap_evt_str[] =
|
||||
};
|
||||
|
||||
// GATTC Event
|
||||
static const char* _gattc_evt_str[] =
|
||||
static const char* _evt_gattc_str[] =
|
||||
{
|
||||
"BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP" ,
|
||||
"BLE_GATTC_EVT_REL_DISC_RSP" ,
|
||||
@@ -287,7 +287,7 @@ static const char* _gattc_evt_str[] =
|
||||
};
|
||||
|
||||
// GATTS Event
|
||||
static const char* _gatts_evt_str[] =
|
||||
static const char* _evt_gatts_str[] =
|
||||
{
|
||||
"BLE_GATTS_EVT_WRITE" ,
|
||||
"BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST" ,
|
||||
@@ -307,14 +307,14 @@ const char* dbg_ble_event_str(uint16_t evt_id)
|
||||
{
|
||||
static char unknown_evt[7] = {0};
|
||||
|
||||
if ( is_within(BLE_EVT_BASE, evt_id, BLE_EVT_BASE+arrcount(_base_evt_str)) )
|
||||
return _base_evt_str[evt_id-BLE_EVT_BASE];
|
||||
else if ( is_within(BLE_GAP_EVT_BASE, evt_id, BLE_GAP_EVT_BASE+arrcount(_gap_evt_str)) )
|
||||
return _gap_evt_str[evt_id-BLE_GAP_EVT_BASE];
|
||||
else if ( is_within(BLE_GATTC_EVT_BASE, evt_id, BLE_GATTC_EVT_BASE+arrcount(_gattc_evt_str) ) )
|
||||
return _gattc_evt_str[evt_id-BLE_GATTC_EVT_BASE];
|
||||
else if ( is_within(BLE_GATTS_EVT_BASE, evt_id, BLE_GATTS_EVT_BASE+arrcount(_gatts_evt_str)) )
|
||||
return _gatts_evt_str[evt_id-BLE_GATTS_EVT_BASE];
|
||||
if ( is_within(BLE_EVT_BASE, evt_id, BLE_EVT_BASE+arrcount(_evt_base_str)) )
|
||||
return _evt_base_str[evt_id-BLE_EVT_BASE];
|
||||
else if ( is_within(BLE_GAP_EVT_BASE, evt_id, BLE_GAP_EVT_BASE+arrcount(_evt_gap_str)) )
|
||||
return _evt_gap_str[evt_id-BLE_GAP_EVT_BASE];
|
||||
else if ( is_within(BLE_GATTC_EVT_BASE, evt_id, BLE_GATTC_EVT_BASE+arrcount(_evt_gattc_str) ) )
|
||||
return _evt_gattc_str[evt_id-BLE_GATTC_EVT_BASE];
|
||||
else if ( is_within(BLE_GATTS_EVT_BASE, evt_id, BLE_GATTS_EVT_BASE+arrcount(_evt_gatts_str)) )
|
||||
return _evt_gatts_str[evt_id-BLE_GATTS_EVT_BASE];
|
||||
else
|
||||
{
|
||||
sprintf(unknown_evt, "0x%04X", evt_id);
|
||||
@@ -322,5 +322,92 @@ const char* dbg_ble_event_str(uint16_t evt_id)
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Error String
|
||||
*------------------------------------------------------------------*/
|
||||
static lookup_entry_t const _err_lookup_items[] =
|
||||
{
|
||||
// General
|
||||
{ .key = NRF_ERROR_SVC_HANDLER_MISSING , .data = "NRF_ERROR_SVC_HANDLER_MISSING" },
|
||||
{ .key = NRF_ERROR_SOFTDEVICE_NOT_ENABLED , .data = "NRF_ERROR_SOFTDEVICE_NOT_ENABLED" },
|
||||
{ .key = NRF_ERROR_INTERNAL , .data = "NRF_ERROR_INTERNAL" },
|
||||
{ .key = NRF_ERROR_NO_MEM , .data = "NRF_ERROR_NO_MEM" },
|
||||
{ .key = NRF_ERROR_NOT_FOUND , .data = "NRF_ERROR_NOT_FOUND" },
|
||||
{ .key = NRF_ERROR_NOT_SUPPORTED , .data = "NRF_ERROR_NOT_SUPPORTED" },
|
||||
{ .key = NRF_ERROR_INVALID_PARAM , .data = "NRF_ERROR_INVALID_PARAM" },
|
||||
{ .key = NRF_ERROR_INVALID_STATE , .data = "NRF_ERROR_INVALID_STATE" },
|
||||
{ .key = NRF_ERROR_INVALID_LENGTH , .data = "NRF_ERROR_INVALID_LENGTH" },
|
||||
{ .key = NRF_ERROR_INVALID_FLAGS , .data = "NRF_ERROR_INVALID_FLAGS" },
|
||||
{ .key = NRF_ERROR_INVALID_DATA , .data = "NRF_ERROR_INVALID_DATA" },
|
||||
{ .key = NRF_ERROR_DATA_SIZE , .data = "NRF_ERROR_DATA_SIZE" },
|
||||
{ .key = NRF_ERROR_TIMEOUT , .data = "NRF_ERROR_TIMEOUT" },
|
||||
{ .key = NRF_ERROR_NULL , .data = "NRF_ERROR_NULL" },
|
||||
{ .key = NRF_ERROR_FORBIDDEN , .data = "NRF_ERROR_FORBIDDEN" },
|
||||
{ .key = NRF_ERROR_INVALID_ADDR , .data = "NRF_ERROR_INVALID_ADDR" },
|
||||
{ .key = NRF_ERROR_BUSY , .data = "NRF_ERROR_BUSY" },
|
||||
{ .key = NRF_ERROR_CONN_COUNT , .data = "NRF_ERROR_CONN_COUNT" },
|
||||
{ .key = NRF_ERROR_RESOURCES , .data = "NRF_ERROR_RESOURCES" },
|
||||
|
||||
// SDM
|
||||
{ .key = NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN , .data = "NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN" },
|
||||
{ .key = NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION , .data = "NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION" },
|
||||
{ .key = NRF_ERROR_SDM_INCORRECT_CLENR0 , .data = "NRF_ERROR_SDM_INCORRECT_CLENR0" },
|
||||
|
||||
// SOC
|
||||
{ .key = NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN , .data = "NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN" },
|
||||
{ .key = NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE , .data = "NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE" },
|
||||
{ .key = NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED , .data = "NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED" },
|
||||
{ .key = NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN , .data = "NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN" },
|
||||
{ .key = NRF_ERROR_SOC_POWER_MODE_UNKNOWN , .data = "NRF_ERROR_SOC_POWER_MODE_UNKNOWN" },
|
||||
{ .key = NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN , .data = "NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN" },
|
||||
{ .key = NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN , .data = "NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN" },
|
||||
{ .key = NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES , .data = "NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES" },
|
||||
{ .key = NRF_ERROR_SOC_PPI_INVALID_CHANNEL , .data = "NRF_ERROR_SOC_PPI_INVALID_CHANNEL" },
|
||||
{ .key = NRF_ERROR_SOC_PPI_INVALID_GROUP , .data = "NRF_ERROR_SOC_PPI_INVALID_GROUP" },
|
||||
|
||||
// BLE Generic
|
||||
{ .key = BLE_ERROR_NOT_ENABLED , .data = "BLE_ERROR_NOT_ENABLED" },
|
||||
{ .key = BLE_ERROR_INVALID_CONN_HANDLE , .data = "BLE_ERROR_INVALID_CONN_HANDLE" },
|
||||
{ .key = BLE_ERROR_INVALID_ATTR_HANDLE , .data = "BLE_ERROR_INVALID_ATTR_HANDLE" },
|
||||
{ .key = BLE_ERROR_INVALID_ROLE , .data = "BLE_ERROR_INVALID_ROLE" },
|
||||
|
||||
// BLE GAP
|
||||
{ .key = BLE_ERROR_GAP_UUID_LIST_MISMATCH , .data = "BLE_ERROR_GAP_UUID_LIST_MISMATCH" },
|
||||
{ .key = BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST , .data = "BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST" },
|
||||
{ .key = BLE_ERROR_GAP_INVALID_BLE_ADDR , .data = "BLE_ERROR_GAP_INVALID_BLE_ADDR" },
|
||||
{ .key = BLE_ERROR_GAP_WHITELIST_IN_USE , .data = "BLE_ERROR_GAP_WHITELIST_IN_USE" },
|
||||
#if SD_VER >= 500
|
||||
{ .key = BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE , .data = "BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE" },
|
||||
{ .key = BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE , .data = "BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE" },
|
||||
#endif
|
||||
|
||||
// BLE GATTC
|
||||
{ .key = BLE_ERROR_GATTC_PROC_NOT_PERMITTED , .data = "BLE_ERROR_GATTC_PROC_NOT_PERMITTED" },
|
||||
|
||||
// BLE GATTS
|
||||
{ .key = BLE_ERROR_GATTS_INVALID_ATTR_TYPE , .data = "BLE_ERROR_GATTS_INVALID_ATTR_TYPE" },
|
||||
{ .key = BLE_ERROR_GATTS_SYS_ATTR_MISSING , .data = "BLE_ERROR_GATTS_SYS_ATTR_MISSING" },
|
||||
};
|
||||
|
||||
lookup_table_t const _err_table =
|
||||
{
|
||||
.count = arrcount(_err_lookup_items),
|
||||
.items = _err_lookup_items
|
||||
};
|
||||
|
||||
const char* dbg_err_str(uint32_t err_id)
|
||||
{
|
||||
const char * str = (const char *) lookup_find(&_err_table, err_id);
|
||||
static char unknown_err[7] = {0};
|
||||
|
||||
if ( str == NULL )
|
||||
{
|
||||
sprintf(unknown_err, "0x%04X", err_id);
|
||||
str = unknown_err;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,7 +102,7 @@ AdafruitBluefruit::AdafruitBluefruit(void)
|
||||
* to increase throughput for most user
|
||||
*/
|
||||
/*------------------------------------------------------------------*/
|
||||
_sd_cfg.attr_table_size = 0xB00;
|
||||
_sd_cfg.attr_table_size = 0x800;
|
||||
_sd_cfg.mtu_max = BLEGATT_ATT_MTU_MAX;
|
||||
_sd_cfg.service_changed = 0;
|
||||
_sd_cfg.uuid128_max = BLE_UUID_VS_COUNT_DEFAULT;
|
||||
@@ -688,6 +688,10 @@ void adafruit_ble_task(void* arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
#if SD_VER >= 500
|
||||
uint8_t * ev_buf = (uint8_t*) rtos_malloc(BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX));
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
if ( xSemaphoreTake(Bluefruit._ble_event_sem, portMAX_DELAY) )
|
||||
@@ -697,13 +701,12 @@ void adafruit_ble_task(void* arg)
|
||||
// Until no pending events
|
||||
while( NRF_ERROR_NOT_FOUND != err )
|
||||
{
|
||||
#if SD_VER < 500
|
||||
#if SD_VER < 500
|
||||
__ALIGN(4) uint8_t ev_buf[ sizeof(ble_evt_t) + (BLE_GATT_ATT_MTU_DEFAULT) ];
|
||||
#else
|
||||
__ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ];
|
||||
#endif
|
||||
|
||||
uint16_t ev_len = sizeof(ev_buf);
|
||||
#else
|
||||
uint16_t ev_len = BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX);
|
||||
#endif
|
||||
|
||||
// Get BLE Event
|
||||
err = sd_ble_evt_get(ev_buf, &ev_len);
|
||||
|
||||
Reference in new issue
Block a user