• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 BLE Server and Client (Part 2/2)

Q&A Forum › Category: ESP32 › ESP32 BLE Server and Client (Part 2/2)
0 Vote Up Vote Down
Elvio Spiteri asked 12 months ago

Hello,
I`m doing this course and encountered the below error.
I`m using PlatformIO but tried it also in Arduino IDE and here it works fine.
Can you please help me with what could be the issue?
Thanks and regards,
Elvio

——————– ERROR ——————–
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
src/main.cpp: In function ‘bool connectToServer(BLEAddress)’:
src/main.cpp:352:48: error: ‘temperatureNotifyCallback’ was not declared in this scope
temperatureCharacteristic->registerForNotify(temperatureNotifyCallback);
^
src/main.cpp:353:45: error: ‘humidityNotifyCallback’ was not declared in this scope
humidityCharacteristic->registerForNotify(humidityNotifyCallback);
^
src/main.cpp: At global scope:
src/main.cpp:370:13: warning: ‘void temperatureNotifyCallback(BLERemoteCharacteristic*, uint8_t*, size_t, bool)’ defined but not used [-Wunused-function]
static void temperatureNotifyCallback(BLERemoteCharacteristic* pBLERemoteCharacteristic,
^
src/main.cpp:378:13: warning: ‘void humidityNotifyCallback(BLERemoteCharacteristic*, uint8_t*, size_t, bool)’ defined but not used [-Wunused-function]
static void humidityNotifyCallback(BLERemoteCharacteristic* pBLERemoteCharacteristic,
^
*** [.pio\build\esp32doit-devkit-v1\src\main.cpp.o] Error 1

Question Tags: BLE client connection
3 Answers
0 Vote Up Vote Down
Best Answer
Steve Mercer answered 12 months ago

The “not declared in this scope” error generally means you have tried to use something that hasn’t been created yet. In this case it’s a couple of functions. What you need to do is move the functions above where they are used. So, move temperatureNotifyCallback function above temperatureCharacteristic->registerForNotify(temperatureNotifyCallback); Do the same for the humidityNotifyCallback function. 
 
The Arduino IDE is a bit more forgiving and will let you get away with having the functions anywhere you like. PIO is stricter and will give that error which is correct.

0 Vote Up Vote Down
Elvio Spiteri answered 12 months ago

Thanks very much, Steve, it worked immediately.
I really do appreciate your support.

0 Vote Up Vote Down
Sara Santos Staff answered 12 months ago

Thanks for answering, Steve.
I’ll mark this issue as resolved.
Elvio, If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Firebase Web App with ESP32 and ESP8266 (version 1.2) April 25, 2022
  • [eBook Updated] MicroPython Programming with ESP32 and ESP8266 (version 1.3) February 7, 2022

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2022 · RandomNerdTutorials.com · All Rights Reserved