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

'StaticJsonDocument' was not declared in this scope #2782

Closed
s0170071 opened this issue Nov 25, 2019 · 18 comments
Closed

'StaticJsonDocument' was not declared in this scope #2782

s0170071 opened this issue Nov 25, 2019 · 18 comments
Labels
Category: Build Related to building/IDE/releases Type: Bug Considered a bug

Comments

@s0170071
Copy link
Contributor

As soon as I add #define P016_P035_Extended_AC to custom.h, I get a compile error:

'StaticJsonDocument' was not declared in this scope

my Custom.h:

#ifndef ESPEASY_CUSTOM_H
#define ESPEASY_CUSTOM_H

/*
    To modify the stock configuration without changing the EspEasy.ino file :

    1) rename this file to "Custom.h" (It is ignored by Git)
    2) define your own settings below
    3) define USE_CUSTOM_H as a build flags. ie : export PLATFORMIO_BUILD_FLAGS="'-DUSE_CUSTOM_H'"
 */


/*

 #######################################################################################################
   Your Own Default Settings
 #######################################################################################################

    You can basically ovveride ALL macro defined in ESPEasy.ino.
    Don't forget to first #undef each existing #define that you add below.
    But since this Custom.h is included before other defines are made, you don't have to undef a lot of defines.

    Here are some examples:
 */

#ifdef BUILD_GIT
# undef BUILD_GIT
#endif // ifdef BUILD_GIT

#define BUILD_GIT           "My Build: "  __DATE__ " "  __TIME__


#define DEFAULT_NAME        "MyEspEasyDevice"                        // Enter your device friendly name
#define UNIT                0                                        // Unit Number
#define DEFAULT_DELAY       60                                       // Sleep Delay in seconds

// --- Wifi AP Mode (when your Wifi Network is not reachable) ----------------------------------------
#define DEFAULT_AP_IP       192, 168, 1, 1                           // Enter IP address (comma separated) for AP (config) mode
#define DEFAULT_AP_SUBNET   255, 255, 255, 0                         // Enter IP address (comma separated) for AP (config) mode
#define DEFAULT_AP_KEY      "configesp"                              // Enter network WPA key for AP (config) mode

// --- Wifi Client Mode -----------------------------------------------------------------------------
#define DEFAULT_SSID                         ""            // Enter your network SSID
#define DEFAULT_KEY                          "" // Enter your network WPA key
#define DEFAULT_USE_STATIC_IP                false                   // (true|false) enabled or disabled static IP
#define DEFAULT_IP                           "192.168.0.50"          // Enter your IP address
#define DEFAULT_DNS                          "192.168.0.1"           // Enter your DNS
#define DEFAULT_GW                           "192.168.0.1"           // Enter your Gateway
#define DEFAULT_SUBNET                       "255.255.255.0"         // Enter your Subnet
#define DEFAULT_IPRANGE_LOW                  "0.0.0.0"               // Allowed IP range to access webserver
#define DEFAULT_IPRANGE_HIGH                 "255.255.255.255"       // Allowed IP range to access webserver
#define DEFAULT_IP_BLOCK_LEVEL               1                       // 0: ALL_ALLOWED  1: LOCAL_SUBNET_ALLOWED  2:
// ONLY_IP_RANGE_ALLOWED
#define DEFAULT_ADMIN_USERNAME               "admin"

#define DEFAULT_WIFI_CONNECTION_TIMEOUT      10000 // minimum timeout in ms for WiFi to be connected.
#define DEFAULT_WIFI_FORCE_BG_MODE           false // when set, only allow to connect in 802.11B or G mode (not N)
#define DEFAULT_WIFI_RESTART_WIFI_CONN_LOST  false // Perform wifi off and on when connection was lost.
#define DEFAULT_ECO_MODE                     false // When set, make idle calls between executing tasks.
#define DEFAULT_WIFI_NONE_SLEEP              false // When set, the wifi will be set to no longer sleep (more power
// used and need reboot to reset mode)
#define DEFAULT_GRATUITOUS_ARP               false // When set, the node will send periodical gratuitous ARP
// packets to announce itself.

// --- Default Controller ------------------------------------------------------------------------------
#define DEFAULT_CONTROLLER   true                                          // true or false enabled or disabled, set 1st controller
                                                                            // defaults

// using a default template, you also need to set a DEFAULT PROTOCOL to a suitable MQTT protocol !
#define DEFAULT_PUB         "sensors/%tskname%/%valname%" // Enter your pub
#define DEFAULT_SUB         "sensors/espeasy/%sysname%/#"                   // Enter your sub
#define DEFAULT_SERVER      "192.168.1.52"                                   // Enter your Server IP address
#define DEFAULT_PORT        1883                                            // Enter your Server port value

#define DEFAULT_PROTOCOL    5                                               // Protocol used for controller communications
                                                                            //   0 = Stand-alone (no controller set)
                                                                            //   1 = Domoticz HTTP
                                                                            //   2 = Domoticz MQTT
                                                                            //   3 = Nodo Telnet
                                                                            //   4 = ThingSpeak
                                                                            //   5 = Home Assistant (openHAB) MQTT
                                                                            //   6 = PiDome MQTT
                                                                            //   7 = EmonCMS
                                                                            //   8 = Generic HTTP
                                                                            //   9 = FHEM HTTP

#define DEFAULT_PIN_I2C_SDA                     4
#define DEFAULT_PIN_I2C_SCL                     5

#define DEFAULT_PIN_STATUS_LED                  -1
#define DEFAULT_PIN_STATUS_LED_INVERSED         true


#define DEFAULT_USE_RULES                       false             // (true|false) Enable Rules?
#define DEFAULT_RULES_OLDENGINE                 true

#define DEFAULT_MQTT_RETAIN                     false             // (true|false) Retain MQTT messages?
#define DEFAULT_MQTT_DELAY                      100               // Time in milliseconds to retain MQTT messages
#define DEFAULT_MQTT_LWT_TOPIC                  ""                // Default lwt topic
#define DEFAULT_MQTT_LWT_CONNECT_MESSAGE        "Connected"       // Default lwt message
#define DEFAULT_MQTT_LWT_DISCONNECT_MESSAGE     "Connection Lost" // Default lwt message
#define DEFAULT_MQTT_USE_UNITNAME_AS_CLIENTID   0

#define DEFAULT_USE_NTP                         true             // (true|false) Use NTP Server
#define DEFAULT_NTP_HOST                        "192.168.1.1"                // NTP Server Hostname
#define DEFAULT_TIME_ZONE                       60                 // Time Offset (in minutes)
#define DEFAULT_USE_DST                         true             // (true|false) Use Daily Time Saving

#define DEFAULT_SYSLOG_IP                       ""                // Syslog IP Address
#define DEFAULT_SYSLOG_LEVEL                    0                 // Syslog Log Level
#define DEFAULT_SERIAL_LOG_LEVEL                LOG_LEVEL_INFO    // Serial Log Level
#define DEFAULT_WEB_LOG_LEVEL                   LOG_LEVEL_INFO    // Web Log Level
#define DEFAULT_SD_LOG_LEVEL                    0                 // SD Card Log Level
#define DEFAULT_USE_SD_LOG                      false             // (true|false) Enable Logging to the SD card

#define DEFAULT_USE_SERIAL                      true              // (true|false) Enable Logging to the Serial Port
#define DEFAULT_SERIAL_BAUD                     115200            // Serial Port Baud Rate
#define DEFAULT_SYSLOG_FACILITY                 0                 // kern


//#define BUILD_NO_DEBUG

// #define USE_SETTINGS_ARCHIVE

/*
 #######################################################################################################
   Special settings  (rendering settings incompatible with other builds)
 #######################################################################################################
 */

// #define USE_NON_STANDARD_24_TASKS

/*
 #######################################################################################################
   Your Own selection of plugins and controllers
 #######################################################################################################
 */

#define CONTROLLER_SET_NONE
#define NOTIFIER_SET_NONE
#define PLUGIN_SET_NONE


/*
 #######################################################################################################
 ###########     Plugins
 #######################################################################################################
 */

#define PLUGIN_BUILD_CUSTOM
//#define BUILD_MINIMAL_OTA    // zusätzlich #define FEATURE_ARDUINO_OTA in ESPEasyCommon.h Zeile 91 sonst linker error.
#define FEATURE_MDNS         // auch einschalten, sonst kein network port in der Arduino IDE

    // einfach in den Ordner legen:
    // vito 
    // MT681
    // SHT25     
    // SMA

    //#ifndef BUILD_NO_DEBUG
    //  #define BUILD_NO_DEBUG
    //#endif
    #ifndef PLUGIN_DESCR
        #define PLUGIN_DESCR  "S0170071"
    #endif // PLUGIN_DESCR

// #define USE_SERVO


   #define USES_P001   // Switch
   #define USES_P002   // ADC
   #define USES_P003   // Pulse
// #define USES_P004   // Dallas
// #define USES_P005   // DHT
 #define USES_P006   // BMP085
// #define USES_P007   // PCF8591
   #define USES_P008   // RFID
// #define USES_P009   // MCP

// #define USES_P010   // BH1750
// #define USES_P011   // PME
// #define USES_P012   // LCD
// #define USES_P013   // HCSR04
// #define USES_P014   // SI7021
// #define USES_P015   // TSL2561
// #define USES_P017   // PN532
// #define USES_P018   // Dust
// #define USES_P019   // PCF8574

// #define USES_P020   // Ser2Net
// #define USES_P021   // Level
// #define USES_P022   // PCA9685
   #define USES_P023   // OLED
// #define USES_P024   // MLX90614
// #define USES_P025   // ADS1115
   #define USES_P026   // SysInfo
// #define USES_P027   // INA219
// #define USES_P028   // BME280
   #define USES_P029   // Output

// #define USES_P031   // SHT1X
// #define USES_P032   // MS5611
   #define USES_P033   // Dummy
// #define USES_P034   // DHT12
// #define USES_P036   // FrameOLED
   #define USES_P037   // MQTTImport
// #define USES_P038   // NeoPixel
// #define USES_P039   // Environment - Thermocouple

   #define USES_P040   // RFID - ID12LA/RDM6300
// #define USES_P041   // NeoClock
// #define USES_P042   // Candle
   #define USES_P043   // ClkOutput
// #define USES_P044   // P1WifiGateway
// #define USES_P045   // MPU6050
// #define USES_P046   // VentusW266
// #define USES_P047   // I2C_soil_misture
// #define USES_P048   // Motoshield_v2
// #define USES_P049   // MHZ19

// #define USES_P050   // TCS34725 RGB Color Sensor with IR filter and White LED
// #define USES_P051   // AM2320
// #define USES_P052   // SenseAir
// #define USES_P053   // PMSx003
// #define USES_P054   // DMX512
// #define USES_P055   // Chiming
// #define USES_P056   // SDS011-Dust
// #define USES_P057   // HT16K33_LED
// #define USES_P058   // HT16K33_KeyPad
// #define USES_P059   // Encoder

// #define USES_P060   // MCP3221
// #define USES_P061   // Keypad
// #define USES_P062   // MPR121_KeyPad
// #define USES_P063   // TTP229_KeyPad
// #define USES_P064   // APDS9960 Gesture
// #define USES_P065   // DRF0299
// #define USES_P066   // VEML6040
// #define USES_P067   // HX711_Load_Cell
// #define USES_P068   // SHT3x
// #define USES_P069   // LM75A

// #define USES_P070   // NeoPixel_Clock
// #define USES_P071   // Kamstrup401
// #define USES_P072   // HDC1080
// #define USES_P073   // 7DG
// #define USES_P074   // TSL2561
// #define USES_P075   // Nextion
// #define USES_P076   // HWL8012   in POW r1
// #define USES_P077   // CSE7766   in POW R2
// #define USES_P078   // Eastron Modbus Energy meters
// #define USES_P079   // Wemos Motoshield

// #define USES_P080   // iButton Sensor  DS1990A
// #define USES_P081   // Cron
// #define USES_P082   // GPS
// #define USES_P083   // SGP30
// #define USES_P084   // VEML6070
// #define USES_P085   // AcuDC24x
   #define USES_P086   // Receiving values according Homie convention. Works together with C014 Homie controller
// #define USES_P087   // Serial Proxy


// Special plugins needing IR library
// #define USES_P016   // IR
   #define USES_P035   // IRTX
   #define P016_P035_Extended_AC // The following define is needed for extended decoding of A/C Messages and or using standardised 
                                 //common arguments for controlling all deeply supported A/C units
 #define P016_P035_USE_RAW_RAW2 //Use the RAW and RAW2 encodings, disabling it saves 3.7Kb
// #define USES_P088   // Heatpump IR


/*
 #######################################################################################################
 ###########     Controllers
 #######################################################################################################
 */


// #define USES_C001   // Domoticz HTTP
// #define USES_C002   // Domoticz MQTT
// #define USES_C003   // Nodo telnet
   #define USES_C004   // ThingSpeak
   #define USES_C005   // Home Assistant (openHAB) MQTT
// #define USES_C006   // PiDome MQTT
// #define USES_C007   // Emoncms
// #define USES_C008   // Generic HTTP
// #define USES_C009   // FHEM HTTP
// #define USES_C010   // Generic UDP
   #define USES_C011   // Generic HTTP Advanced
// #define USES_C012   // Blynk HTTP
   #define USES_C013   // ESPEasy P2P network
   #define USES_C014   // homie 3 & 4dev MQTT
// #define USES_C015   // Blynk
// #define USES_C016   // Cache controller
// #define USES_C017   // Zabbix
// #define USES_C018   // TTN/RN2483


/*
 #######################################################################################################
 ###########     Notifiers
 #######################################################################################################
 */


// #define USES_N001   // Email
// #define USES_N002   // Buzzer


#endif // ESPEASY_CUSTOM_H

@s0170071
Copy link
Contributor Author

resolved it by adding
#include "ArduinoJson.h"
to P035_IRTX.ino
Still, this should not happen...

@TD-er
Copy link
Member

TD-er commented Nov 25, 2019

I think this include is also needed for _P016_IR.ino as the same class is used in there.

@TD-er
Copy link
Member

TD-er commented Nov 25, 2019

Can you make a PR for the addition of both includes?

@TD-er TD-er added Category: Build Related to building/IDE/releases Type: Bug Considered a bug labels Nov 25, 2019
@s0170071
Copy link
Contributor Author

hmm. Now it compiles but gives me an error in the log.
Deserialize Json failed: NoMemory

Other than that, I am having a hard time copying that line from the weblog as it jumps away then I try to do so. Yes, I have unchecked Autoscroll. Try strg+f "failed". You see it but you cannot grab it :-o

@TD-er
Copy link
Member

TD-er commented Nov 25, 2019

There is a copy button on the web page. Then you can copy/paste it into notepad or something similar.

@jimmys01
Copy link
Contributor

Deserialize Json failed: NoMemory

what is the command you are giving it? I suppose is an irsendAC command

In line 210 of P035.ino StaticJsonDocument<300> doc;
Make it bigger StaticJsonDocument<320> doc;
or even 350 if this doesnt work for you.
But i am curious how big is your command

@TD-er
Copy link
Member

TD-er commented Nov 26, 2019

Is it possible there to include the needed size in the log?

@jimmys01
Copy link
Contributor

I dont think so

@TD-er
Copy link
Member

TD-er commented Nov 26, 2019

Well if you know how much the message is you want to encode, you can give a rough estimate since you know the JSON structure and thus have a fixed offset.

@jimmys01
Copy link
Contributor

well I have done this and I had concluded that 300 would be enought

@s0170071
Copy link
Contributor Author

The command that I send is:
IRSENDAC,{"power":"OFF","temp":"16","protocol":"FUJITSU_AC","model":"ARREB1E","mode":"AUTO", "swingv":"OFF", "swingh":"OFF", "turbo":"OFF", "econo":"OFF", "fanspeed":"AUTO"}
Thats 174 characters. Sounds like it should have worked. In fact, the ESPEasy log error is gone although I did not touch anything since.

The log shows now:

110256038: IRTX: JSON received: {'power':'OFF','temp':'16','protocol':'FUJITSU_AC','model':'ARREB1E','mode':'AUTO', 'swingv':'OFF', 'swing
110256115: IRTX: IR Code Sent: {'power':'OFF'

Btw, this does compile of of the box:

//StaticJsonDocument<300> doc;
        DynamicJsonDocument doc(string.length());

Cant't test it right now, its too early in the morning to wake everyone by playing with the AC. Will report back.

@jimmys01
Copy link
Contributor

Encapsulate the whole JSON inbetween '

IRSENDAC,' {"power":"OFF","temp":"16","protocol":"FUJITSU_AC","model":"ARREB1E","mode":"AUTO", "swingv":"OFF", "swingh":"OFF", "turbo":"OFF", "econo":"OFF", "fanspeed":"AUTO"}'

@TD-er
Copy link
Member

TD-er commented Nov 27, 2019

Cant't test it right now, its too early in the morning to wake everyone by playing with the AC. Will report back.

You don't have a 'testing' and 'production' environment for that? ;)

@TD-er
Copy link
Member

TD-er commented Nov 27, 2019

Encapsulate the whole JSON inbetween '

Yep, see also #2724

@s0170071
Copy link
Contributor Author

You don't have a 'testing' and 'production' environment for that? ;)

I wish I had. Whenever I do a
git clone MyHouse; rm -s /tmp/wife
I get an access denied error 👎

Encapsulate the whole JSON inbetween '

I'll try but I am pretty sure it worked without. The command comes from OpenHAB via MQTT and I did not touch that part of my setup. I just updated the ESP.

@s0170071
Copy link
Contributor Author

recent changes regarding more strict parsing of parameters.

Ah, I get it.

@jimmys01
Copy link
Contributor

Check also https://www.letscontrolit.com/forum/viewtopic.php?f=2&t=6850
I have updated the posts to reflect this change also

@tonhuisman
Copy link
Contributor

This seems to have been fixed now, so can be closed.

@TD-er TD-er closed this as completed Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Build Related to building/IDE/releases Type: Bug Considered a bug
Projects
None yet
Development

No branches or pull requests

4 participants