Hello everyone, there is something wrong with my programme, please help me correct it


#include <GxEPD.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>
#include <U8g2_for_Adafruit_GFX.h>
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
#include <ArduinoJson.h>

//AsyncWebServer server(80);
//#include <GxGDEP015OC1/GxGDEP015OC1.h>    // 1.54" b/w
//#include <GxGDEH0154D67/GxGDEH0154D67.h>  // 1.54" b/w
//#include <GxGDEW0154Z04/GxGDEW0154Z04.h>  // 1.54" b/w/r 200x200
//#include <GxGDEW0154Z17/GxGDEW0154Z17.h>  // 1.54" b/w/r 152x152
//#include <GxGDEW0213I5F/GxGDEW0213I5F.h>  // 2.13" b/w 104x212 flexible
//#include <GxGDE0213B1/GxGDE0213B1.h>      // 2.13" b/w 250×122
//#include <GxGDEH0213B72/GxGDEH0213B72.h>  // 2.13" b/w new panel
//#include <GxGDEH0213B73/GxGDEH0213B73.h>  // 2.13" b/w newer panel
//#include <GxGDEW0213Z16/GxGDEW0213Z16.h>  // 2.13" b/w/r
//#include <GxGDEH029A1/GxGDEH029A1.h>      // 2.9" b/w
//#include <GxGDEW029T5/GxGDEW029T5.h>      // 2.9" b/w IL0373
//#include <GxGDEW029Z10/GxGDEW029Z10.h>    // 2.9" b/w/r
//#include <GxGDEW026T0/GxGDEW026T0.h>      // 2.6" b/w
//#include <GxGDEW027C44/GxGDEW027C44.h>    // 2.7" b/w/r
//#include <GxGDEW027W3/GxGDEW027W3.h>      // 2.7" b/w
//#include <GxGDEW0371W7/GxGDEW0371W7.h>    // 3.7" b/w
#include <GxGDEW042T2/GxGDEW042T2.h>      // 4.2" b/w
//#include <GxGDEW042Z15/GxGDEW042Z15.h>    // 4.2" b/w/r
//#include <GxGDEW0583T7/GxGDEW0583T7.h>    // 5.83" b/w
//#include <GxGDEW075T8/GxGDEW075T8.h>      // 7.5" b/w
//#include <GxGDEW075T7/GxGDEW075T7.h>      // 7.5" b/w 800x480
//#include <GxGDEW075Z09/GxGDEW075Z09.h>    // 7.5" b/w/r
//#include <GxGDEW075Z08/GxGDEW075Z08.h>    // 7.5" b/w/r 800x480
U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx;
//DNSServer dns;
//AsyncWiFiManager  wifiManager(&server, &dns);
// mapping suggestion from Waveshare SPI e-Paper to Wemos D1 mini
// BUSY -> D2, RST -> D4, DC -> D3, CS -> D8, CLK -> D5, DIN -> D7, GND -> GND, 3.3V -> 3.3V

// mapping suggestion for ESP32, e.g. LOLIN32, see .../variants/.../pins_arduino.h for your board
// NOTE: there are variants with different pins for SPI ! CHECK SPI PINS OF YOUR BOARD
// BUSY -> 4, RST -> 16, DC -> 17, CS -> SS(5), CLK -> SCK(18), DIN -> MOSI(23), GND -> GND, 3.3V -> 3.3V

//ESP8266
//GxIO_Class io(SPI, /*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2); // arbitrary selection of D3(=0), D4(=2), selected for default of GxEPD_Class
//GxEPD_Class display(io, /*RST=D4*/ 2, /*BUSY=D2*/ 4); // default selection of D4(=2), D2(=4)

//ESP32
GxIO_Class io(SPI, /*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16); // arbitrary selection of 17, 16
GxEPD_Class display(io, /*RST=*/ 16, /*BUSY=*/ 4); // arbitrary selection of (16), 4


String valor;

#define SERVICE_UUID        "a55b8b58-1693-488d-98b3-ee5d929318ef" //禁止修改,修改后APP将无法连接蓝牙
#define CHARACTERISTIC_UUID "0182844c-9a56-454c-94a2-2ba00713ec5a" //禁止修改,修改后APP将无法连接蓝牙
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;
DynamicJsonDocument noteDoc(5000);
class MyCallbacks: public BLECharacteristicCallbacks {
    void onWrite(BLECharacteristic *pCharacteristic) {
      std::string value = pCharacteristic->getValue();

      if (value.length() > 0) {
        valor = "";
        for (int i = 0; i < value.length(); i++) {
          // Serial.print(value[i]); // Presenta value.
          valor = valor + value[i];
        }

        Serial.println("*********");
        Serial.print("valor = ");
        Serial.println(valor); // Presenta valor.

        deserializeJson(noteDoc, valor);
        JsonArray notes = noteDoc["notes"];
        // JsonArray notes = noteDoc["notes"].to<JsonArray>();

        Serial.println( notes.size());
        display.fillScreen(GxEPD_WHITE);
        /*************************************************在这里进行个性化设置******************************************************************/
        for (int i = 0; i < notes.size(); i++) {

          display.drawFastHLine(0, i * 30 + 30, 400, GxEPD_BLACK);
          u8g2_for_adafruit_gfx.setCursor(2, i * 30 + 20);
          int num = i + 1;
          u8g2_for_adafruit_gfx.print(String(num) + ". ");
          u8g2_for_adafruit_gfx.setCursor(25, i * 30 + 20);
          String content = notes[i]["content"];
          u8g2_for_adafruit_gfx.print(content);//noteDoc[i]["content"]

          u8g2_for_adafruit_gfx.setCursor(320, i * 30 + 20);
          String date = notes[i]["date"];
          u8g2_for_adafruit_gfx.print(date);
        }
        /*************************************************在这里进行个性化设置******************************************************************/
        display.update();
      }
    }
};
class MyServerCallbacks: public BLEServerCallbacks {
    void onConnect(BLEServer* pServer) {
      deviceConnected = true;
    };

    void onDisconnect(BLEServer* pServer) {
      deviceConnected = false;
    }
};
void setup() {

  Serial.begin(115200);
  display.init(115200);


  u8g2_for_adafruit_gfx.begin(display);

  BLEDevice::init("墨水屏记事本");  //蓝牙名称
  pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());
  BLEService *pService = pServer->createService(SERVICE_UUID);
  pCharacteristic = pService->createCharacteristic(
                      CHARACTERISTIC_UUID,
                      BLECharacteristic::PROPERTY_READ   |
                      BLECharacteristic::PROPERTY_WRITE  |
                      BLECharacteristic::PROPERTY_NOTIFY |
                      BLECharacteristic::PROPERTY_INDICATE
                    );
  pCharacteristic->addDescriptor(new BLE2902());
  pCharacteristic->setCallbacks(new MyCallbacks());
  pService->start();
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(false);
  pAdvertising->setMinPreferred(0x0);  // set value to 0x00 to not advertise this parameter
  BLEDevice::startAdvertising();



  display.setRotation(4);
  display.fillScreen(GxEPD_WHITE);
  u8g2_for_adafruit_gfx.setFont(u8g2_font_wqy16_t_gb2312b);  // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
  u8g2_for_adafruit_gfx.setForegroundColor(GxEPD_BLACK);         // apply Adafruit GFX color
  u8g2_for_adafruit_gfx.setBackgroundColor(GxEPD_WHITE);         // apply Adafruit GFX color
  u8g2_for_adafruit_gfx.setCursor(20, 20);
  u8g2_for_adafruit_gfx.print("墨水屏记事本");
  display.update();

}
void loop() {

  if (!deviceConnected && oldDeviceConnected) {
    delay(500); // give the bluetooth stack the chance to get things ready
    pServer->startAdvertising(); // restart advertising
    Serial.println("start advertising");
    oldDeviceConnected = deviceConnected;

    Serial.println("disconnecting");
  }

  if (deviceConnected && !oldDeviceConnected) {

    oldDeviceConnected = deviceConnected;

    Serial.println("connecting");
  }
}




Compilation error message:













找到无效库在 C:\Users\Administrator\Documents\Arduino\libraries\include: no headers files (.h) found in C:\Users\Administrator\Documents\Arduino\libraries\include
C:\Users\ADMINI~1\AppData\Local\Temp\arduino_modified_sketch_209374\sketch_apr15a.ino:63:28: warning: 'DynamicJsonDocument' is deprecated: use JsonDocument instead [-Wdeprecated-declarations]
   63 | DynamicJsonDocument noteDoc(5000);
      |                            ^
In file included from C:\Users\Administrator\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:56,
                 from C:\Users\Administrator\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,
                 from C:\Users\ADMINI~1\AppData\Local\Temp\arduino_modified_sketch_209374\sketch_apr15a.ino:10:
C:\Users\Administrator\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/compatibility.hpp:125:58: note: declared here
  125 | class ARDUINOJSON_DEPRECATED("use JsonDocument instead") DynamicJsonDocument
      |                                                          ^~~~~~~~~~~~~~~~~~~
C:\Users\ADMINI~1\AppData\Local\Temp\arduino_modified_sketch_209374\sketch_apr15a.ino: In member function 'virtual void MyCallbacks::onWrite(BLECharacteristic*)':
sketch_apr15a:66:52: error: conversion from 'String' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   66 |       std::string value = pCharacteristic->getValue();
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~^~
exit status 1
conversion from 'String' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
C:\Users\Administrator\Documents\Arduino\sketch_apr15a\sketch_apr15a.ino:63:28: warning: 'DynamicJsonDocument' is deprecated: use JsonDocument instead [-Wdeprecated-declarations]
   63 | DynamicJsonDocument noteDoc(5000);
      |                            ^
In file included from C:\Users\Administrator\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:56,
                 from C:\Users\Administrator\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,
                 from C:\Users\Administrator\Documents\Arduino\sketch_apr15a\sketch_apr15a.ino:10:
C:\Users\Administrator\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/compatibility.hpp:125:58: note: declared here
  125 | class ARDUINOJSON_DEPRECATED("use JsonDocument instead") DynamicJsonDocument
      |                                                          ^~~~~~~~~~~~~~~~~~~
C:\Users\Administrator\Documents\Arduino\sketch_apr15a\sketch_apr15a.ino: In member function 'virtual void MyCallbacks::onWrite(BLECharacteristic*)':
sketch_apr15a:66:52: error: conversion from 'String' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   66 |       std::string value = pCharacteristic->getValue();
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~^~
exit status 1
conversion from 'String' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested

version:2.3.6
日期:2025-04-09T11:26:55.498Z
CLI 版本:1.2.0

Copyright © 2025 Arduino SA

Please insert a full code using a code tags.

Welcome to the forum

How do you know that something is wrong ?
Can you compile the code or do you get error messages ? If you get any then please post them in full using code tags when you do

See https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

No, the code cannot be compiled

Sorry, I'm not very familiar with operating it on my phone. I edited it on my computer this time. Thank you for your reply

Already modified, sorry to bother you

This is not a full sketch, it is a small (very small) part of it... The same about of error message - it breaks in half...

Is what you have posted all that you have got ?

Please post the full sketch

I'll double check

The code that you posted is not a sketch at all, it just a few header lines.

Already modified, please review, thank you

Where did you get the code from ?

The code looks complete, but the error message is not. Please insert a full error message.

In a forum, I want to create a device for children to transmit homework through mobile communication. Now I have bought an ESP32 and an ink screen

Already modified

I might be stating the obvious, but have you tried replacing the above line with the following?

JsonDocument noteDoc(5000);

Okay, I'll try, thank you very much.

exit status 1

Compilation error: no matching function for call to 'ArduinoJson::V741PB22::JsonDocument::JsonDocument(int)'

Even after modification, it still doesn't work

The documentation for ArduinoJson is here:

As best as I can tell from spending just a few minutes reviewing the documentation, your revised declaration should look like this:

JsonDocument noteDoc;

...without the (5000).

no.it is bad