@@ -16,7 +16,8 @@ using Topic = const char* const;
1616
1717// for incoming published messages
1818// TODO double check with typename
19- using MqttReceiveCallback = std::function<void (Topic, const uint8_t [], size_t )>;
19+ // using MqttReceiveCallback = std::function<void(Topic, const uint8_t[], size_t)>;
20+ using MqttReceiveCallback = std::function<void (Topic, Stream&)>;
2021
2122// TODO define callback for mqtt events. one should be the default, but the user can always change it
2223
@@ -31,7 +32,8 @@ enum MqttQos: uint8_t {
3132// TODO define mqtt version
3233
3334constexpr MqttQos QosDefault = MqttQos0;
34- constexpr size_t MqttClientIdMaxLength = 256 ;
35+ // constexpr size_t MqttClientIdMaxLength = 256;
36+ constexpr size_t MqttClientIdMaxLength = 40 ;
3537
3638// TODO make it possible to generate the client id if none is provided during connect
3739// + should it be performed by the derived class or by the interface?
@@ -57,13 +59,15 @@ class MqttClientInterface: public arduino::ClientConnect{
5759
5860 // TODO Will stuff
5961 // TODO auth stuff, also related to MQTT 5.0
62+
63+ // TODO single callback for every incoming message or a callback for everything?
64+ // FIXME make this private
65+ MqttReceiveCallback _cbk;
66+
6067protected:
6168 // TODO is it better to use the one provided from outside or copy it locally?
6269 char * _clientid;
6370 // char _clientid[MqttClientIdMaxLength+1];
64-
65- // TODO single callback for every incoming message or a callback for everything?
66- MqttReceiveCallback _cbk;
6771};
6872
6973
@@ -86,15 +90,11 @@ class MqttClient: public MqttClientInterface {
8690 void poll () override ;
8791 error_t ping () override ;
8892
89- static void setFactory (std::function<std::unique_ptr<MqttClientInterface>()> factory) {
90- // FIXME find a better way to solve constructor call order
91- static std::function<std::unique_ptr<MqttClientInterface>()> f = factory;
92- _factory = &f;
93- }
94-
93+ // FIXME use a & or && parameter
94+ static void setFactory (std::function<std::unique_ptr<MqttClientInterface>()> factory);
9595 void setClientId (char * client_id = nullptr ) override ;
9696protected:
97- static std::function<std::unique_ptr<MqttClientInterface>()> * _factory;
97+ // static std::function<std::unique_ptr<MqttClientInterface>()> _factory;
9898
9999 std::unique_ptr<MqttClientInterface> impl;
100100private:
0 commit comments