Skip to content

Commit 11e1b82

Browse files
author
Henk Courtz
committed
few bugfixes
1 parent a79b9b1 commit 11e1b82

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

lib/MQTT/MqttClient.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ void MqttClient::fromMeshCallback(const char *topic, const char *msg) {
110110

111111
milightClient->prepare(config, deviceId, groupId);
112112
milightClient->update(obj);
113-
//sometimes bulbs are missing commands regeardless repeats, send twice:
114-
//milightClient->prepare(config, deviceId, groupId);
115-
//milightClient->update(obj);
116113
}
117114
}
118115
}

lib/WebServer/MiLightHttpServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void MiLightHttpServer::handleSystemPost() {
7979
Serial.println(F("Resetting Wifi and then Restarting..."));
8080
server.send_P(200, TEXT_PLAIN, PSTR("true"));
8181

82-
delay(100);
82+
delay(100);
8383
ESP.eraseConfig();
8484
delay(100);
8585
SPIFFS.format();

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ platform = ${common.platform}
5353
framework = ${common.framework}
5454
board = d1_mini
5555
upload_speed = ${common.upload_speed}
56-
upload_port = COM7
56+
upload_port = COM9
5757
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld -D FIRMWARE_VARIANT=d1_mini
5858
extra_scripts = ${common.extra_scripts}
5959
lib_deps =

src/main.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ void onPacketSentHandler(uint8_t* packet, const MiLightRemoteConfig& config) {
6565
return;
6666
}
6767

68-
const MiLightRemoteConfig& remoteConfig = *MiLightRemoteConfig::fromType(bulbId.deviceType);
68+
const MiLightRemoteConfig& remoteConfig =
69+
*MiLightRemoteConfig::fromType(bulbId.deviceType);
6970

7071
//update the status of groups for the first UDP device
7172
if (settings.numGatewayConfigs > 0) {
@@ -75,9 +76,13 @@ void onPacketSentHandler(uint8_t* packet, const MiLightRemoteConfig& config) {
7576
Serial.println(F("onPacketSentHandler - update the status of groups for the first UDP device\r\n"));
7677
#endif
7778

78-
GroupState* groupState = stateStore->get(bulbId);
79-
groupState->patch(result);
80-
stateStore->set(bulbId, *groupState);
79+
// update state to reflect changes from this packet
80+
GroupState* groupState = stateStore->get(bulbId);
81+
82+
if (groupState != NULL) {
83+
groupState->patch(result);
84+
stateStore->set(bulbId, *groupState);
85+
}
8186

8287
if (mqttClient) {
8388

@@ -87,11 +92,12 @@ void onPacketSentHandler(uint8_t* packet, const MiLightRemoteConfig& config) {
8792
mqttClient->sendUpdate(remoteConfig, bulbId.deviceId, bulbId.groupId, output);
8893

8994
// Sends the entire state
90-
bulbStateUpdater->enqueueUpdate(bulbId, *groupState);
91-
}
92-
}
95+
if (groupState != NULL) {
96+
bulbStateUpdater->enqueueUpdate(bulbId, *groupState);
97+
}
98+
}
99+
}
93100
}
94-
95101
httpServer->handlePacketSent(packet, remoteConfig);
96102
}
97103

@@ -133,6 +139,8 @@ void handleListen() {
133139
#endif
134140
return;
135141
}
142+
143+
// update state to reflect this packet
136144
onPacketSentHandler(readPacket, *remoteConfig);
137145
}
138146
}

0 commit comments

Comments
 (0)