From 8fa7862fcfee8c005ff9e66f88d4774ccf9e58a2 Mon Sep 17 00:00:00 2001 From: ankgt Date: Fri, 19 May 2023 22:59:20 +0530 Subject: [PATCH] Initialize pAdvertising after NimBLEDevice::init() (#545) Initializing the pAdvertising variable from NimBLEDevice::init while defining it as a globally results in the name getting truncated. --- .../NimBLE_Service_Data_Advertiser.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/NimBLE_Service_Data_Advertiser/NimBLE_Service_Data_Advertiser.ino b/examples/NimBLE_Service_Data_Advertiser/NimBLE_Service_Data_Advertiser.ino index dd588fd2..21bddf05 100644 --- a/examples/NimBLE_Service_Data_Advertiser/NimBLE_Service_Data_Advertiser.ino +++ b/examples/NimBLE_Service_Data_Advertiser/NimBLE_Service_Data_Advertiser.ino @@ -12,7 +12,7 @@ #define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b" static NimBLEUUID dataUuid(SERVICE_UUID); -static NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising(); +static NimBLEAdvertising *pAdvertising = nullptr; static uint32_t count = 0; void setup() { @@ -20,6 +20,7 @@ void setup() { Serial.println("Starting BLE work!"); NimBLEDevice::init("svc data"); + pAdvertising = NimBLEDevice::getAdvertising(); } void loop() {