From 1c4e967872c1bc3ac067deda8ed6fdeb57dfbc7f Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Thu, 18 Jun 2020 22:38:44 +0200 Subject: [PATCH] feat(ble): Add pretty event printing --- epicardium/ble/ble_main.c | 117 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/epicardium/ble/ble_main.c b/epicardium/ble/ble_main.c index 678ca5016..7344683b6 100644 --- a/epicardium/ble/ble_main.c +++ b/epicardium/ble/ble_main.c @@ -21,6 +21,7 @@ #include "wsf_msg.h" #include "wsf_trace.h" #include "hci_api.h" +#include "l2c_api.h" #include "dm_api.h" #include "att_api.h" #include "smp_api.h" @@ -202,6 +203,109 @@ static dmConnId_t pair_connId = DM_CONN_ID_NONE; static uint32_t pair_confirm_value; static void BleHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); + +static const char * const att_events[] = { + "ATTC_FIND_INFO_RSP", + "ATTC_FIND_BY_TYPE_VALUE_RSP", + "ATTC_READ_BY_TYPE_RSP", + "ATTC_READ_RSP", + "ATTC_READ_LONG_RSP", + "ATTC_READ_MULTIPLE_RSP", + "ATTC_READ_BY_GROUP_TYPE_RSP", + "ATTC_WRITE_RSP", + "ATTC_WRITE_CMD_RSP", + "ATTC_PREPARE_WRITE_RSP", + "ATTC_EXECUTE_WRITE_RSP", + "ATTC_HANDLE_VALUE_NTF", + "ATTC_HANDLE_VALUE_IND", + /* ATT server callback events */ + "ATTS_HANDLE_VALUE_CNF", + "ATTS_CCC_STATE_IND", + "ATTS_DB_HASH_CALC_CMPL_IND", + /* ATT common callback events */ + "ATT_MTU_UPDATE_IND" +}; + +static const char * const dm_events[] = { + "DM_RESET_CMPL_IND", + "DM_ADV_START_IND", + "DM_ADV_STOP_IND", + "DM_ADV_NEW_ADDR_IND", + "DM_SCAN_START_IND", + "DM_SCAN_STOP_IND", + "DM_SCAN_REPORT_IND", + "DM_CONN_OPEN_IND", + "DM_CONN_CLOSE_IND", + "DM_CONN_UPDATE_IND", + "DM_SEC_PAIR_CMPL_IND", + "DM_SEC_PAIR_FAIL_IND", + "DM_SEC_ENCRYPT_IND", + "DM_SEC_ENCRYPT_FAIL_IND", + "DM_SEC_AUTH_REQ_IND", + "DM_SEC_KEY_IND", + "DM_SEC_LTK_REQ_IND", + "DM_SEC_PAIR_IND", + "DM_SEC_SLAVE_REQ_IND", + "DM_SEC_CALC_OOB_IND", + "DM_SEC_ECC_KEY_IND", + "DM_SEC_COMPARE_IND", + "DM_SEC_KEYPRESS_IND", + "DM_PRIV_RESOLVED_ADDR_IND", + "DM_PRIV_GENERATE_ADDR_IND", + "DM_CONN_READ_RSSI_IND", + "DM_PRIV_ADD_DEV_TO_RES_LIST_IND", + "DM_PRIV_REM_DEV_FROM_RES_LIST_IND", + "DM_PRIV_CLEAR_RES_LIST_IND", + "DM_PRIV_READ_PEER_RES_ADDR_IND", + "DM_PRIV_READ_LOCAL_RES_ADDR_IND", + "DM_PRIV_SET_ADDR_RES_ENABLE_IND", + "DM_REM_CONN_PARAM_REQ_IND", + "DM_CONN_DATA_LEN_CHANGE_IND", + "DM_CONN_WRITE_AUTH_TO_IND", + "DM_CONN_AUTH_TO_EXPIRED_IND", + "DM_PHY_READ_IND", + "DM_PHY_SET_DEF_IND", + "DM_PHY_UPDATE_IND", + "DM_ADV_SET_START_IND", + "DM_ADV_SET_STOP_IND", + "DM_SCAN_REQ_RCVD_IND", + "DM_EXT_SCAN_START_IND", + "DM_EXT_SCAN_STOP_IND", + "DM_EXT_SCAN_REPORT_IND", + "DM_PER_ADV_SET_START_IND", + "DM_PER_ADV_SET_STOP_IND", + "DM_PER_ADV_SYNC_EST_IND", + "DM_PER_ADV_SYNC_EST_FAIL_IND", + "DM_PER_ADV_SYNC_LOST_IND", + "DM_PER_ADV_SYNC_TRSF_EST_IND", + "DM_PER_ADV_SYNC_TRSF_EST_FAIL_IND", + "DM_PER_ADV_SYNC_TRSF_IND", + "DM_PER_ADV_SET_INFO_TRSF_IND", + "DM_PER_ADV_REPORT_IND", + "DM_REMOTE_FEATURES_IND", + "DM_READ_REMOTE_VER_INFO_IND", + "DM_CONN_IQ_REPORT_IND", + "DM_CTE_REQ_FAIL_IND", + "DM_CONN_CTE_RX_SAMPLE_START_IND", + "DM_CONN_CTE_RX_SAMPLE_STOP_IND", + "DM_CONN_CTE_TX_CFG_IND", + "DM_CONN_CTE_REQ_START_IND", + "DM_CONN_CTE_REQ_STOP_IND", + "DM_CONN_CTE_RSP_START_IND", + "DM_CONN_CTE_RSP_STOP_IND", + "DM_READ_ANTENNA_INFO_IND", + "DM_L2C_CMD_REJ_IND", + "DM_ERROR_IND", + "DM_HW_ERROR_IND", + "DM_VENDOR_SPEC_IND" +}; + +static const char * const l2c_coc_events[] = { + "L2C_COC_CONNECT_IND", + "L2C_COC_DISCONNECT_IND", + "L2C_COC_DATA_IND", + "L2C_COC_DATA_CNF" +}; /*************************************************************************************************/ /*! * \brief Application DM callback. @@ -656,12 +760,25 @@ static void BleHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) if (pMsg->event >= DM_CBACK_START && pMsg->event <= DM_CBACK_END) { + LOG_INFO("ble", "Ble got evt %d: %s", pMsg->event, dm_events[pMsg->event - DM_CBACK_START]); /* process advertising and connection-related messages */ AppSlaveProcDmMsg((dmEvt_t *) pMsg); /* process security-related messages */ AppSlaveSecProcDmMsg((dmEvt_t *) pMsg); } + else if (pMsg->event >= ATT_CBACK_START && pMsg->event <= ATT_CBACK_END) + { + LOG_INFO("ble", "Ble got evt %d: %s", pMsg->event, att_events[pMsg->event - ATT_CBACK_START]); + } + else if (pMsg->event >= L2C_COC_CBACK_START && pMsg->event <= L2C_COC_CBACK_CBACK_END) + { + LOG_INFO("ble", "Ble got evt %d: %s", pMsg->event, l2c_coc_events[pMsg->event - L2C_COC_CBACK_START]); + } + else + { + LOG_INFO("ble", "Ble got evt %d", pMsg->event); + } /* perform profile and user interface-related operations */ bleProcMsg((bleMsg_t *) pMsg); -- GitLab