diff --git a/2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.c b/2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.c index bb57994..1e61a04 100644 --- a/2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.c +++ b/2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.c @@ -192,6 +192,22 @@ void COMM_BLE_Task(void * pvParameters) switch (command.ID) { + case COMM_BLE_STOP_SCANNING: + { + cy_en_ble_api_result_t apiResult = Cy_BLE_GAPC_StopScan(); + + if (apiResult != CY_BLE_SUCCESS) + { +#ifdef TRACE_BLE + COMM_Console_Print_String("[BLE] Cy_BLE_GAPC_StopScan API Error: 0x"); + COMM_Console_Print_UInt32AsHex(apiResult); + COMM_Console_Print_String("\n"); +#endif // TRACE_BLE + } + COMM_BLE_RequestState(COMM_BLE_IDLE); + } + break; + case COMM_BLE_STOP_ADVERTISING: { cy_en_ble_api_result_t apiResult = Cy_BLE_GAPP_StopAdvertisement(); @@ -340,6 +356,14 @@ SystemKResult_T BLE_StopAdvertising(void) return SYSTEMK_RESULT_SUCCESS; } +SystemKResult_T BLE_StopScanning(void) +{ + COMM_BLE_Command_T command = { .ID = COMM_BLE_STOP_SCANNING, .Data = (void *)0x00 }; + xQueueSend(COMM_BLE_CommandQueue, &command, 0); + + return SYSTEMK_RESULT_SUCCESS; +} + void COMM_BLE_RequestState(COMM_BLE_StateID_T state) { Next_State = state; diff --git a/2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.h b/2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.h index 83701e6..e4921c5 100644 --- a/2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.h +++ b/2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.h @@ -43,6 +43,7 @@ typedef enum COMM_BLE_SCAN_FOR_KTAG_PACKETS, COMM_BLE_ADVERTISE_AS_BROADCASTER, COMM_BLE_ADVERTISE_AS_PERIPHERAL, + COMM_BLE_STOP_SCANNING, COMM_BLE_STOP_ADVERTISING, COMM_BLE_SCAN_AND_ADVERTISE, // COMM_BLE_COMMAND_IS_OUT_OF_RANGE is one more than the last valid command. diff --git a/2020TPCApp1.cydsn/SystemK b/2020TPCApp1.cydsn/SystemK index 7aa8275..fb1a4ab 160000 --- a/2020TPCApp1.cydsn/SystemK +++ b/2020TPCApp1.cydsn/SystemK @@ -1 +1 @@ -Subproject commit 7aa827563a00b9bfa74e89be60f8529259ddac99 +Subproject commit fb1a4ab07b990fef8f957ef7c5f806649e126d0f diff --git a/2020TPCAppNoDFU.cydsn/COMM/BLE/COMM_BLE.c b/2020TPCAppNoDFU.cydsn/COMM/BLE/COMM_BLE.c index bb57994..1e61a04 100644 --- a/2020TPCAppNoDFU.cydsn/COMM/BLE/COMM_BLE.c +++ b/2020TPCAppNoDFU.cydsn/COMM/BLE/COMM_BLE.c @@ -192,6 +192,22 @@ void COMM_BLE_Task(void * pvParameters) switch (command.ID) { + case COMM_BLE_STOP_SCANNING: + { + cy_en_ble_api_result_t apiResult = Cy_BLE_GAPC_StopScan(); + + if (apiResult != CY_BLE_SUCCESS) + { +#ifdef TRACE_BLE + COMM_Console_Print_String("[BLE] Cy_BLE_GAPC_StopScan API Error: 0x"); + COMM_Console_Print_UInt32AsHex(apiResult); + COMM_Console_Print_String("\n"); +#endif // TRACE_BLE + } + COMM_BLE_RequestState(COMM_BLE_IDLE); + } + break; + case COMM_BLE_STOP_ADVERTISING: { cy_en_ble_api_result_t apiResult = Cy_BLE_GAPP_StopAdvertisement(); @@ -340,6 +356,14 @@ SystemKResult_T BLE_StopAdvertising(void) return SYSTEMK_RESULT_SUCCESS; } +SystemKResult_T BLE_StopScanning(void) +{ + COMM_BLE_Command_T command = { .ID = COMM_BLE_STOP_SCANNING, .Data = (void *)0x00 }; + xQueueSend(COMM_BLE_CommandQueue, &command, 0); + + return SYSTEMK_RESULT_SUCCESS; +} + void COMM_BLE_RequestState(COMM_BLE_StateID_T state) { Next_State = state; diff --git a/2020TPCAppNoDFU.cydsn/COMM/BLE/COMM_BLE.h b/2020TPCAppNoDFU.cydsn/COMM/BLE/COMM_BLE.h index 83701e6..e4921c5 100644 --- a/2020TPCAppNoDFU.cydsn/COMM/BLE/COMM_BLE.h +++ b/2020TPCAppNoDFU.cydsn/COMM/BLE/COMM_BLE.h @@ -43,6 +43,7 @@ typedef enum COMM_BLE_SCAN_FOR_KTAG_PACKETS, COMM_BLE_ADVERTISE_AS_BROADCASTER, COMM_BLE_ADVERTISE_AS_PERIPHERAL, + COMM_BLE_STOP_SCANNING, COMM_BLE_STOP_ADVERTISING, COMM_BLE_SCAN_AND_ADVERTISE, // COMM_BLE_COMMAND_IS_OUT_OF_RANGE is one more than the last valid command. diff --git a/2020TPCAppNoDFU.cydsn/SystemK b/2020TPCAppNoDFU.cydsn/SystemK index 7aa8275..fb1a4ab 160000 --- a/2020TPCAppNoDFU.cydsn/SystemK +++ b/2020TPCAppNoDFU.cydsn/SystemK @@ -1 +1 @@ -Subproject commit 7aa827563a00b9bfa74e89be60f8529259ddac99 +Subproject commit fb1a4ab07b990fef8f957ef7c5f806649e126d0f