mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 11:02:12 +01:00
treewide: fix warnings
This commit is contained in:
parent
60f8c629bf
commit
82afcbedc0
5 changed files with 43 additions and 18 deletions
|
|
@ -372,7 +372,6 @@ bool ShadeConfigFile::getAppVersion(appver_t &ver) {
|
||||||
char app[15];
|
char app[15];
|
||||||
if(!LittleFS.exists("/appversion")) return false;
|
if(!LittleFS.exists("/appversion")) return false;
|
||||||
File f = LittleFS.open("/appversion", "r");
|
File f = LittleFS.open("/appversion", "r");
|
||||||
size_t fsize = f.size();
|
|
||||||
memset(app, 0x00, sizeof(app));
|
memset(app, 0x00, sizeof(app));
|
||||||
f.read((uint8_t *)app, sizeof(app) - 1);
|
f.read((uint8_t *)app, sizeof(app) - 1);
|
||||||
f.close();
|
f.close();
|
||||||
|
|
|
||||||
2
SSDP.cpp
2
SSDP.cpp
|
|
@ -133,7 +133,7 @@ void UPNPDeviceType::setChipId(uint32_t chipId) {
|
||||||
(uint16_t)((chipId >> 8) & 0xff),
|
(uint16_t)((chipId >> 8) & 0xff),
|
||||||
(uint16_t)chipId & 0xff);
|
(uint16_t)chipId & 0xff);
|
||||||
}
|
}
|
||||||
SSDPClass::SSDPClass():sendQueue{NULL} {}
|
SSDPClass::SSDPClass():sendQueue{false, INADDR_NONE, 0, nullptr, false, 0, ""} {}
|
||||||
SSDPClass::~SSDPClass() { end(); }
|
SSDPClass::~SSDPClass() { end(); }
|
||||||
bool SSDPClass::begin() {
|
bool SSDPClass::begin() {
|
||||||
for(int i = 0; i < SSDP_QUEUE_SIZE; i++) {
|
for(int i = 0; i < SSDP_QUEUE_SIZE; i++) {
|
||||||
|
|
|
||||||
29
Somfy.cpp
29
Somfy.cpp
|
|
@ -298,6 +298,8 @@ void somfy_frame_t::encodeFrame(byte *frame) {
|
||||||
case somfy_commands::Flag:
|
case somfy_commands::Flag:
|
||||||
frame[0] = 142;
|
frame[0] = 142;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -317,6 +319,8 @@ void somfy_frame_t::encodeFrame(byte *frame) {
|
||||||
frame[8] = 0;
|
frame[8] = 0;
|
||||||
frame[9] = 25;
|
frame[9] = 25;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
byte checksum = 0;
|
byte checksum = 0;
|
||||||
|
|
@ -1114,6 +1118,8 @@ void SomfyShade::processWaitingFrame() {
|
||||||
Serial.println(" repeats");
|
Serial.println(" repeats");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1136,7 +1142,6 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
|
||||||
const uint64_t curTime = millis();
|
const uint64_t curTime = millis();
|
||||||
this->lastFrame.copy(frame);
|
this->lastFrame.copy(frame);
|
||||||
int8_t dir = 0;
|
int8_t dir = 0;
|
||||||
int8_t tiltDir = 0;
|
|
||||||
this->moveStart = this->tiltStart = curTime;
|
this->moveStart = this->tiltStart = curTime;
|
||||||
this->startPos = this->currentPos;
|
this->startPos = this->currentPos;
|
||||||
this->startTiltPos = this->currentTiltPos;
|
this->startTiltPos = this->currentTiltPos;
|
||||||
|
|
@ -1514,7 +1519,6 @@ void SomfyShade::sendTiltCommand(somfy_commands cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SomfyShade::moveToTiltTarget(float target) {
|
void SomfyShade::moveToTiltTarget(float target) {
|
||||||
int8_t newDir = 0;
|
|
||||||
somfy_commands cmd = somfy_commands::My;
|
somfy_commands cmd = somfy_commands::My;
|
||||||
if(target < this->currentTiltPos)
|
if(target < this->currentTiltPos)
|
||||||
cmd = somfy_commands::Up;
|
cmd = somfy_commands::Up;
|
||||||
|
|
@ -1539,7 +1543,6 @@ void SomfyShade::moveToTiltTarget(float target) {
|
||||||
this->settingTiltPos = true;
|
this->settingTiltPos = true;
|
||||||
}
|
}
|
||||||
void SomfyShade::moveToTarget(float pos, float tilt) {
|
void SomfyShade::moveToTarget(float pos, float tilt) {
|
||||||
int8_t newDir = 0;
|
|
||||||
somfy_commands cmd = somfy_commands::My;
|
somfy_commands cmd = somfy_commands::My;
|
||||||
if(pos < this->currentPos)
|
if(pos < this->currentPos)
|
||||||
cmd = somfy_commands::Up;
|
cmd = somfy_commands::Up;
|
||||||
|
|
@ -1732,7 +1735,6 @@ void SomfyShadeController::publish() {
|
||||||
mqtt.publish("shades", arr);
|
mqtt.publish("shades", arr);
|
||||||
}
|
}
|
||||||
uint8_t SomfyShadeController::getNextShadeId() {
|
uint8_t SomfyShadeController::getNextShadeId() {
|
||||||
uint8_t nextId = 0;
|
|
||||||
// There is no shortcut for this since the deletion of
|
// There is no shortcut for this since the deletion of
|
||||||
// a shade in the middle makes all of this very difficult.
|
// a shade in the middle makes all of this very difficult.
|
||||||
for(uint8_t i = 1; i < SOMFY_MAX_SHADES - 1; i++) {
|
for(uint8_t i = 1; i < SOMFY_MAX_SHADES - 1; i++) {
|
||||||
|
|
@ -1972,7 +1974,7 @@ bool SomfyShadeController::toJSON(JsonArray &arr) {
|
||||||
}
|
}
|
||||||
void SomfyShadeController::loop() {
|
void SomfyShadeController::loop() {
|
||||||
this->transceiver.loop();
|
this->transceiver.loop();
|
||||||
for(uint8_t i; i < SOMFY_MAX_SHADES; i++) {
|
for(uint8_t i = 0; i < SOMFY_MAX_SHADES; i++) {
|
||||||
if(this->shades[i].getShadeId() != 255) this->shades[i].checkMovement();
|
if(this->shades[i].getShadeId() != 255) this->shades[i].checkMovement();
|
||||||
}
|
}
|
||||||
// Only commit the file once per second.
|
// Only commit the file once per second.
|
||||||
|
|
@ -2004,17 +2006,16 @@ static const uint32_t tempo_if_gap = 30415; // Gap between frames
|
||||||
|
|
||||||
|
|
||||||
static int16_t bitMin = SYMBOL * TOLERANCE_MIN;
|
static int16_t bitMin = SYMBOL * TOLERANCE_MIN;
|
||||||
static uint16_t timing_index = 0;
|
|
||||||
static somfy_rx_t somfy_rx;
|
static somfy_rx_t somfy_rx;
|
||||||
static somfy_rx_queue_t rx_queue;
|
static somfy_rx_queue_t rx_queue;
|
||||||
|
|
||||||
bool somfy_tx_queue_t::pop(somfy_tx_t *tx) {
|
bool somfy_tx_queue_t::pop(somfy_tx_t *tx) {
|
||||||
// Read the oldest index.
|
// Read the oldest index.
|
||||||
for(uint8_t i = MAX_TX_BUFFER - 1; i >= 0; i--) {
|
for(int8_t i = MAX_TX_BUFFER - 1; i >= 0; i--) {
|
||||||
if(this->index[i] < MAX_TX_BUFFER) {
|
if(this->index[i] < MAX_TX_BUFFER) {
|
||||||
uint8_t ndx = this->index[i];
|
uint8_t ndx = this->index[i];
|
||||||
memcpy(tx, &this->items[ndx], sizeof(somfy_tx_t));
|
memcpy(tx, &this->items[ndx], sizeof(somfy_tx_t));
|
||||||
memset(&this->items[ndx], 0x00, sizeof(somfy_tx_t));
|
this->items[ndx].clear();
|
||||||
this->length--;
|
this->length--;
|
||||||
this->index[i] = 255;
|
this->index[i] = 255;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2027,7 +2028,8 @@ bool somfy_tx_queue_t::push(uint32_t await, somfy_commands cmd, uint8_t repeats)
|
||||||
uint8_t ndx = this->index[MAX_TX_BUFFER - 1];
|
uint8_t ndx = this->index[MAX_TX_BUFFER - 1];
|
||||||
this->index[MAX_TX_BUFFER - 1] = 255;
|
this->index[MAX_TX_BUFFER - 1] = 255;
|
||||||
this->length = MAX_TX_BUFFER - 1;
|
this->length = MAX_TX_BUFFER - 1;
|
||||||
if(ndx < MAX_TX_BUFFER) memset(&this->items[ndx], 0x00, sizeof(somfy_tx_t));
|
if (ndx < MAX_TX_BUFFER)
|
||||||
|
this->items[ndx].clear();
|
||||||
}
|
}
|
||||||
// Place the command in the first empty slot. Empty slots are those
|
// Place the command in the first empty slot. Empty slots are those
|
||||||
// with a millis of 0. We will shift the indexes right so that this
|
// with a millis of 0. We will shift the indexes right so that this
|
||||||
|
|
@ -2050,7 +2052,8 @@ bool somfy_tx_queue_t::push(uint32_t await, somfy_commands cmd, uint8_t repeats)
|
||||||
}
|
}
|
||||||
void somfy_rx_queue_t::init() {
|
void somfy_rx_queue_t::init() {
|
||||||
Serial.println("Initializing RX Queue");
|
Serial.println("Initializing RX Queue");
|
||||||
memset(&this->items[0], 0x00, sizeof(somfy_rx_t) * MAX_RX_BUFFER);
|
for (uint8_t i = 0; i < MAX_RX_BUFFER; i++)
|
||||||
|
this->items[i].clear();
|
||||||
memset(&this->index[0], 0xFF, MAX_RX_BUFFER);
|
memset(&this->index[0], 0xFF, MAX_RX_BUFFER);
|
||||||
this->length = 0;
|
this->length = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2058,11 +2061,11 @@ void somfy_rx_queue_t::init() {
|
||||||
bool somfy_rx_queue_t::pop(somfy_rx_t *rx) {
|
bool somfy_rx_queue_t::pop(somfy_rx_t *rx) {
|
||||||
// Read off the data from the oldest index.
|
// Read off the data from the oldest index.
|
||||||
//Serial.println("Popping RX Queue");
|
//Serial.println("Popping RX Queue");
|
||||||
for(uint8_t i = MAX_RX_BUFFER - 1; i >= 0; i--) {
|
for(int8_t i = MAX_RX_BUFFER - 1; i >= 0; i--) {
|
||||||
if(this->index[i] < MAX_RX_BUFFER) {
|
if(this->index[i] < MAX_RX_BUFFER) {
|
||||||
uint8_t ndx = this->index[i];
|
uint8_t ndx = this->index[i];
|
||||||
memcpy(rx, &this->items[this->index[i]], sizeof(somfy_rx_t));
|
memcpy(rx, &this->items[this->index[i]], sizeof(somfy_rx_t));
|
||||||
memset(&this->items[ndx], 0x00, sizeof(somfy_rx_t));
|
this->items[ndx].clear();
|
||||||
this->length--;
|
this->length--;
|
||||||
this->index[i] = 255;
|
this->index[i] = 255;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2304,7 +2307,7 @@ void Transceiver::emitFrame(somfy_frame_t *frame, somfy_rx_t *rx) {
|
||||||
evt.appendMessage(buf);
|
evt.appendMessage(buf);
|
||||||
snprintf(buf, sizeof(buf), "\"rcode\":%d,", frame->rollingCode);
|
snprintf(buf, sizeof(buf), "\"rcode\":%d,", frame->rollingCode);
|
||||||
evt.appendMessage(buf);
|
evt.appendMessage(buf);
|
||||||
snprintf(buf, sizeof(buf), "\"command\":\"%s\",", translateSomfyCommand(frame->cmd));
|
snprintf(buf, sizeof(buf), "\"command\":\"%s\",", translateSomfyCommand(frame->cmd).c_str());
|
||||||
evt.appendMessage(buf);
|
evt.appendMessage(buf);
|
||||||
snprintf(buf, sizeof(buf), "\"rssi\":%d,", frame->rssi);
|
snprintf(buf, sizeof(buf), "\"rssi\":%d,", frame->rssi);
|
||||||
evt.appendMessage(buf);
|
evt.appendMessage(buf);
|
||||||
|
|
|
||||||
27
Somfy.h
27
Somfy.h
|
|
@ -69,6 +69,17 @@ typedef enum {
|
||||||
} t_status;
|
} t_status;
|
||||||
|
|
||||||
struct somfy_rx_t {
|
struct somfy_rx_t {
|
||||||
|
void clear() {
|
||||||
|
this->status = t_status::waiting_synchro;
|
||||||
|
this->bit_length = 56;
|
||||||
|
this->cpt_synchro_hw = 0;
|
||||||
|
this->cpt_bits = 0;
|
||||||
|
this->previous_bit = 0;
|
||||||
|
this->waiting_half_symbol = false;
|
||||||
|
memset(this->payload, 0, sizeof(this->payload));
|
||||||
|
memset(this->pulses, 0, sizeof(this->pulses));
|
||||||
|
this->pulseCount = 0;
|
||||||
|
}
|
||||||
t_status status;
|
t_status status;
|
||||||
uint8_t bit_length = 56;
|
uint8_t bit_length = 56;
|
||||||
uint8_t cpt_synchro_hw = 0;
|
uint8_t cpt_synchro_hw = 0;
|
||||||
|
|
@ -91,13 +102,25 @@ struct somfy_rx_queue_t {
|
||||||
bool pop(somfy_rx_t *rx);
|
bool pop(somfy_rx_t *rx);
|
||||||
};
|
};
|
||||||
struct somfy_tx_t {
|
struct somfy_tx_t {
|
||||||
|
void clear() {
|
||||||
|
this->await = 0;
|
||||||
|
this->cmd = somfy_commands::Unknown0;
|
||||||
|
this->repeats = 0;
|
||||||
|
}
|
||||||
uint32_t await = 0;
|
uint32_t await = 0;
|
||||||
somfy_commands cmd;
|
somfy_commands cmd;
|
||||||
uint8_t repeats;
|
uint8_t repeats;
|
||||||
};
|
};
|
||||||
struct somfy_tx_queue_t {
|
struct somfy_tx_queue_t {
|
||||||
somfy_tx_queue_t() { memset(this->index, 255, MAX_TX_BUFFER); memset(&this->items[0], 0x00, sizeof(somfy_tx_queue_t) * MAX_TX_BUFFER); }
|
somfy_tx_queue_t() {
|
||||||
void clear() { memset(&this->index[0], 255, MAX_TX_BUFFER); memset(&this->items[0], 0x00, sizeof(somfy_tx_queue_t) * MAX_TX_BUFFER); }
|
this->clear();
|
||||||
|
}
|
||||||
|
void clear() {
|
||||||
|
for (uint8_t i = 0; i < MAX_TX_BUFFER; i++) {
|
||||||
|
this->index[i] = 255;
|
||||||
|
this->items[i].clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
uint8_t length = 0;
|
uint8_t length = 0;
|
||||||
uint8_t index[MAX_TX_BUFFER];
|
uint8_t index[MAX_TX_BUFFER];
|
||||||
somfy_tx_t items[MAX_TX_BUFFER];
|
somfy_tx_t items[MAX_TX_BUFFER];
|
||||||
|
|
|
||||||
2
Web.cpp
2
Web.cpp
|
|
@ -229,7 +229,7 @@ void Web::begin() {
|
||||||
Serial.print("Received:");
|
Serial.print("Received:");
|
||||||
Serial.println(apiServer.arg("plain"));
|
Serial.println(apiServer.arg("plain"));
|
||||||
// Send the command to the shade.
|
// Send the command to the shade.
|
||||||
if(target >= 0 && target <= 100)
|
if(target <= 100)
|
||||||
shade->moveToTiltTarget(target);
|
shade->moveToTiltTarget(target);
|
||||||
else
|
else
|
||||||
shade->sendTiltCommand(command);
|
shade->sendTiltCommand(command);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue