diff --git a/nucleo-wb55-ble/Middlewares/ST/STM32_WPAN/ble/svc/Src/p2p_stm.c b/nucleo-wb55-ble/Middlewares/ST/STM32_WPAN/ble/svc/Src/p2p_stm.c index e60a1e6..1b44b55 100644 --- a/nucleo-wb55-ble/Middlewares/ST/STM32_WPAN/ble/svc/Src/p2p_stm.c +++ b/nucleo-wb55-ble/Middlewares/ST/STM32_WPAN/ble/svc/Src/p2p_stm.c @@ -20,7 +20,7 @@ /* Includes ------------------------------------------------------------------*/ #include "common_blesvc.h" - +#include "commands.h" /* Private typedef -----------------------------------------------------------*/ typedef struct{ uint16_t PeerToPeerSvcHdle; /**< Service handle */ @@ -118,11 +118,14 @@ static SVCCTL_EvtAckStatus_t PeerToPeer_Event_Handler(void *Event) { case HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE: { + log_debug("PeerToPeer_Event_Handler", "HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE", 0); blecore_evt = (evt_blecore_aci*)event_pckt->data; switch(blecore_evt->ecode) { case ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE: { + log_debug("PeerToPeer_Event_Handler", "blecore_evt->ecode=ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE", 0); + log_debug("PeerToPeer_Event_Handler", "aPeerToPeerContext.P2PNotifyServerToClientCharHdle=0x%x", 1, aPeerToPeerContext.P2PNotifyServerToClientCharHdle); attribute_modified = (aci_gatt_attribute_modified_event_rp0*)blecore_evt->data; if(attribute_modified->Attr_Handle == (aPeerToPeerContext.P2PNotifyServerToClientCharHdle + 2)) { diff --git a/nucleo-wb55-dongle-ble/STM32_WPAN/App/app_ble.c b/nucleo-wb55-dongle-ble/STM32_WPAN/App/app_ble.c index 74410c2..c99d6de 100644 --- a/nucleo-wb55-dongle-ble/STM32_WPAN/App/app_ble.c +++ b/nucleo-wb55-dongle-ble/STM32_WPAN/App/app_ble.c @@ -323,7 +323,8 @@ void APP_BLE_Init( void ) /*Radio mask Activity*/ #if (OOB_DEMO != 0) - aci_hal_set_radio_activity_mask(0x0020); + aci_hal_set_radio_activity_mask(0x0020); // connection event master + log_debug("APP_BLE_Init", "aci_hal_set_radio_activity_mask=0x0020 (connection event master)", 0); #endif /** * Initialize P2P Client Application @@ -339,6 +340,7 @@ void APP_BLE_Init( void ) * Start scanning */ UTIL_SEQ_SetTask(1 << CFG_TASK_START_SCAN_ID, CFG_SCH_PRIO_0); + log_debug("APP_BLE_Init", "trigger scanning task", 0); #endif /* USER CODE BEGIN APP_BLE_Init_2 */ log_debug("APP_BLE_Init", "done", 0); @@ -391,12 +393,12 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) { /* USER CODE BEGIN GAP_GENERAL_DISCOVERY_PROC */ - log_debug("SVCCTL_App_Notification", "-- GAP GENERAL DISCOVERY PROCEDURE_COMPLETED", 0); /* USER CODE END GAP_GENERAL_DISCOVERY_PROC */ - APP_DBG_MSG("-- GAP GENERAL DISCOVERY PROCEDURE_COMPLETED\n"); + log_debug("SVCCTL_App_Notification", "-- GAP GENERAL DISCOVERY PROCEDURE_COMPLETED", 0); /*if a device found, connect to it, device 1 being chosen first if both found*/ if (BleApplicationContext.DeviceServerFound == 0x01 && BleApplicationContext.Device_Connection_Status != APP_BLE_CONNECTED_CLIENT) { + log_debug("SVCCTL_App_Notification", "Set task: CFG_TASK_CONN_DEV_1_ID", 0); UTIL_SEQ_SetTask(1 << CFG_TASK_CONN_DEV_1_ID, CFG_SCH_PRIO_0); } } @@ -407,6 +409,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) { /* USER CODE BEGIN EVT_BLUE_L2CAP_CONNECTION_UPDATE_REQ */ + log_debug("SVCCTL_App_Notification", "Event: ACI_L2CAP_CONNECTION_UPDATE_REQ_VSEVT_CODE", 0); /* USER CODE END EVT_BLUE_L2CAP_CONNECTION_UPDATE_REQ */ aci_l2cap_connection_update_req_event_rp0 *pr = (aci_l2cap_connection_update_req_event_rp0 *) blecore_evt->data; aci_hal_set_radio_activity_mask(0x0000); @@ -504,7 +507,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) BleApplicationContext.Device_Connection_Status = APP_BLE_CONNECTED_CLIENT; /* CONNECTION WITH CLIENT */ - APP_DBG_MSG("\r\n\r** CONNECTION EVENT WITH SERVER \n"); + log_debug("SVCCTL_App_Notification", "** CONNECTION EVENT WITH SERVER", 0); handleNotification.P2P_Evt_Opcode = PEER_CONN_HANDLE_EVT; handleNotification.ConnectionHandle = BleApplicationContext.BleApplicationContext_legacy.connectionHandle; P2PC_APP_Notification(&handleNotification); @@ -512,12 +515,12 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) result = aci_gatt_disc_all_primary_services(BleApplicationContext.BleApplicationContext_legacy.connectionHandle); if (result == BLE_STATUS_SUCCESS) { - APP_DBG_MSG("\r\n\r** GATT SERVICES & CHARACTERISTICS DISCOVERY \n"); - APP_DBG_MSG("* GATT : Start Searching Primary Services \r\n\r"); + log_debug("SVCCTL_App_Notification", "** GATT SERVICES & CHARACTERISTICS DISCOVERY", 0); + log_debug("SVCCTL_App_Notification", "* GATT : Start Searching Primary Services", 0); } else { - APP_DBG_MSG("BLE_CTRL_App_Notification(), All services discovery Failed \r\n\r"); + log_error("SVCCTL_App_Notification", "All services discovery Failed", 0); } break; /* HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE */ @@ -672,17 +675,20 @@ void APP_BLE_Key_Button1_Action(void) *************************************************************/ static void Ble_Tl_Init( void ) { + log_debug("Ble_Tl_Init", "start", 0); HCI_TL_HciInitConf_t Hci_Tl_Init_Conf; Hci_Tl_Init_Conf.p_cmdbuffer = (uint8_t*)&BleCmdBuffer; Hci_Tl_Init_Conf.StatusNotCallBack = BLE_StatusNot; hci_init(BLE_UserEvtRx, (void*) &Hci_Tl_Init_Conf); + log_debug("Ble_Tl_Init", "end", 0); return; } - static void Ble_Hci_Gap_Gatt_Init(void){ +static void Ble_Hci_Gap_Gatt_Init(void){ + log_debug("Ble_Hci_Gap_Gatt_Init", "start", 0); uint8_t role; uint16_t gap_service_handle, gap_dev_name_char_handle, gap_appearance_char_handle; const uint8_t *bd_addr; @@ -751,6 +757,7 @@ static void Ble_Tl_Init( void ) { const char *name = "Monsun1"; + log_debug("Ble_Hci_Gap_Gatt_Init", "aci_gap_init()", 0); aci_gap_init(role, 0, APPBLE_GAP_DEVICE_NAME_LENGTH, &gap_service_handle, &gap_dev_name_char_handle, &gap_appearance_char_handle); @@ -761,14 +768,15 @@ static void Ble_Tl_Init( void ) } } - if(aci_gatt_update_char_value(gap_service_handle, - gap_appearance_char_handle, - 0, - 2, - (uint8_t *)&appearance)) - { - BLE_DBG_SVCCTL_MSG("Appearance aci_gatt_update_char_value failed.\n"); - } + log_debug("Ble_Hci_Gap_Gatt_Init", "aci_gatt_update_char_value()", 0); + if(aci_gatt_update_char_value(gap_service_handle, + gap_appearance_char_handle, + 0, + 2, + (uint8_t *)&appearance)) + { + BLE_DBG_SVCCTL_MSG("Appearance aci_gatt_update_char_value failed.\n"); + } /** * Initialize IO capability @@ -786,6 +794,7 @@ static void Ble_Tl_Init( void ) BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.Fixed_Pin = CFG_FIXED_PIN; BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.bonding_mode = CFG_BONDING_MODE; + log_debug("Ble_Hci_Gap_Gatt_Init", "aci_gap_set_authentication_requirement()", 0); aci_gap_set_authentication_requirement(BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.bonding_mode, BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.mitm_mode, CFG_SC_SUPPORT, @@ -802,16 +811,18 @@ static void Ble_Tl_Init( void ) */ if (BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.bonding_mode) { + log_debug("Ble_Hci_Gap_Gatt_Init", "aci_gap_configure_whitelist()", 0); aci_gap_configure_whitelist(); } + log_debug("Ble_Hci_Gap_Gatt_Init", "end", 0); } static void Scan_Request( void ) { /* USER CODE BEGIN Scan_Request_1 */ - log_debug("Scan_Request", "enter", 0); + log_debug("Scan_Request", "start", 0); /* USER CODE END Scan_Request_1 */ tBleStatus result; if (BleApplicationContext.Device_Connection_Status != APP_BLE_CONNECTED_CLIENT) @@ -819,22 +830,21 @@ static void Scan_Request( void ) /* USER CODE BEGIN APP_BLE_CONNECTED_CLIENT */ /* USER CODE END APP_BLE_CONNECTED_CLIENT */ + log_debug("Scan_Request", "aci_gap_start_general_discovery_proc()", 0); result = aci_gap_start_general_discovery_proc(SCAN_P, SCAN_L, PUBLIC_ADDR, 1); if (result == BLE_STATUS_SUCCESS) { /* USER CODE BEGIN BLE_SCAN_SUCCESS */ - log_debug("Scan_Request", "START GENERAL DISCOVERY (SCAN)", 0); /* USER CODE END BLE_SCAN_SUCCESS */ - APP_DBG_MSG(" \r\n\r** START GENERAL DISCOVERY (SCAN) ** \r\n\r"); + log_debug("Scan_Request", "** START GENERAL DISCOVERY (SCAN) **", 0); } else { /* USER CODE BEGIN BLE_SCAN_FAILED */ - log_debug("Scan_Request", "BLE_App_Start_Limited_Disc_Req, Failed", 0); /* USER CODE END BLE_SCAN_FAILED */ - APP_DBG_MSG("-- BLE_App_Start_Limited_Disc_Req, Failed \r\n\r"); + log_debug("Scan_Request", "-- BLE_App_Start_Limited_Disc_Req, Failed ", 0); } } /* USER CODE BEGIN Scan_Request_2 */ @@ -847,14 +857,15 @@ static void Connect_Request( void ) { /* USER CODE BEGIN Connect_Request_1 */ - log_debug("Scan_Request", "enter", 0); + log_debug("Connect_Request", "start", 0); /* USER CODE END Connect_Request_1 */ tBleStatus result; - APP_DBG_MSG("\r\n\r** CREATE CONNECTION TO SERVER ** \r\n\r"); + log_debug("Connect_Request", "** CREATE CONNECTION TO SERVER **", 0); if (BleApplicationContext.Device_Connection_Status != APP_BLE_CONNECTED_CLIENT) { + log_debug("Connect_Request", "aci_gap_create_connection()", 0); result = aci_gap_create_connection(SCAN_P, SCAN_L, PUBLIC_ADDR, SERVER_REMOTE_BDADDR, @@ -871,6 +882,7 @@ static void Connect_Request( void ) /* USER CODE BEGIN BLE_CONNECT_SUCCESS */ /* USER CODE END BLE_CONNECT_SUCCESS */ + log_debug("Device_Connection_Status", "APP_BLE_LP_CONNECTING", 0); BleApplicationContext.Device_Connection_Status = APP_BLE_LP_CONNECTING; } @@ -879,6 +891,8 @@ static void Connect_Request( void ) /* USER CODE BEGIN BLE_CONNECT_FAILED */ /* USER CODE END BLE_CONNECT_FAILED */ + log_error("Connect_Request", "Connection failed", 0); + log_debug("Device_Connection_Status", "APP_BLE_IDLE", 0); BleApplicationContext.Device_Connection_Status = APP_BLE_IDLE; } @@ -892,11 +906,13 @@ static void Connect_Request( void ) static void Switch_OFF_GPIO(){ /* USER CODE BEGIN Switch_OFF_GPIO */ + log_debug("Switch_OFF_GPIO", "start/end", 0); /* USER CODE END Switch_OFF_GPIO */ } const uint8_t* BleGetBdAddress( void ) { + log_debug("BleGetBdAddress", "start", 0); uint8_t *otp_addr; const uint8_t *bd_addr; uint32_t udn; @@ -940,6 +956,7 @@ const uint8_t* BleGetBdAddress( void ) } } + log_debug("BleGetBdAddress", "end", 0); return bd_addr; } /* USER CODE BEGIN FD_LOCAL_FUNCTIONS */ @@ -970,6 +987,7 @@ void hci_cmd_resp_wait(uint32_t timeout) static void BLE_UserEvtRx( void * pPayload ) { + // log_debug("BLE_UserEvtRx", "start", 0); SVCCTL_UserEvtFlowStatus_t svctl_return_status; tHCI_UserEvtRxParam *pParam; @@ -984,10 +1002,12 @@ static void BLE_UserEvtRx( void * pPayload ) { pParam->status = HCI_TL_UserEventFlow_Disable; } + // log_debug("BLE_UserEvtRx", "end", 0); } static void BLE_StatusNot( HCI_TL_CmdStatus_t status ) { + // log_debug("BLE_StatusNot", "start", 0); uint32_t task_id_list; switch (status) { @@ -1014,6 +1034,7 @@ static void BLE_StatusNot( HCI_TL_CmdStatus_t status ) default: break; } + // log_debug("BLE_StatusNot", "end", 0); return; } diff --git a/nucleo-wb55-dongle-ble/STM32_WPAN/App/p2p_client_app.c b/nucleo-wb55-dongle-ble/STM32_WPAN/App/p2p_client_app.c index 035f436..c7bef4a 100644 --- a/nucleo-wb55-dongle-ble/STM32_WPAN/App/p2p_client_app.c +++ b/nucleo-wb55-dongle-ble/STM32_WPAN/App/p2p_client_app.c @@ -20,6 +20,7 @@ /* Includes ------------------------------------------------------------------*/ +#include #include "main.h" #include "app_common.h" @@ -176,7 +177,7 @@ void P2PC_APP_Init(void) { uint8_t index =0; /* USER CODE BEGIN P2PC_APP_Init_1 */ - log_debug("P2PC_APP_Init", "enter", 0); + log_debug("P2PC_APP_Init", "start", 0); UTIL_SEQ_RegTask( 1<< CFG_TASK_SEARCH_SERVICE_ID, UTIL_SEQ_RFU, Update_Service ); UTIL_SEQ_RegTask( 1<< CFG_TASK_SW1_BUTTON_PUSHED_ID, UTIL_SEQ_RFU, Button_Trigger_Received ); @@ -190,6 +191,7 @@ void P2PC_APP_Init(void) P2P_Client_App_Context.LedControl.Led1=0x00; /* led OFF */ P2P_Client_App_Context.ButtonStatus.Device_Button_Selection=0x01;/* Device1 */ P2P_Client_App_Context.ButtonStatus.Button1=0x00; + log_debug("P2PC_APP_Init", "BLE_CFG_CLT_MAX_NBR_CB=%d", 1, BLE_CFG_CLT_MAX_NBR_CB); /* USER CODE END P2PC_APP_Init_1 */ for(index = 0; index < BLE_CFG_CLT_MAX_NBR_CB; index++) { @@ -207,6 +209,7 @@ void P2PC_APP_Init(void) /* USER CODE BEGIN P2PC_APP_Init_2 */ + log_debug("P2PC_APP_Init", "end", 0); /* USER CODE END P2PC_APP_Init_2 */ return; } @@ -214,7 +217,7 @@ void P2PC_APP_Init(void) void P2PC_APP_Notification(P2PC_APP_ConnHandle_Not_evt_t *pNotification) { /* USER CODE BEGIN P2PC_APP_Notification_1 */ - log_debug("P2PC_APP_Notification", "enter", 0); + log_debug("P2PC_APP_Notification", "start", 0); /* USER CODE END P2PC_APP_Notification_1 */ switch(pNotification->P2P_Evt_Opcode) { @@ -224,13 +227,15 @@ void P2PC_APP_Notification(P2PC_APP_ConnHandle_Not_evt_t *pNotification) case PEER_CONN_HANDLE_EVT : /* USER CODE BEGIN PEER_CONN_HANDLE_EVT */ + log_debug("P2PC_APP_Notification", "PEER_CONN_HANDLE_EVT", 0); P2P_Client_App_Context.ConnectionHandle = pNotification->ConnectionHandle; /* USER CODE END PEER_CONN_HANDLE_EVT */ - break; + break; case PEER_DISCON_HANDLE_EVT : /* USER CODE BEGIN PEER_DISCON_HANDLE_EVT */ { + log_debug("P2PC_APP_Notification", "PEER_DISCON_HANDLE_EVT", 0); uint8_t index = 0; P2P_Client_App_Context.ConnectionHandle = 0x00; while((index < BLE_CFG_CLT_MAX_NBR_CB) && @@ -261,6 +266,7 @@ void P2PC_APP_Notification(P2PC_APP_ConnHandle_Not_evt_t *pNotification) /* USER CODE BEGIN FD */ void P2PC_APP_SW1_Button_Action(void) { + log_debug("P2PC_APP_SW1_Button_Action", "set task: BLE_CFG_CLT_MAX_NBR_CB", 0); UTIL_SEQ_SetTask(1<data; switch(blecore_evt->ecode) { case ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE: { + log_debug("Event_Handler", "blecore_evt->ecode=ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE", 0); aci_att_read_by_group_type_resp_event_rp0 *pr = (void*)blecore_evt->data; uint8_t numServ, i, idx; uint16_t uuid, handle; @@ -315,7 +323,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) if((aP2PClientContext[index].state == APP_BLE_CONNECTED_CLIENT)&& (status == APP_BLE_IDLE)) { - /* Handle deconnected */ + /* Handle disconnected */ aP2PClientContext[index].state = APP_BLE_IDLE; aP2PClientContext[index].connHandle = 0xFFFF; @@ -351,16 +359,23 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) uuid = UNPACK_2_BYTE_PARAMETER(&pr->Attribute_Data_List[idx]); if(uuid == P2P_SERVICE_UUID) { + log_debug("Event_Handler", "uuid=0x%x", 1, uuid); + log_debug("Event_Handler", "-- GATT : P2P_SERVICE_UUID FOUND - connection handle=0x%x", 1, aP2PClientContext[index].connHandle); #if(CFG_DEBUG_APP_TRACE != 0) APP_DBG_MSG("-- GATT : P2P_SERVICE_UUID FOUND - connection handle 0x%x \n", aP2PClientContext[index].connHandle); #endif #if (UUID_128BIT_FORMAT==1) + /* + | 2 byte | 2 byte | 14 byte | 2 byte | + | p2p service handle | p2p service end handle | ???? | uuid | + */ aP2PClientContext[index].P2PServiceHandle = UNPACK_2_BYTE_PARAMETER(&pr->Attribute_Data_List[idx-16]); aP2PClientContext[index].P2PServiceEndHandle = UNPACK_2_BYTE_PARAMETER (&pr->Attribute_Data_List[idx-14]); #else aP2PClientContext[index].P2PServiceHandle = UNPACK_2_BYTE_PARAMETER(&pr->Attribute_Data_List[idx-4]); aP2PClientContext[index].P2PServiceEndHandle = UNPACK_2_BYTE_PARAMETER (&pr->Attribute_Data_List[idx-2]); #endif + log_debug("Event_Handler", "aP2PClientContext.state=APP_BLE_DISCOVER_CHARACS", 0); aP2PClientContext[index].state = APP_BLE_DISCOVER_CHARACS ; } idx += 6; @@ -373,6 +388,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) case ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE: { + log_debug("Event_Handler", "blecore_evt->ecode=ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE", 0); aci_att_read_by_type_resp_event_rp0 *pr = (void*)blecore_evt->data; uint8_t idx; uint16_t uuid, handle; @@ -406,6 +422,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) pr->Data_Length -= 1; while(pr->Data_Length > 0) { + log_debug("Event_Handler", "uuid=0x%x", 1, uuid); uuid = UNPACK_2_BYTE_PARAMETER(&pr->Handle_Value_Pair_Data[idx]); /* store the characteristic handle not the attribute handle */ #if (UUID_128BIT_FORMAT==1) @@ -415,6 +432,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) #endif if(uuid == P2P_WRITE_CHAR_UUID) { + log_debug("Event_Handler", "-- GATT : WRITE_UUID FOUND - connection handle=0x%x", 1, aP2PClientContext[index].connHandle); #if(CFG_DEBUG_APP_TRACE != 0) APP_DBG_MSG("-- GATT : WRITE_UUID FOUND - connection handle 0x%x\n", aP2PClientContext[index].connHandle); #endif @@ -424,6 +442,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) else if(uuid == P2P_NOTIFY_CHAR_UUID) { + log_debug("Event_Handler", "-- GATT : NOTIFICATION_CHAR_UUID FOUND - connection handle=0x%x", 1, aP2PClientContext[index].connHandle); #if(CFG_DEBUG_APP_TRACE != 0) APP_DBG_MSG("-- GATT : NOTIFICATION_CHAR_UUID FOUND - connection handle 0x%x\n", aP2PClientContext[index].connHandle); #endif @@ -445,6 +464,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) case ACI_ATT_FIND_INFO_RESP_VSEVT_CODE: { + log_debug("Event_Handler", "blecore_evt->ecode=ACI_ATT_FIND_INFO_RESP_VSEVT_CODE", 0); aci_att_find_info_resp_event_rp0 *pr = (void*)blecore_evt->data; uint8_t numDesc, idx, i; @@ -479,6 +499,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) if(uuid == CLIENT_CHAR_CONFIG_DESCRIPTOR_UUID) { + log_debug("Event_Handler", "-- GATT : CLIENT_CHAR_CONFIG_DESCRIPTOR_UUID FOUND - connection handle=0x%x", 1, aP2PClientContext[index].connHandle); #if(CFG_DEBUG_APP_TRACE != 0) APP_DBG_MSG("-- GATT : CLIENT_CHAR_CONFIG_DESCRIPTOR_UUID- connection handle 0x%x\n", aP2PClientContext[index].connHandle); #endif @@ -499,6 +520,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) case ACI_GATT_NOTIFICATION_VSEVT_CODE: { + log_debug("Event_Handler", "blecore_evt->ecode=ACI_GATT_NOTIFICATION_VSEVT_CODE", 0); aci_gatt_notification_event_rp0 *pr = (void*)blecore_evt->data; uint8_t index; @@ -509,6 +531,15 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) if(index < BLE_CFG_CLT_MAX_NBR_CB) { + uint8_t buffer[512]; + buffer[0] = (uint8_t)('0'); + buffer[1] = (uint8_t)('x'); + uint8_t i; + for (i = 0; iAttribute_Value_Length; i++) { + snprintf((char*)(buffer + i + 2), 512-i-2, "%x", pr->Attribute_Value[i]); + } + buffer[i + 2] = (uint8_t)('\0'); + log_debug("Event_Handler", "Notification payload: %s", 1, buffer); if ( (pr->Attribute_Handle == aP2PClientContext[index].P2PNotificationCharHdle) && (pr->Attribute_Value_Length == (2)) ) @@ -529,6 +560,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) case ACI_GATT_PROC_COMPLETE_VSEVT_CODE: { + log_debug("Event_Handler", "blecore_evt->ecode=ACI_GATT_PROC_COMPLETE_VSEVT_CODE", 0); aci_gatt_proc_complete_event_rp0 *pr = (void*)blecore_evt->data; #if(CFG_DEBUG_APP_TRACE != 0) APP_DBG_MSG("-- GATT : ACI_GATT_PROC_COMPLETE_VSEVT_CODE \n"); @@ -561,6 +593,7 @@ static SVCCTL_EvtAckStatus_t Event_Handler(void *Event) break; } + log_debug("Event_Handler", "end", 0); return(return_value); }/* end BLE_CTRL_Event_Acknowledged_Status_t */ diff --git a/out/ble-client-seq/ble-client-seq.svg b/out/ble-client-seq/ble-client-seq.svg new file mode 100644 index 0000000..14f49fa --- /dev/null +++ b/out/ble-client-seq/ble-client-seq.svg @@ -0,0 +1,95 @@ +unknownunknownmainmaininterruptinterruptapp_entryapp_entryapp_bleapp_blep2p_client_appp2p_client_appstm32_seqstm32_seq?b?b?a?ashci_tlshci_tlapp_debugapp_debugshcishcisvc_ctlsvc_ctlapp_p2p_clientapp_p2p_clienthw_timeserverhw_timeserverButton pressedHAL_GPIO_EXTI_Callback()APP_BLE_Key_Button1_Action()P2PC_APP_SW1_Button_Action()UTIL_SEQ_SetTask(CFG_TASK_SW1_BUTTON_PUSHED_ID)waiting for task gets executed.Button_Trigger_Received()toggleButtonStatus()Write_Char(P2P_WRITE_CHAR_UUID, 0, buttonStatus)aci_gatt_write_without_resp()Event receivedEvent_Handler()opt[event == HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE]opt[event->core_event == ACI_GATT_PROC_COMPLETE_VSEVT_CODE]opt[aP2PClientContext[index].connHandle != pr->Connection_Handle]UTIL_SEQ_SetTask(CFG_TASK_SEARCH_SERVICE_ID)waiting for task gets executed.Update_Service()UTIL_SEQ_Idle()shci_notify_asynch_evt()UTIL_SEQ_SetTask(CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID)shci_cmd_resp_release()UTIL_SEQ_SetEvt(CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID)shci_cmd_resp_wait()UTIL_SEQ_WaitEvt(CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID)INITUTIL_SEQ_Run(UTIL_SEQ_DEFAULT)shci_user_evt_proc()APPE_SysUserEvtRx()APPD_EnableCPU2()APP_BLE_Init()Ble_Tl_Init()UTIL_SEQ_RegTask(CFG_TASK_HCI_ASYNCH_EVT_ID, UTIL_SEQ_RFU, hci_user_evt_proc)SHCI_C2_BLE_Init()Ble_Hci_Gap_Gatt_Init()SVCCTL_Init()UTIL_SEQ_RegTask(CFG_TASK_START_SCAN_ID, UTIL_SEQ_RFU, Scan_Request)UTIL_SEQ_RegTask(CFG_TASK_CONN_DEV_1_ID, UTIL_SEQ_RFU, Connect_Request)aci_hal_set_radio_activity_mask()P2PC_APP_Init()SVCCTL_RegisterCltHandler(Event_Handler)HW_TS_Create(CFG_TIM_PROC_ID_ISR, &(BleApplicationContext.SwitchOffGPIO_timer_Id), hw_ts_SingleShot, Switch_OFF_GPIO)UTIL_SEQ_PreIdle()UTIL_SEQ_Idle()UTIL_SEQ_PostIdle() \ No newline at end of file diff --git a/request-sequence-diagram.puml b/request-sequence-diagram.puml new file mode 100644 index 0000000..f749635 --- /dev/null +++ b/request-sequence-diagram.puml @@ -0,0 +1,33 @@ +@startuml +participant backend as be +participant usb_receive as usb_r +participant command_exucutor as ce +participant Request as req +participant Response as resp + +be -> usb_r : send command() +usb_r -> ce : enqueue command() +ce -> req : execute() +activate req + req -> req : interpret_request() + req -> req : execute_request() + activate req + create resp + req -> resp : new + activate resp + req -> resp : execute() + resp -> resp : set_payload() + activate resp + resp -> resp : set_response_payload() + activate resp + resp --> resp : response_payload_size + deactivate resp + resp --> resp : payload_size + deactivate resp + resp --> req : was_successful + deactivate resp + req --> req : was_successful + deactivate req +req --> ce : was_successful +deactivate req +@enduml \ No newline at end of file