From c7ce0d1a2fe80cfa3fc991817d2ef473785dc312 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 28 May 2021 08:52:10 +0200 Subject: [PATCH 1/2] Use device id for defining all topic names if no thing id is set. This is a first step into removing thing-id dependency from all cloud sketches. --- src/ArduinoIoTCloudTCP.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ArduinoIoTCloudTCP.h b/src/ArduinoIoTCloudTCP.h index f29aafde7..6d0392148 100644 --- a/src/ArduinoIoTCloudTCP.h +++ b/src/ArduinoIoTCloudTCP.h @@ -132,10 +132,10 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass bool _ota_req; #endif /* OTA_ENABLED */ - inline String getTopic_shadowout() { return ( getThingId().length() == 0) ? String("") : String("/a/t/" + getThingId() + "/shadow/o"); } - inline String getTopic_shadowin () { return ( getThingId().length() == 0) ? String("") : String("/a/t/" + getThingId() + "/shadow/i"); } - inline String getTopic_dataout () { return ( getThingId().length() == 0) ? String("/a/d/" + getDeviceId() + "/e/o") : String("/a/t/" + getThingId() + "/e/o"); } - inline String getTopic_datain () { return ( getThingId().length() == 0) ? String("/a/d/" + getDeviceId() + "/e/i") : String("/a/t/" + getThingId() + "/e/i"); } + inline String getTopic_shadowout() { return ( getThingId().length() == 0) ? String("/a/d/" + getDeviceId() + "/shadow/o") : String("/a/t/" + getThingId() + "/shadow/o"); } + inline String getTopic_shadowin () { return ( getThingId().length() == 0) ? String("/a/d/" + getDeviceId() + "/shadow/i") : String("/a/t/" + getThingId() + "/shadow/i"); } + inline String getTopic_dataout () { return ( getThingId().length() == 0) ? String("/a/d/" + getDeviceId() + "/e/o") : String("/a/t/" + getThingId() + "/e/o"); } + inline String getTopic_datain () { return ( getThingId().length() == 0) ? String("/a/d/" + getDeviceId() + "/e/i") : String("/a/t/" + getThingId() + "/e/i"); } State handle_ConnectPhy(); State handle_SyncTime(); From 839328781e81afe3647bbc7cdf63cc6ed7210377 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 28 May 2021 08:54:49 +0200 Subject: [PATCH 2/2] Mark functions setting/getting the thing id as deprecated. --- src/ArduinoIoTCloud.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArduinoIoTCloud.h b/src/ArduinoIoTCloud.h index 0130e3efc..9d34f1915 100644 --- a/src/ArduinoIoTCloud.h +++ b/src/ArduinoIoTCloud.h @@ -89,8 +89,8 @@ class ArduinoIoTCloudClass void push(); bool setTimestamp(String const & prop_name, unsigned long const timestamp); - inline void setThingId (String const thing_id) { _thing_id = thing_id; }; - inline String & getThingId () { return _thing_id; }; + inline void setThingId (String const thing_id) { _thing_id = thing_id; } __attribute__((deprecated("It is no longer necessary to configure a THING ID."))); + inline String & getThingId () { return _thing_id; } __attribute__((deprecated("It is no longer necessary to configure a THING ID."))); inline void setDeviceId(String const device_id) { _device_id = device_id; }; inline String & getDeviceId() { return _device_id; };