@@ -16,7 +16,8 @@ using Topic = const char* const;
16
16
17
17
// for incoming published messages
18
18
// 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&)>;
20
21
21
22
// TODO define callback for mqtt events. one should be the default, but the user can always change it
22
23
@@ -31,7 +32,8 @@ enum MqttQos: uint8_t {
31
32
// TODO define mqtt version
32
33
33
34
constexpr MqttQos QosDefault = MqttQos0;
34
- constexpr size_t MqttClientIdMaxLength = 256 ;
35
+ // constexpr size_t MqttClientIdMaxLength = 256;
36
+ constexpr size_t MqttClientIdMaxLength = 40 ;
35
37
36
38
// TODO make it possible to generate the client id if none is provided during connect
37
39
// + should it be performed by the derived class or by the interface?
@@ -57,13 +59,15 @@ class MqttClientInterface: public arduino::ClientConnect{
57
59
58
60
// TODO Will stuff
59
61
// 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
+
60
67
protected:
61
68
// TODO is it better to use the one provided from outside or copy it locally?
62
69
char * _clientid;
63
70
// char _clientid[MqttClientIdMaxLength+1];
64
-
65
- // TODO single callback for every incoming message or a callback for everything?
66
- MqttReceiveCallback _cbk;
67
71
};
68
72
69
73
@@ -86,15 +90,11 @@ class MqttClient: public MqttClientInterface {
86
90
void poll () override ;
87
91
error_t ping () override ;
88
92
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);
95
95
void setClientId (char * client_id = nullptr ) override ;
96
96
protected:
97
- static std::function<std::unique_ptr<MqttClientInterface>()> * _factory;
97
+ // static std::function<std::unique_ptr<MqttClientInterface>()> _factory;
98
98
99
99
std::unique_ptr<MqttClientInterface> impl;
100
100
private:
0 commit comments