Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into use-256dpi-mqtt-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
remuslazar committed Aug 9, 2023
2 parents d66b712 + 0c3efab commit b38610a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion firmware/lib/SiedleClient/SiedleClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void SiedleClient::bitTimerISR() {
if (bitNumber >= 0) {
auto bit = bitRead(cmd_tx_buf, bitNumber--);
digitalWrite(outputPin, !bit);
} else {
} else { // bitNumber < 0
digitalWrite(outputPin, LOW);
digitalWrite(outputCarrierPin, LOW);

Expand Down
10 changes: 9 additions & 1 deletion firmware/src/siedle-service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

void SiedleServiceClass::begin() {
lastTxMillis = 0;
lastTxCounter = 0;
siedleClient = SiedleClient(SIEDLE_A_IN, SIEDLE_TX_PIN, SIEDLE_TX_CARRIER_PIN);
siedleClient.begin();
}
Expand Down Expand Up @@ -40,11 +41,18 @@ void SiedleServiceClass::loop() {
if (doSend) {
cmd = siedleTxQueue.pop();
siedleClient.sendCmdAsync(cmd);
lastTxCmd = cmd;
}

// check if we have sent a new cmd since last run and, if so, send the cmd via MQTT
// note: the siedle client will not increment the tx counter if there were errors!
if (siedleClient.txCount > lastTxCounter) {
lastTxCounter = siedleClient.txCount;
MQTTService.sendAsync({RTCSync.getEpoch(), lastTxCmd}, sent);
}
interrupts();

if (doSend) {
MQTTService.sendAsync({RTCSync.getEpoch(), cmd}, sent);
siedleRxTxLog.push({ { RTCSync.getEpoch(), cmd }, tx });
lastTxMillis = now;
}
Expand Down
2 changes: 2 additions & 0 deletions firmware/src/siedle-service.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class SiedleServiceClass {
private:
CircularBuffer<siedle_cmd_t, SIEDLE_TX_QUEUE_LEN> siedleTxQueue;
unsigned long lastTxMillis;
unsigned int lastTxCounter;
siedle_cmd_t lastTxCmd;
};

extern SiedleServiceClass SiedleService;
Expand Down

0 comments on commit b38610a

Please sign in to comment.