From 4b8353193df91e1e823d7acb6c5c26ed3e60f53c Mon Sep 17 00:00:00 2001 From: Joe Kearney Date: Sat, 24 May 2025 17:35:07 -0500 Subject: [PATCH] Added BLE_StopAdvertising(). --- components/BLE/BLE.c | 30 ++++++++++++++++++++++++++---- components/SystemK | 2 +- main/Version.h | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/components/BLE/BLE.c b/components/BLE/BLE.c index 15dfe83..a729f96 100644 --- a/components/BLE/BLE.c +++ b/components/BLE/BLE.c @@ -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; } diff --git a/components/SystemK b/components/SystemK index cb72042..6382526 160000 --- a/components/SystemK +++ b/components/SystemK @@ -1 +1 @@ -Subproject commit cb7204269140ba9c6dbe44ca5a5dbaf8c031f685 +Subproject commit 63825263911578804866ec4b34310248b8074f17 diff --git a/main/Version.h b/main/Version.h index 4625992..1c95727 100644 --- a/main/Version.h +++ b/main/Version.h @@ -24,7 +24,7 @@ #define VERSION_H #define VERSION_MAJOR 00 -#define VERSION_MINOR 39 +#define VERSION_MINOR 40 #define STRINGIFY(number) #number #define VERSION_STRING(major, minor) STRINGIFY(major) "." STRINGIFY(minor)