diff options
Diffstat (limited to 'Projects/NUCLEO-WB15CC/Applications/BLE/BLE_DataThroughput/STM32_WPAN/App/dts.c')
-rw-r--r-- | Projects/NUCLEO-WB15CC/Applications/BLE/BLE_DataThroughput/STM32_WPAN/App/dts.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/Projects/NUCLEO-WB15CC/Applications/BLE/BLE_DataThroughput/STM32_WPAN/App/dts.c b/Projects/NUCLEO-WB15CC/Applications/BLE/BLE_DataThroughput/STM32_WPAN/App/dts.c index 60daa3acb..4d6d37f0f 100644 --- a/Projects/NUCLEO-WB15CC/Applications/BLE/BLE_DataThroughput/STM32_WPAN/App/dts.c +++ b/Projects/NUCLEO-WB15CC/Applications/BLE/BLE_DataThroughput/STM32_WPAN/App/dts.c @@ -97,6 +97,7 @@ static tBleStatus TX_Update_Char( DTS_STM_Payload_t *pDataValue ); static SVCCTL_EvtAckStatus_t DTS_Event_Handler( void *pckt ); static DataTransferSvcContext_t aDataTransferContext; extern uint16_t Att_Mtu_Exchanged; +extern void BLE_SVC_L2CAP_Conn_Update_7_5(void); /* Functions Definition ------------------------------------------------------*/ /* Private functions ----------------------------------------------------------*/ @@ -110,9 +111,10 @@ static SVCCTL_EvtAckStatus_t DTS_Event_Handler( void *Event ) { SVCCTL_EvtAckStatus_t return_value; hci_event_pckt * event_pckt; - evt_blue_aci * blue_evt; + evt_blecore_aci * blecore_evt; aci_gatt_attribute_modified_event_rp0 * attribute_modified; aci_att_exchange_mtu_resp_event_rp0 * exchange_mtu_resp; + aci_gatt_write_permit_req_event_rp0 * write_permit_req ; DTS_STM_App_Notification_evt_t Notification; @@ -121,22 +123,22 @@ static SVCCTL_EvtAckStatus_t DTS_Event_Handler( void *Event ) switch (event_pckt->evt) { - case EVT_VENDOR: + case HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE: { - blue_evt = (evt_blue_aci*) event_pckt->data; + blecore_evt = (evt_blecore_aci*) event_pckt->data; - switch (blue_evt->ecode) + switch (blecore_evt->ecode) { - case EVT_BLUE_ATT_EXCHANGE_MTU_RESP: - APP_DBG_MSG("EVT_BLUE_ATT_EXCHANGE_MTU_RESP \n"); - exchange_mtu_resp = (aci_att_exchange_mtu_resp_event_rp0 *)blue_evt->data; - APP_DBG_MSG("MTU_size = %d \n",exchange_mtu_resp->Server_RX_MTU ); + case ACI_ATT_EXCHANGE_MTU_RESP_VSEVT_CODE: + exchange_mtu_resp = (aci_att_exchange_mtu_resp_event_rp0 *)blecore_evt->data; + APP_DBG_MSG("**MTU_size = %d \n",exchange_mtu_resp->Server_RX_MTU ); + APP_DBG_MSG("\r\n\r"); Att_Mtu_Exchanged = exchange_mtu_resp->Server_RX_MTU; break; /* server */ - case EVT_BLUE_GATT_ATTRIBUTE_MODIFIED: + case ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE: { - attribute_modified = (aci_gatt_attribute_modified_event_rp0*) blue_evt->data; + attribute_modified = (aci_gatt_attribute_modified_event_rp0*) blecore_evt->data; if (attribute_modified->Attr_Handle == (aDataTransferContext.DataTransferTxCharHdle + 2)) { /** @@ -144,13 +146,15 @@ static SVCCTL_EvtAckStatus_t DTS_Event_Handler( void *Event ) */ if (attribute_modified->Attr_Data[0] & DTS_STM_NOTIFICATION_MASK) { - APP_DBG_MSG("notification enabled\n"); + APP_DBG_MSG("**NOTIFICATION ENABLED \n"); + APP_DBG_MSG("\r\n\r"); Notification.Evt_Opcode = DTS_STM__NOTIFICATION_ENABLED; DTS_Notification(&Notification); } else { - APP_DBG_MSG("notification disabled\n"); + APP_DBG_MSG("**NOTIFICATION DISABLED \n"); + APP_DBG_MSG("\r\n\r"); Notification.Evt_Opcode = DTS_STM_NOTIFICATION_DISABLED; DTS_Notification(&Notification); } @@ -162,13 +166,16 @@ static SVCCTL_EvtAckStatus_t DTS_Event_Handler( void *Event ) */ if (attribute_modified->Attr_Data[0] & DTS_STM_NOTIFICATION_MASK) { - APP_DBG_MSG("notification enabled\n"); + APP_DBG_MSG("**WRITE RESULT NOTIFICATION ENABLED \n"); + APP_DBG_MSG("\r\n\r"); + BLE_SVC_L2CAP_Conn_Update_7_5(); Notification.Evt_Opcode = DTC_NOTIFICATION_ENABLED; DTS_Notification(&Notification); } else { - APP_DBG_MSG("notification disabled\n"); + APP_DBG_MSG("**WRITE RESULT NOTIFICATION DISABLED \n"); + APP_DBG_MSG("\r\n\r"); Notification.Evt_Opcode = DTC_NOTIFICATION_DISABLED; DTS_Notification(&Notification); } @@ -177,22 +184,27 @@ static SVCCTL_EvtAckStatus_t DTS_Event_Handler( void *Event ) { return_value = SVCCTL_EvtAckFlowEnable; - APP_DBG_MSG("length = %x, offset = %x\r\n", attribute_modified->Attr_Data_Length,attribute_modified->Offset); Notification.Evt_Opcode = DTS_STM_DATA_RECEIVED; Notification.DataTransfered.Length=attribute_modified->Attr_Data_Length; DTS_Notification(&Notification); } } break; - case EVT_BLUE_GATT_TX_POOL_AVAILABLE: + case ACI_GATT_TX_POOL_AVAILABLE_VSEVT_CODE: Resume_Notification(); break; + + case ACI_GATT_WRITE_PERMIT_REQ_VSEVT_CODE: + //APP_DBG_MSG("WRITE PERMIT RESP \r\n"); + write_permit_req = (aci_gatt_write_permit_req_event_rp0 *) blecore_evt->data; + aci_gatt_write_resp( write_permit_req->Connection_Handle, write_permit_req->Attribute_Handle, 0, 0, write_permit_req->Data_Length, write_permit_req->Data); + break; default: break; } } - break; /* HCI_EVT_VENDOR_SPECIFIC */ + break; /* HCI_HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE_SPECIFIC */ default: break; @@ -252,7 +264,7 @@ void DTS_STM_Init( void ) /** * Add Data Transfer TX Characteristic */ - aci_gatt_add_char(aDataTransferContext.DataTransferSvcHdle, + hciCmdResult = aci_gatt_add_char(aDataTransferContext.DataTransferSvcHdle, DT_UUID_LENGTH, (Char_UUID_t *) DT_REQ_CHAR_UUID, DATA_TRANSFER_NOTIFICATION_LEN_MAX, @@ -274,9 +286,9 @@ void DTS_STM_Init( void ) DT_UUID_LENGTH, (Char_UUID_t *) DT_REQ_CHAR2_UUID, 255, /* DATA_TRANSFER_NOTIFICATION_LEN_MAX, */ - CHAR_PROP_WRITE, + CHAR_PROP_WRITE_WITHOUT_RESP, ATTR_PERMISSION_NONE, - GATT_NOTIFY_ATTRIBUTE_WRITE, /* gattEvtMask */ + GATT_NOTIFY_ATTRIBUTE_WRITE, //GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP,/* gattEvtMask */ 10, /* encryKeySize */ 1, /* isVariable */ &(aDataTransferContext.DataTransferRxCharHdle)); |