Added BLE_StopAdvertising().

This commit is contained in:
Joe Kearney 2025-05-24 17:35:07 -05:00
parent 138cf30b23
commit 4b8353193d
3 changed files with 28 additions and 6 deletions

View file

@ -11,7 +11,8 @@
static const char *TAG = "BLE";
static bool Host_And_Controller_Synced = false;
static bool Is_Scanning_And_Advertising = false;
static bool Is_Scanning = false;
static bool Is_Advertising = false;
static uint8_t Advertising_Data[BLE_KTAG_PACKET_TOTAL_SIZE] = {0x1E, 0xFF, 0xFF, 0xFF, 'K', 'T', 'a', 'g'};
@ -247,7 +248,7 @@ SystemKResult_T BLE_SetAdvertisingData(BLE_AdvertisingData_T *data)
memcpy(Advertising_Data, data, BLE_KTAG_PACKET_TOTAL_SIZE);
}
if (Is_Scanning_And_Advertising == true)
if (Is_Advertising == true)
{
// Restart advertising to put the new data into the advertisement.
ble_gap_adv_stop();
@ -263,11 +264,32 @@ SystemKResult_T BLE_ScanAndAdvertise(void)
if (Host_And_Controller_Synced == true)
{
if (Is_Scanning_And_Advertising == false)
if (Is_Scanning == false)
{
ble_scan();
Is_Scanning = true;
}
if (Is_Advertising == false)
{
ble_advertise();
Is_Scanning_And_Advertising = true;
Is_Advertising = true;
}
result = SYSTEMK_RESULT_SUCCESS;
}
return result;
}
SystemKResult_T BLE_StopAdvertising(void)
{
SystemKResult_T result = SYSTEMK_RESULT_NOT_READY;
if (Host_And_Controller_Synced == true)
{
if (Is_Advertising == true)
{
ble_gap_adv_stop();
Is_Advertising = false;
}
result = SYSTEMK_RESULT_SUCCESS;
}

@ -1 +1 @@
Subproject commit cb7204269140ba9c6dbe44ca5a5dbaf8c031f685
Subproject commit 63825263911578804866ec4b34310248b8074f17