Skip to content

Commit 45d819c

Browse files
committed
send network data to cloud
1 parent 0ce691b commit 45d819c

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/ArduinoIoTCloudDevice.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ _state{State::Init},
2828
_attachAttempt(0, 0),
2929
_propertyContainer(),
3030
_propertyContainerIndex(0),
31+
_connectionHandler(nullptr),
3132
_attached(false),
3233
_registered(false) {
3334
}
3435

35-
void ArduinoCloudDevice::begin() {
36+
void ArduinoCloudDevice::begin(ConnectionHandler *connectionHandler) {
3637
_attachAttempt.begin(AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms,
3738
AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms);
39+
_connectionHandler = connectionHandler;
3840
}
3941

4042
void ArduinoCloudDevice::update() {
@@ -109,6 +111,13 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleSendCapabilities() {
109111
DeviceBeginCmd deviceBegin = { DeviceBeginCmdId, AIOT_CONFIG_LIB_VERSION };
110112
deliver(reinterpret_cast<Message*>(&deviceBegin));
111113

114+
/* Send Network Configuration */
115+
if(_connectionHandler != nullptr){
116+
DeviceNetConfigCmdUp deviceNetConfig = { DeviceNetConfigCmdUpId };
117+
_connectionHandler->getSetting(deviceNetConfig.params );
118+
deliver(reinterpret_cast<Message*>(&deviceNetConfig));
119+
}
120+
112121
/* Subscribe to device topic to request */
113122
ThingBeginCmd thingBegin = { ThingBeginCmdId };
114123
deliver(reinterpret_cast<Message*>(&thingBegin));

src/ArduinoIoTCloudDevice.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <Arduino_TimedAttempt.h>
1919
#include "interfaces/CloudProcess.h"
2020
#include "property/PropertyContainer.h"
21+
#include <Arduino_ConnectionHandler.h>
2122

2223
/******************************************************************************
2324
* CLASS DECLARATION
@@ -30,7 +31,7 @@ class ArduinoCloudDevice : public CloudProcess {
3031
virtual void update() override;
3132
virtual void handleMessage(Message* m) override;
3233

33-
virtual void begin();
34+
virtual void begin(ConnectionHandler *connectionHandler);
3435
virtual int connected();
3536

3637
inline PropertyContainer &getPropertyContainer() {
@@ -57,6 +58,7 @@ class ArduinoCloudDevice : public CloudProcess {
5758
CommandId _command;
5859
TimedAttempt _attachAttempt;
5960
PropertyContainer _propertyContainer;
61+
ConnectionHandler *_connectionHandler;
6062
unsigned int _propertyContainerIndex;
6163
bool _attached;
6264
bool _registered;

src/ArduinoIoTCloudNotecard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int ArduinoIoTCloudNotecard::begin(ConnectionHandler &connection_, int interrupt
104104

105105
// Configure the Device and Thing property containers
106106
_thing.begin();
107-
_device.begin();
107+
_device.begin(_connection);
108108

109109
return 1; // (true -> success)
110110
}

src/ArduinoIoTCloudTCP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
165165
_messageTopicIn = getTopic_messagein();
166166

167167
_thing.begin();
168-
_device.begin();
168+
_device.begin(_connection);
169169

170170
#if OTA_ENABLED && !defined(OFFLOADED_DOWNLOAD)
171171
_ota.setClient(&_otaClient);

0 commit comments

Comments
 (0)