Skip to content

Commit 69bcde0

Browse files
committed
fix issue with channel write not working and add helper button functions to prop class
1 parent 63bb74a commit 69bcde0

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

EmberChannelDefinition.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#ifndef EMBERCHANNELDEF_H
3535
#define EMBERCHANNELDEF_H
3636

37+
#define EMBER_BUTTON_OFF 0
38+
#define EMBER_BUTTON_ON 1
39+
#define EMBER_BUTTON_PUSH 2
40+
3741
class EmberIotProp
3842
{
3943
public:
@@ -66,6 +70,15 @@ class EmberIotProp
6670
return this->data;
6771
}
6872

73+
bool toButtonIsOn() const
74+
{
75+
return toInt() == EMBER_BUTTON_ON;
76+
}
77+
78+
bool toButtonIsPush() const {
79+
return toInt() == EMBER_BUTTON_PUSH;
80+
}
81+
6982
/**
7083
* True if the value itself has changed from the last emitted value.
7184
*/
@@ -987,7 +1000,9 @@ EmberIotUpdateCallback callbacks[EMBER_CHANNEL_COUNT] = {
9871000
#endif
9881001
};
9891002

990-
#define EMBER_CHANNEL_CB(channel) \
991-
void ember_channel_cb_##channel (const EmberIotProp &prop)
1003+
// Macro indirection for forcing expansion, so users are able to use macros as a parameter to EMBER_CHANNEL_CB
1004+
#define EMBER_CH_CB_IN(x) void ember_channel_cb_##x (const EmberIotProp &prop)
1005+
#define EMBER_CH_CB_IN_INDIR(x) EMBER_CH_CB_IN(x)
1006+
#define EMBER_CHANNEL_CB(x) EMBER_CH_CB_IN_INDIR(x)
9921007

9931008
#endif

EmberIot.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,10 @@
3838
#include <EmberIotUtil.h>
3939
#include <WithSecureClient.h>
4040
#include <EmberIotAuth.h>
41-
#include <EmberIotShared.h>
42-
#include <EmberIotShared.h>
4341
#include <EmberIotStream.h>
4442
#include <time.h>
4543

4644
#define UPDATE_LAST_SEEN_INTERVAL 120000
47-
#define EMBER_BUTTON_OFF 0
48-
#define EMBER_BUTTON_ON 1
49-
#define EMBER_BUTTON_PUSH 2
5045

5146
/**
5247
* @param dbUrl Realtime database URL, without protocol and slashes at the end. Example value: my-rtdb.firebaseio.com
@@ -239,7 +234,7 @@ class EmberIot : WithSecureClient
239234
*/
240235
void channelWrite(uint8_t channel, const char* value)
241236
{
242-
if (!checkChannelChanged(updateDataByChannel[channel], value))
237+
if (hasUpdateByChannel[channel] && !checkChannelChanged(updateDataByChannel[channel], value))
243238
{
244239
return;
245240
}
@@ -366,6 +361,7 @@ class EmberIot : WithSecureClient
366361
default:
367362
{
368363
channelWrite(job->dataChannel, job->value);
364+
snprintf(writtenData, sizeof(writtenData), "%s", job->value);
369365
}
370366
}
371367

EmberIotNotifications.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ class FCMEmberNotifications
197197
return;
198198
}
199199

200-
if (!FirePropUtil::isTimeInitialized() || clientPtr == nullptr)
200+
201+
if (WiFi.status() != WL_CONNECTED || !FirePropUtil::isTimeInitialized() || clientPtr == nullptr)
201202
{
202203
return;
203204
}
@@ -393,6 +394,7 @@ class FCMEmberNotifications
393394
#endif
394395

395396
HTTP_LOGN("Send pending notifications.");
397+
unsigned long timeCounter = 0;
396398

397399
EmberIotNotification notif = notificationQueue[currentNotification-1];
398400

@@ -503,7 +505,7 @@ class FCMEmberNotifications
503505

504506
if (HTTP_UTIL::isSuccess(responseStatus))
505507
{
506-
HTTP_LOGN("Notification sent successfully.");
508+
HTTP_LOGF("Notification sent successfully, time taken: %lu\n", millis() - timeCounter);
507509
currentNotification--;
508510
}
509511
else

0 commit comments

Comments
 (0)