@@ -49,25 +49,18 @@ class MqttClientInterface: public arduino::ClientConnect{
4949 virtual void poll () = 0;
5050 virtual error_t ping () = 0;
5151
52- virtual void setReceiveCallback (MqttReceiveCallback cbk) { _cbk = cbk; }
52+ // TODO make this pure virtual?
53+ virtual void setReceiveCallback (MqttReceiveCallback cbk) = 0;
5354
5455 // nullptr means generate it randomly
55- // TODO should this be pure virtual?
56- virtual void setClientId (char * client_id = nullptr ) { // TODO put this in .cpp file
57- _clientid = client_id;
58- }
56+ virtual void setClientId (const char * client_id = nullptr ) = 0;
5957
60- // TODO Will stuff
61- // TODO auth stuff, also related to MQTT 5.0
58+ // password may be null, if username is null password won't be used
59+ virtual void setAuth ( const char * username, const char * password= nullptr ) = 0;
6260
63- // TODO single callback for every incoming message or a callback for everything?
64- // FIXME make this private
65- MqttReceiveCallback _cbk;
61+ virtual void setWill (Topic willTopic, const uint8_t * will_message, size_t will_size) = 0;
6662
67- protected:
68- // TODO is it better to use the one provided from outside or copy it locally?
69- char * _clientid;
70- // char _clientid[MqttClientIdMaxLength+1];
63+ // TODO MQTT 5.0 stuff
7164};
7265
7366
@@ -90,9 +83,14 @@ class MqttClient: public MqttClientInterface {
9083 void poll () override ;
9184 error_t ping () override ;
9285
86+ void setReceiveCallback (MqttReceiveCallback cbk) override ;
87+
9388 // FIXME use a & or && parameter
9489 static void setFactory (std::function<std::unique_ptr<MqttClientInterface>()> factory);
95- void setClientId (char * client_id = nullptr ) override ;
90+ void setClientId (const char * client_id = nullptr ) override ;
91+
92+ void setAuth (const char * username, const char * password=nullptr ) override ;
93+ void setWill (Topic willTopic, const uint8_t * will_message, size_t will_size) override ;
9694protected:
9795 // static std::function<std::unique_ptr<MqttClientInterface>()> _factory;
9896
0 commit comments