Beginner Warning!! Having moved from PlatformIO to using the esp IDF toolchain I am getting the errors below when I try and compile some sample code for C++. Am I missing something really obvious here with my initial attempts?
MINGW32 ~/esp/stblescan
$ make
CXX build/main/stblescan.o
C:/msys32/home/simon/esp/stblescan/main/stblescan.cpp: In member function 'virtual void MyAdvertisedDeviceCallbacks::onResult(BLEAdvertisedDevice)':
C:/msys32/home/simon/esp/stblescan/main/stblescan.cpp:17:7: error: 'Serial' was not declared in this scope
Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
^
C:/msys32/home/simon/esp/stblescan/main/stblescan.cpp: In function 'void setup()':
C:/msys32/home/simon/esp/stblescan/main/stblescan.cpp:23:3: error: 'Serial' was not declared in this scope
Serial.begin(115200);
^
C:/msys32/home/simon/esp/stblescan/main/stblescan.cpp: In function 'void loop()':
C:/msys32/home/simon/esp/stblescan/main/stblescan.cpp:38:13: error: 'delay' was not declared in this scope
delay(2000);
^
make[1]: [/home/simon/esp/esp-idf/make/component_wrapper.mk:274: stblescan.o] Error 1
make: [C:/msys32/home/simon/esp/esp-idf/make/project.mk:450: component-main-build] Error 2
Beginner Warning!! Having moved from PlatformIO to using the esp IDF toolchain I am getting the errors below when I try and compile some sample code for C++. Am I missing something really obvious here with my initial attempts?
Here is the example code for stblescan.cpp:
include "BLEDevice.h"
include "BLEUtils.h"
include "BLEScan.h"
include "BLEAdvertisedDevice.h"
int scanTime = 30; //In seconds
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { void onResult(BLEAdvertisedDevice advertisedDevice) {
};
void setup() { Serial.begin(115200); Serial.println("Scanning...");
BLEDevice::init(""); BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster BLEScanResults foundDevices = pBLEScan->start(scanTime); Serial.print("Devices found: "); Serial.println(foundDevices.getCount()); Serial.println("Scan done!"); }
void loop() { // put your main code here, to run repeatedly: delay(2000); }