@@ -49,25 +49,18 @@ class MqttClientInterface: public arduino::ClientConnect{
49
49
virtual void poll () = 0;
50
50
virtual error_t ping () = 0;
51
51
52
- virtual void setReceiveCallback (MqttReceiveCallback cbk) { _cbk = cbk; }
52
+ // TODO make this pure virtual?
53
+ virtual void setReceiveCallback (MqttReceiveCallback cbk) = 0;
53
54
54
55
// 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;
59
57
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;
62
60
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;
66
62
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
71
64
};
72
65
73
66
@@ -90,9 +83,14 @@ class MqttClient: public MqttClientInterface {
90
83
void poll () override ;
91
84
error_t ping () override ;
92
85
86
+ void setReceiveCallback (MqttReceiveCallback cbk) override ;
87
+
93
88
// FIXME use a & or && parameter
94
89
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 ;
96
94
protected:
97
95
// static std::function<std::unique_ptr<MqttClientInterface>()> _factory;
98
96
0 commit comments