• 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 4 years 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 4 years 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 4 years ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 4 years 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] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

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

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

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.