From 44c15b98fa4c262947b3ab1e3ca3c5e1bd51631d Mon Sep 17 00:00:00 2001 From: ankgt Date: Mon, 15 May 2023 20:12:06 +0530 Subject: [PATCH] Initialize pAdvertising after NimBLEDevice::init() 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() {