Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: 'const void*' is not a pointer-to-object type #1874

Closed
beliboba opened this issue Feb 19, 2023 · 2 comments
Closed

error: 'const void*' is not a pointer-to-object type #1874

beliboba opened this issue Feb 19, 2023 · 2 comments
Labels
duplicate v6 ArduinoJson 6

Comments

@beliboba
Copy link

beliboba commented Feb 19, 2023

error: 'const void*' is not a pointer-to-object type
This error occurs when trying to compile sketch.
Im using arduino editor with arduino iot cloud.
Have a look at my code:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include "thingProperties.h"

#define TFT_CS         12
#define TFT_RST        4
#define TFT_DC         5

#define stickVRX 16 // D0
#define stickVRY 0 // D3
#define stickSW 2 // D4

const char* ssid = "";
const char* password =  "";

const char* username = "";
const char* token = "";

const char* repo = "";

const char* host = "api.github.com";

Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
HTTPClient http;
WiFiClient client;

template <typename T>
inline const T* pgm_read(const void* p) {
  return reinterpret_cast<const T*>(pgm_read_ptr(p));
}

void startup() {
  tft.fillScreen(ST77XX_BLACK);
  tft.setCursor(45, 120);
  tft.setTextSize(2);
  tft.println("Github Tracker");
}

void setup() {
  Serial.begin(115200);
  
  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("connected");
  
  tft.init(240, 240, SPI_MODE3);
  tft.setRotation(2);
  delay(1500);
  initProperties();

  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  initProperties();
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
  startup();
  delay(500);
}

void notifications() {
  WiFiClientSecure client;
  if (!client.connect(host, 443)) {
    Serial.println("Connection failed");
    return;
  }
  if (client.verify(fingerprint, host)) {
    Serial.println("Certificate matches");
  } else {
    Serial.println("Certificate doesn't match");
    return;
  }
  client.print(String("GET /notifications?access_token=") + token + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "User-Agent: ESP8266\r\n" +
               "Connection: close\r\n\r\n");
  while (!client.available()) {
    delay(10);
  }
  String response = "";
  while (client.available()) {
    response += client.readString();
  }
  const size_t capacity = JSON_OBJECT_SIZE(10) + 1000;
  DynamicJsonDocument doc(capacity);
  DeserializationError error = deserializeJson(doc, response);
  if (error) {
    Serial.print("deserializeJson() failed: ");
    Serial.println(error.c_str());
    return;
  }
  JsonArray notifications = doc.as<JsonArray>();
  Serial.println("Latest notifications:");
  for (JsonObject notification : notifications) {
    Serial.println(notification["subject"]["title"].as<String>());
  }
}


void loop() {
  ArduinoCloud.update();
  // Get the latest notifications from GitHub every minute
  static unsigned long lastNotification = 0;
  if (millis() - lastNotification > 60000) {
    lastNotification = millis();
    notifications();
  }
}
@beliboba beliboba added the bug label Feb 19, 2023
@bblanchon
Copy link
Owner

Related to arduino/ArduinoCore-API#118.
Duplicate of #1442, #1519, #1536, #1591, #1676, and #1790.

If the error occurs in ArduinoJson (which I cannot tell because you didn't include the compiler output), you can work around this bug by defining ARDUINOJSON_ENABLE_PROGMEM to 0. BTW, the ArduinoJson Troubleshooter would have told you that.

@bblanchon bblanchon added duplicate and removed bug labels Feb 20, 2023
@beliboba
Copy link
Author

Thank you! Ill try it

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2023
@bblanchon bblanchon added the v6 ArduinoJson 6 label Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate v6 ArduinoJson 6
Projects
None yet
Development

No branches or pull requests

2 participants