nkolban / esp32-snippets

Sample ESP32 snippets and code fragments
https://leanpub.com/kolban-ESP32
Apache License 2.0
2.36k stars 710 forks source link

Problem when trying to compile the SampleServer_authentication_passkey.cpp code #867

Open marvindinneweth opened 5 years ago

marvindinneweth commented 5 years ago

Hi,

Anybody who knows how I could fix this? This is the example under cpp-utils/tests/bletests/security

/home/parallels/Desktop/gatt_security_server/main/main.cpp: In member function 'virtual void MainBLEServer::run(void*)':
/home/parallels/Desktop/gatt_security_server/main/main.cpp:78:50: error: invalid new-expression of abstract class type 'MySecurity'
   BLEDevice::setSecurityCallbacks(new MySecurity());
                                                  ^
/home/parallels/Desktop/gatt_security_server/main/main.cpp:25:7: note:   because the following virtual functions are pure within 'MySecurity':
 class MySecurity : public BLESecurityCallbacks {
       ^
In file included from /home/parallels/Desktop/gatt_security_server/components/cpp_utils/BLEServer.h:22:0,
                 from /home/parallels/Desktop/gatt_security_server/components/cpp_utils/BLEDevice.h:18,
                 from /home/parallels/Desktop/gatt_security_server/main/main.cpp:12:
/home/parallels/Desktop/gatt_security_server/components/cpp_utils/BLESecurity.h:69:15: note:    virtual bool BLESecurityCallbacks::onConfirmPIN(uint32_t)
  virtual bool onConfirmPIN(uint32_t pin) = 0;
               ^

Thx, Marvin

chegewara commented 5 years ago

You can fix BLESecurityCallbacks, so there is not pure virtual, or you have to implement all virtual functions in that class, even if you dont need/use them. Just remember its about ble security, so if its bool then most likely you want to return false.