Browse Source

Fix some issues with 2.5 (#1565)

rules-rpn
Xose Pérez 5 years ago
parent
commit
51703f6ecf
3 changed files with 39 additions and 11 deletions
  1. +13
    -10
      code/espurna/influxdb.ino
  2. +21
    -0
      code/espurna/libs/SyncClientWrap.h
  3. +5
    -1
      code/espurna/pwm.c

+ 13
- 10
code/espurna/influxdb.ino View File

@ -9,10 +9,11 @@ Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
#if INFLUXDB_SUPPORT
#include "ESPAsyncTCP.h"
#include "SyncClient.h"
#include "libs/SyncClientWrap.h"
bool _idb_enabled = false;
SyncClient _idb_client;
SyncClientWrap * _idb_client;
// -----------------------------------------------------------------------------
@ -66,8 +67,8 @@ bool idbSend(const char * topic, const char * payload) {
bool success = false;
_idb_client.setTimeout(2);
if (_idb_client.connect((const char *) host, port)) {
_idb_client->setTimeout(2);
if (_idb_client->connect((const char *) host, (unsigned int) port)) {
char data[128];
snprintf(data, sizeof(data), "%s,device=%s value=%s", topic, getSetting("hostname").c_str(), String(payload).c_str());
@ -79,17 +80,17 @@ bool idbSend(const char * topic, const char * payload) {
getSetting("idbUsername", INFLUXDB_USERNAME).c_str(), getSetting("idbPassword", INFLUXDB_PASSWORD).c_str(),
host, port, strlen(data), data);
if (_idb_client.printf(request) > 0) {
while (_idb_client.connected() && _idb_client.available() == 0) delay(1);
while (_idb_client.available()) _idb_client.read();
if (_idb_client.connected()) _idb_client.stop();
if (_idb_client->printf(request) > 0) {
while (_idb_client->connected() && _idb_client->available() == 0) delay(1);
while (_idb_client->available()) _idb_client->read();
if (_idb_client->connected()) _idb_client->stop();
success = true;
} else {
DEBUG_MSG_P(PSTR("[INFLUXDB] Sent failed\n"));
}
_idb_client.stop();
while (_idb_client.connected()) yield();
_idb_client->stop();
while (_idb_client->connected()) yield();
} else {
DEBUG_MSG_P(PSTR("[INFLUXDB] Connection failed\n"));
@ -112,6 +113,8 @@ bool idbEnabled() {
void idbSetup() {
_idb_client = new SyncClientWrap();
_idbConfigure();
#if WEB_SUPPORT


+ 21
- 0
code/espurna/libs/SyncClientWrap.h View File

@ -0,0 +1,21 @@
/*
SyncClientWrap
Temporary wrap to fix https://github.com/me-no-dev/ESPAsyncTCP/issues/109
*/
#pragma once
#include <SyncClient.h>
class SyncClientWrap: public SyncClient {
public:
int connect(const char *host, uint16_t port);
int connect(CONST IPAddress& ip, uint16_t port) { return connect(ip, port); }
bool flush(unsigned int maxWaitMs = 0) { flush(); return true; }
bool stop(unsigned int maxWaitMs = 0) { stop(); return true; }
};

+ 5
- 1
code/espurna/pwm.c View File

@ -391,7 +391,11 @@ pwm_start(void)
pwm_state.current_set = pwm_state.next_set = *pwm;
pwm_state.current_phase = phases - 1;
ETS_FRC1_INTR_ENABLE();
RTC_REG_WRITE(FRC1_LOAD_ADDRESS, 0);
#if defined(TIMER_REG_WRITE)
TIMER_REG_WRITE(FRC1_LOAD_ADDRESS, 0);
#else
RTC_REG_WRITE(FRC1_LOAD_ADDRESS, 0);
#endif
timer->frc1_ctrl = TIMER1_DIVIDE_BY_16 | TIMER1_ENABLE_TIMER;
return;
}


Loading…
Cancel
Save