-
Notifications
You must be signed in to change notification settings - Fork 132
Open
Description
The library remembers most subscriptions, for example this works fine:
void setup() {
[...]
if (!rpc.RPC_Subscribe(callbacks.cbegin(), callbacks.cend())) {
Serial.println("Failed to subscribe for RPC");
}
if (!shared_update.Shared_Attributes_Subscribe(attr_update_callback)) {
Serial.println("Failed to subscribe for shared attribute updates");
}
if (!tb.connect(THINGSBOARD_SERVER, TOKEN, THINGSBOARD_PORT)) {
Serial.println("Failed to connect");
}
}Both the RPC subscription and the attributes subscription are remembered across the (re)connect and after the connection has been made, both RPC requests and attribute updates are processed.
However, if I add an OTA subscription:
void setup() {
[...]
if (!rpc.RPC_Subscribe(callbacks.cbegin(), callbacks.cend())) {
Serial.println("Failed to subscribe for RPC");
}
if (!shared_update.Shared_Attributes_Subscribe(attr_update_callback)) {
Serial.println("Failed to subscribe for shared attribute updates");
}
if (!ota.Subscribe_Firmware_Update(ota_callback)) {
Serial.println("Failed to subscribe for OTA attribute updates");
}
if (!tb.connect(THINGSBOARD_SERVER, TOKEN, THINGSBOARD_PORT)) {
Serial.println("Failed to connect");
}
}that one doesn't work.
I have to do this OTA subscription after the connection has been made, in other words every time that I reconnect.
Doing some subscriptions only once and others every time on-connect makes the code harder to read, I would prefer to have them all in one place.
I didn't want to move the other subscriptions (RPC and attributes) to on-connect because I'm not sure if doing them multiple times will cause issues.
Metadata
Metadata
Assignees
Labels
No labels