I've added a HID service in my project.
I see a lot of messages
<00> debug> nrf_sdh_ble: BLE event: 0x57.
in the RTT Viewer.
What does the event 0x57 mean?
I've added a HID service in my project.
I see a lot of messages
<00> debug> nrf_sdh_ble: BLE event: 0x57.
in the RTT Viewer.
What does the event 0x57 mean?
See the file in the SDK :
nRF5_SDK_15.3.0_59ac345/components/softdevice/s132/headers/ble_gatts.h
I'm referencing the softdevice 132, but the others will be the same.
Search for enum BLE_GATTS_EVT. Line 89.
You will see that the first entry in the enum is BLE_GATTS_EVT_BASE. You can find that value in ble_ranges.h (same directory).
The value of BLE_GATTS_EVT_BASE is 0x50. Increment through the enum and you will find 0x57 is BLE_GATTS_EVT_HVN_TX_COMPLETE.
That event means that your indication or notification as been transmitted, and if I understand the softdevice correctly, the packets successfully received by the peer at the link layer.
Your data made it! Party time.
I highly recommend that you employ an editor with tagging capabilities and tag the softdevice and portions of the SDK you intend to use (or perhaps all of it).
Thank you!
Thank you!
This helps; I'm showing decimal instead of hex, but 0x57 = 87 decimal. I like to see all events without having to search for them, note the ones handled elsewhere in ble_gap_event() are simply commented out as they already have a trace message - start by uncommenting all then comment out the duplicates:.
// BLE_GAP_EVTS - GAP Event IDs - uniquely identify an event coming from the stack to the application // case BLE_GAP_EVT_ADV_REPORT: // case BLE_GAP_EVT_CONNECTED: // 16 Connected to peer // case BLE_GAP_EVT_DISCONNECTED: // 17 Disconnected from peer // case BLE_GAP_EVT_CONN_PARAM_UPDATE: // 18 Connection Parameters updated // case BLE_GAP_EVT_SEC_PARAMS_REQUEST: // 19 Request to provide security parameters case BLE_GAP_EVT_SEC_INFO_REQUEST: // 20 Request to provide security information case BLE_GAP_EVT_PASSKEY_DISPLAY: // 21 Request to display a passkey to the user case BLE_GAP_EVT_KEY_PRESSED: // 22 Notification of a keypress on the remote device case BLE_GAP_EVT_AUTH_KEY_REQUEST: // 23 Request to provide an authentication key case BLE_GAP_EVT_LESC_DHKEY_REQUEST: // 24 Request to calculate an LE Secure Connections DHKey case BLE_GAP_EVT_AUTH_STATUS: // 25 Authentication procedure completed with status case BLE_GAP_EVT_CONN_SEC_UPDATE: // 26 Connection security updated // case BLE_GAP_EVT_TIMEOUT: // 27 Timeout expired // case BLE_GAP_EVT_RSSI_CHANGED: // 28 RSSI report // case BLE_GAP_EVT_ADV_REPORT: // 29 Advertising report case BLE_GAP_EVT_SEC_REQUEST: // 30 Security Request // case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: // 31 Connection Parameter Update Request case BLE_GAP_EVT_SCAN_REQ_REPORT: // 32 Scan request report // case BLE_GAP_EVT_PHY_UPDATE_REQUEST: // 33 PHY Update Request // case BLE_GAP_EVT_PHY_UPDATE: // 34 PHY Update Procedure is complete case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: // 35 Data Length Update Request case BLE_GAP_EVT_DATA_LENGTH_UPDATE: // 36 LL Data Channel PDU payload length updated case BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT: // 37 Channel survey report case BLE_GAP_EVT_ADV_SET_TERMINATED: // 38 Advertising set terminated // BLE_GATTC_EVTS - GATT Client Event IDs case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: // 48 Primary Service Discovery Response event case BLE_GATTC_EVT_REL_DISC_RSP: // 49 Relationship Discovery Response event case BLE_GATTC_EVT_CHAR_DISC_RSP: // 50 Characteristic Discovery Response event case BLE_GATTC_EVT_DESC_DISC_RSP: // 51 Descriptor Discovery Response event case BLE_GATTC_EVT_ATTR_INFO_DISC_RSP: // 52 Attribute Information Response event case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP: // 53 Read By UUID Response event case BLE_GATTC_EVT_READ_RSP: // 54 Read Response event case BLE_GATTC_EVT_CHAR_VALS_READ_RSP: // 55 Read multiple Response event case BLE_GATTC_EVT_WRITE_RSP: // 56 Write Response event case BLE_GATTC_EVT_HVX: // 57 Handle Value Notification or Indication event case BLE_GATTC_EVT_EXCHANGE_MTU_RSP: // 58 Exchange MTU Response event // case BLE_GATTC_EVT_TIMEOUT: // 59 Timeout event case BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE: // 60 Write without Response transmission complete // BLE_GATTS_EVTS - GATT Server Event IDs. case BLE_GATTS_EVT_WRITE: // 80 Write operation performed case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: // 81 Read/Write Authorization request case BLE_GATTS_EVT_SYS_ATTR_MISSING: // 82 A persistent system attribute access is pending case BLE_GATTS_EVT_HVC: // 83 Handle Value Confirmation case BLE_GATTS_EVT_SC_CONFIRM: // 84 Service Changed Confirmation case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: // 85 Exchange MTU Request // case BLE_GATTS_EVT_TIMEOUT: // 86 Peer failed to respond to an ATT request in time case BLE_GATTS_EVT_HVN_TX_COMPLETE: // 87 Handle Value Notification transmission complete if (p_ble_evt->header.evt_id < NUM_BLE_EVENTS) { NRF_LOG_INFO("p_ble_evt: %d %s",p_ble_evt->header.evt_id, ble_evt_description[p_ble_evt->header.evt_id]); } else { NRF_LOG_INFO("Unhandled p_ble_evt->header.evt_id: %d",p_ble_evt->header.evt_id); } break;
This is the text description array, verbose but helpful:
// BLE_GAP_EVTS - GAP Event IDs - uniquely identify an event coming from the stack to the application static char * ble_evt_description[] = { /* */ " 0 ?", /* */ " 1 ?", /* */ " 2 ?", /* */ " 3 ?", /* */ " 4 ?", /* */ " 5 ?", /* */ " 6 ?", /* */ " 7 ?", /* */ " 8 ?", /* */ " 9 ?", /* */ "10 ?", /* */ "11 ?", /* */ "12 ?", /* */ "13 ?", /* */ "14 ?", /* */ "15 ?", /* BLE_GAP_EVT_ADV_REPORT: */ /* BLE_GAP_EVT_CONNECTED: */ "16 Connected to peer", /* BLE_GAP_EVT_DISCONNECTED: */ "17 Disconnected from peer", /* BLE_GAP_EVT_CONN_PARAM_UPDATE: */ "18 Connection Parameters updated", /* BLE_GAP_EVT_SEC_PARAMS_REQUEST: */ "19 Request to provide security parameters", /* BLE_GAP_EVT_SEC_INFO_REQUEST: */ "20 Request to provide security information", /* BLE_GAP_EVT_PASSKEY_DISPLAY: */ "21 Request to display a passkey to the user", /* BLE_GAP_EVT_KEY_PRESSED: */ "22 Notification of a keypress on the remote device", /* BLE_GAP_EVT_AUTH_KEY_REQUEST: */ "23 Request to provide an authentication key", /* BLE_GAP_EVT_LESC_DHKEY_REQUEST: */ "24 Request to calculate an LE Secure Connections DHKey", /* BLE_GAP_EVT_AUTH_STATUS: */ "25 Authentication procedure completed with status", /* BLE_GAP_EVT_CONN_SEC_UPDATE: */ "26 Connection security updated", /* BLE_GAP_EVT_TIMEOUT: */ "27 Timeout expired", /* BLE_GAP_EVT_RSSI_CHANGED: */ "28 RSSI report", /* BLE_GAP_EVT_ADV_REPORT: */ "29 Advertising report", /* BLE_GAP_EVT_SEC_REQUEST: */ "30 Security Request", /* BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: */ "31 Connection Parameter Update Request", /* BLE_GAP_EVT_SCAN_REQ_REPORT: */ "32 Scan request report", /* BLE_GAP_EVT_PHY_UPDATE_REQUEST: */ "33 PHY Update Request", /* BLE_GAP_EVT_PHY_UPDATE: */ "34 PHY Update Procedure is complete", /* BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: */ "35 Data Length Update Request", /* BLE_GAP_EVT_DATA_LENGTH_UPDATE: */ "36 LL Data Channel PDU payload length updated", /* BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT: */ "37 Channel survey report", /* BLE_GAP_EVT_ADV_SET_TERMINATED: */ "38 Advertising set terminated", /* */ "39 ?", /* */ "40 ?", /* */ "41 ?", /* */ "42 ?", /* */ "43 ?", /* */ "44 ?", /* */ "45 ?", /* */ "46 ?", /* */ "47 ?", /*LE_GATTC_EVTS - GATT Client Event IDs */ /* BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: */ "48 Primary Service Discovery Response event", /* BLE_GATTC_EVT_REL_DISC_RSP: */ "49 Relationship Discovery Response event", /* BLE_GATTC_EVT_CHAR_DISC_RSP: */ "50 Characteristic Discovery Response event", /* BLE_GATTC_EVT_DESC_DISC_RSP: */ "51 Descriptor Discovery Response event", /* BLE_GATTC_EVT_ATTR_INFO_DISC_RSP: */ "52 Attribute Information Response event", /* BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP: */ "53 Read By UUID Response event", /* BLE_GATTC_EVT_READ_RSP: */ "54 Read Response event", /* BLE_GATTC_EVT_CHAR_VALS_READ_RSP: */ "55 Read multiple Response event", /* BLE_GATTC_EVT_WRITE_RSP: */ "56 Write Response event", /* BLE_GATTC_EVT_HVX: */ "57 Handle Value Notification or Indication event", /* BLE_GATTC_EVT_EXCHANGE_MTU_RSP: */ "58 Exchange MTU Response event", /* BLE_GATTC_EVT_TIMEOUT: */ "59 Timeout event", /* BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE: */ "60 Write without Response transmission complete", /* */ "61 ?", /* */ "62 ?", /* */ "63 ?", /* */ "64 ?", /* */ "65 ?", /* */ "66 ?", /* */ "67 ?", /* */ "68 ?", /* */ "69 ?", /* */ "70 ?", /* */ "71 ?", /* */ "72 ?", /* */ "73 ?", /* */ "74 ?", /* */ "75 ?", /* */ "76 ?", /* */ "77 ?", /* */ "78 ?", /* */ "79 ?", /*LE_GATTS_EVTS - GATT Server Event IDs. */ /* BLE_GATTS_EVT_WRITE: */ "80 Write operation performed", /* BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: */ "81 Read/Write Authorization request", /* BLE_GATTS_EVT_SYS_ATTR_MISSING: */ "82 A persistent system attribute access is pending", /* BLE_GATTS_EVT_HVC: */ "83 Handle Value Confirmation", /* BLE_GATTS_EVT_SC_CONFIRM: */ "84 Service Changed Confirmation", /* BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: */ "85 Exchange MTU Request", /* BLE_GATTS_EVT_TIMEOUT: */ "86 Peer failed to respond to an ATT request in time", /* BLE_GATTS_EVT_HVN_TX_COMPLETE: */ "87 Handle Value Notification transmission complete", }; #define NUM_BLE_EVENTS (sizeof(ble_evt_description)/sizeof(ble_evt_description[0]))
And a few safety checks:
STATIC_ASSERT(BLE_GAP_EVT_CONNECTED == 0x10, "Enum Check Fails - BLE_GAP_EVTS"); STATIC_ASSERT(BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP == 0x30, "Enum Check Fails - BLE_GATTC_EVTS"); STATIC_ASSERT(BLE_GATTS_EVT_WRITE == 0x50, "Enum Check Fails - BLE_GATTS_EVTS"); STATIC_ASSERT(BLE_GAP_EVT_ADV_SET_TERMINATED == 38, "Enum Check Fails - BLE_GAP_EVTS"); STATIC_ASSERT(BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE == 60, "Enum Check Fails - BLE_GATTC_EVTS"); STATIC_ASSERT(BLE_GATTS_EVT_HVN_TX_COMPLETE == 87, "Enum Check Fails - BLE_GATTS_EVTS");
It is very helpful, thanks!