monstrenyatko / ArduinoMqtt

MQTT client for Arduino
MIT License
72 stars 12 forks source link

Arduino MKR usage #20

Closed salvq closed 4 years ago

salvq commented 4 years ago

During compiling on MKR GSM 1400 any of examples I am getting error while compiling. Do you know why ?

Part of the code

static MqttClient *mqtt = NULL;

// ============== Object to supply system functions ============================
class System: public MqttClient::System {
public:

  unsigned long millis() const {
    return ::millis();
  }

  void yield(void) {
    ::yield();
  }
};

Compile error

error: expected class-name before '{' token

 class System: public MqttClient::System {

                                         ^

Z:\2019_11_15_First_prototype\00_final_arduinomqtt_qos1_ArduinoMqtt\00_final_arduinomqtt_qos1_ArduinoMqtt.ino: In function 'void setup()':

00_final_arduinomqtt_qos1_ArduinoMqtt:138:15: error: 'System' is not a member of 'MqttClient'

   MqttClient::System *mqttSystem = new System;

               ^~~~~~

00_final_arduinomqtt_qos1_ArduinoMqtt:138:23: error: 'mqttSystem' was not declared in this scope

   MqttClient::System *mqttSystem = new System;

                       ^~~~~~~~~~

Z:\2019_11_15_First_prototype\00_final_arduinomqtt_qos1_ArduinoMqtt\00_final_arduinomqtt_qos1_ArduinoMqtt.ino:138:23: note: suggested alternative: 'System'

   MqttClient::System *mqttSystem = new System;

                       ^~~~~~~~~~

                       System
monstrenyatko commented 4 years ago

@salvq it might be something with the compiler version is used or the library is not visible for the build system. The MqttClient::System definitely exists in MqttClient.h and public.

salvq commented 4 years ago

@monstrenyatko thank you for confirmation.

I have searched for similar libraries and found that MqttClient.h filename exist in several others libraries such as ArduinoMqttClient therefore compiler just picked different one.

Now it is working, I moved forward to the next error :)