diff --git a/BLE/BLE_HW_Interface.h b/BLE/BLE_HW_Interface.h index 6b3f31c..7a9759e 100644 --- a/BLE/BLE_HW_Interface.h +++ b/BLE/BLE_HW_Interface.h @@ -25,5 +25,6 @@ SystemKResult_T BLE_GetMyAddress(uint8_t * BD_ADDR); SystemKResult_T BLE_ScanAndAdvertise(void); SystemKResult_T BLE_SetAdvertisingData(BLE_AdvertisingData_T * data); +SystemKResult_T BLE_StopAdvertising(void); #endif // BLE_HW_INTERFACE_H diff --git a/BLE/BLE_Packets.c b/BLE/BLE_Packets.c index 443b52e..8b165fb 100644 --- a/BLE/BLE_Packets.c +++ b/BLE/BLE_Packets.c @@ -304,6 +304,11 @@ void BLE_RespondToConfigurationPacket(const BLE_ParametersPacket_T *const packet { KLOG_ERROR(KLOG_TAG, "Error responding to configuration packet!"); } + + if (BLE_ScanAndAdvertise() != SYSTEMK_RESULT_SUCCESS) + { + KLOG_ERROR(KLOG_TAG, "Couldn't scan and advertise!"); + } } void BLE_UpdateHelloPacket() diff --git a/Game/Weapons.c b/Game/Weapons.c index f90f523..52da364 100644 --- a/Game/Weapons.c +++ b/Game/Weapons.c @@ -158,7 +158,7 @@ Weapon_t WeaponsByID[NUMBER_OF_WEAPONS] = // The Dubuque Protocol { - .ID = LASER_X_ID, + .ID = DUBUQUE_PROTOCOL_ID, .Type = ENERGY, .Protocol = DUBUQUE_PROTOCOL, .Damage_Per_Shot = 1, diff --git a/States/State_Configuring.c b/States/State_Configuring.c index f196438..bf2c664 100644 --- a/States/State_Configuring.c +++ b/States/State_Configuring.c @@ -34,7 +34,8 @@ static TickType_t xBLEConfigurationResponseTimerPeriod = 3000 / portTICK_PERIOD_ static void BLEConfigurationResponseTimerCallback(TimerHandle_t xTimer) { - BLE_UpdateHelloPacket(); + // Don't send HELLO packets once configuration has started. + BLE_StopAdvertising(); } #define MAX_MENU_DEPTH 10 @@ -106,7 +107,7 @@ static void Configuring_Do(StateMachineContext_T *context) portBASE_TYPE xStatus; static KEvent_T Event; - // For the first hunderd milliseconds, keep updating the Hello packet, since on some platforms (PSoC6), one call is not enough. + // For the first hundred milliseconds, keep updating the Hello packet, since on some platforms (PSoC6), one call is not enough. // TODO: Fix the Hello packet hack on PSoC6. if ((xTaskGetTickCount() - context->Time_At_State_Entry_In_Ticks) < (100 / portTICK_PERIOD_MS)) { @@ -413,6 +414,11 @@ void HandleBLEConfigurationPacket(const BLE_ParametersPacket_T *const packet) } } } + else + { + // Once configuration has begun, stop advertising the HELLO packet to free up bandwidth. + BLE_StopAdvertising(); + } BLE_FreePacketBuffer((BLE_GenericPacketType_T *)packet); }