github: enable warnings

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
Álvaro Fernández Rojas 2023-05-31 15:11:31 +02:00
parent 5f183bfc42
commit 5b0e19438a
10 changed files with 26 additions and 20 deletions

View file

@ -123,7 +123,7 @@ jobs:
- name: Build ${{ matrix.name }} - name: Build ${{ matrix.name }}
run: | run: |
mkdir -p build mkdir -p build
arduino-cli compile --clean --output-dir build --fqbn ${{ matrix.fqbn }} ./SomfyController arduino-cli compile --clean --output-dir build --fqbn ${{ matrix.fqbn }} --warnings default ./SomfyController
- name: ${{ matrix.name }} Image - name: ${{ matrix.name }} Image
run: | run: |

View file

@ -58,7 +58,10 @@ bool ConfigFile::seekRecordByIndex(uint16_t ndx) {
if(!this->file) { if(!this->file) {
return false; return false;
} }
if(((this->header.recordSize * ndx) + this->header.length) > this->file.size()) return false; if(((this->header.recordSize * ndx) + this->header.length) > this->file.size()) {
return false;
}
return true;
} }
bool ConfigFile::readString(char *buff, size_t len) { bool ConfigFile::readString(char *buff, size_t len) {
if(!this->file) return false; if(!this->file) return false;

View file

@ -8,7 +8,7 @@
#define CFG_REC_END '\n' #define CFG_REC_END '\n'
#define CFG_TOK_NONE 0x00 #define CFG_TOK_NONE 0x00
typedef struct config_header_t { struct config_header_t {
uint8_t version = 1; uint8_t version = 1;
uint16_t recordSize = 0; uint16_t recordSize = 0;
uint16_t records = 0; uint16_t records = 0;
@ -63,4 +63,4 @@ class ShadeConfigFile : public ConfigFile {
bool seekRecordById(uint8_t id); bool seekRecordById(uint8_t id);
bool validate(); bool validate();
}; };
#endif; #endif

View file

@ -33,6 +33,7 @@ bool BaseSettings::saveFile(const char *filename) {
this->toJSON(obj); this->toJSON(obj);
serializeJson(doc, file); serializeJson(doc, file);
file.close(); file.close();
return true;
} }
bool BaseSettings::parseValueString(JsonObject &obj, const char *prop, char *pdest, size_t size) { bool BaseSettings::parseValueString(JsonObject &obj, const char *prop, char *pdest, size_t size) {
if(obj.containsKey(prop)) strlcpy(pdest, obj[prop], size); if(obj.containsKey(prop)) strlcpy(pdest, obj[prop], size);
@ -272,8 +273,8 @@ String WifiSettings::mapEncryptionType(int type) {
return "WPA/WPA2/PSK"; return "WPA/WPA2/PSK";
case WIFI_AUTH_WPA2_ENTERPRISE: case WIFI_AUTH_WPA2_ENTERPRISE:
return "WPA/Enterprise"; return "WPA/Enterprise";
return "Unknown";
} }
return "Unknown";
} }
void WifiSettings::print() { void WifiSettings::print() {
Serial.println("WIFI Settings"); Serial.println("WIFI Settings");

View file

@ -314,11 +314,12 @@ bool Network::connect() {
return this->connectWiFi(); return this->connectWiFi();
} }
int Network::getStrengthByMac(const char *macAddr) { int Network::getStrengthByMac(const char *macAddr) {
int strength = -100;
int n = WiFi.scanNetworks(true); int n = WiFi.scanNetworks(true);
for(int i = 0; i < n; i++) { for(int i = 0; i < n; i++) {
if(WiFi.BSSIDstr(i).compareTo(macAddr) == 0) return WiFi.RSSI(i); if (WiFi.BSSIDstr(i).compareTo(macAddr) == 0)
return WiFi.RSSI(i);
} }
return -100;
} }
uint32_t Network::getChipId() { uint32_t Network::getChipId() {
uint32_t chipId = 0; uint32_t chipId = 0;
@ -416,6 +417,7 @@ bool Network::openSoftAP() {
} }
yield(); yield();
} }
return true;
} }
bool Network::connected() { bool Network::connected() {
if(this->connType == conn_types::unset) return false; if(this->connType == conn_types::unset) return false;

View file

@ -728,7 +728,7 @@ void SSDPClass::_processRequest(AsyncUDPPacket &p) {
this->_printPacket(&pkt); this->_printPacket(&pkt);
DEBUG_SSDP.println("--------------- ROOT ---------------------"); DEBUG_SSDP.println("--------------- ROOT ---------------------");
#endif #endif
if(pkt.method == MULTICAST) if(pkt.type == MULTICAST)
this->_addToSendQueue(IPAddress(SSDP_MULTICAST_ADDR), SSDP_PORT, dev, pkt.st, pkt.mx, false); this->_addToSendQueue(IPAddress(SSDP_MULTICAST_ADDR), SSDP_PORT, dev, pkt.st, pkt.mx, false);
else else
this->_sendResponse(p.remoteIP(), p.remotePort(), dev, pkt.st, false); this->_sendResponse(p.remoteIP(), p.remotePort(), dev, pkt.st, false);
@ -746,7 +746,7 @@ void SSDPClass::_processRequest(AsyncUDPPacket &p) {
this->_printPacket(&pkt); this->_printPacket(&pkt);
DEBUG_SSDP.println("-------------- ACCEPT --------------------"); DEBUG_SSDP.println("-------------- ACCEPT --------------------");
#endif #endif
if(pkt.method == MULTICAST) if(pkt.type == MULTICAST)
this->_addToSendQueue(IPAddress(SSDP_MULTICAST_ADDR), SSDP_PORT, dev, pkt.st, pkt.mx, useUUID); this->_addToSendQueue(IPAddress(SSDP_MULTICAST_ADDR), SSDP_PORT, dev, pkt.st, pkt.mx, useUUID);
else { else {
this->_sendResponse(p.remoteIP(), p.remotePort(), dev, pkt.st, useUUID); this->_sendResponse(p.remoteIP(), p.remotePort(), dev, pkt.st, useUUID);

4
SSDP.h
View file

@ -38,7 +38,7 @@ typedef enum {
MULTICAST, MULTICAST,
UNICAST UNICAST
} ssdp_req_types_t; } ssdp_req_types_t;
typedef struct ssdp_packet_t { struct ssdp_packet_t {
bool pending; bool pending;
unsigned long recvd; unsigned long recvd;
ssdp_method_t method; ssdp_method_t method;
@ -91,7 +91,7 @@ class UPNPDeviceType {
char *getUSN(const char *st); char *getUSN(const char *st);
void setChipId(uint32_t chipId); void setChipId(uint32_t chipId);
}; };
typedef struct ssdp_response_t { struct ssdp_response_t {
bool waiting; bool waiting;
IPAddress address; IPAddress address;
uint16_t port; uint16_t port;

View file

@ -6,7 +6,7 @@
#define SOCK_MAX_ROOMS 1 #define SOCK_MAX_ROOMS 1
#define ROOM_EMIT_FRAME 0 #define ROOM_EMIT_FRAME 0
typedef struct room_t { struct room_t {
uint8_t clients[5] = {255, 255, 255, 255}; uint8_t clients[5] = {255, 255, 255, 255};
uint8_t activeClients(); uint8_t activeClients();
bool isJoined(uint8_t num); bool isJoined(uint8_t num);

14
Somfy.h
View file

@ -4,7 +4,7 @@
#define SOMFY_MAX_SHADES 32 #define SOMFY_MAX_SHADES 32
#define SOMFY_MAX_LINKED_REMOTES 7 #define SOMFY_MAX_LINKED_REMOTES 7
typedef struct appver_t { struct appver_t {
uint8_t major; uint8_t major;
uint8_t minor; uint8_t minor;
uint8_t build; uint8_t build;
@ -58,7 +58,7 @@ typedef enum {
complete = 2 complete = 2
} t_status; } t_status;
typedef struct somfy_rx_t { struct somfy_rx_t {
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;
@ -72,7 +72,7 @@ typedef struct somfy_rx_t {
// A simple FIFO queue to hold rx buffers. We are using // A simple FIFO queue to hold rx buffers. We are using
// a byte index to make it so we don't have to reorganize // a byte index to make it so we don't have to reorganize
// the storage each time we push or pop. // the storage each time we push or pop.
typedef struct somfy_rx_queue_t { struct somfy_rx_queue_t {
void init(); void init();
uint8_t length = 0; uint8_t length = 0;
uint8_t index[MAX_RX_BUFFER]; uint8_t index[MAX_RX_BUFFER];
@ -80,12 +80,12 @@ typedef struct somfy_rx_queue_t {
//void push(somfy_rx_t *rx); //void push(somfy_rx_t *rx);
bool pop(somfy_rx_t *rx); bool pop(somfy_rx_t *rx);
}; };
typedef struct somfy_tx_t { struct somfy_tx_t {
uint32_t await = 0; uint32_t await = 0;
somfy_commands cmd; somfy_commands cmd;
uint8_t repeats; uint8_t repeats;
}; };
typedef 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() { memset(this->index, 255, MAX_TX_BUFFER); memset(&this->items[0], 0x00, sizeof(somfy_tx_queue_t) * MAX_TX_BUFFER); }
void clear() { memset(&this->index[0], 255, MAX_TX_BUFFER); memset(&this->items[0], 0x00, sizeof(somfy_tx_queue_t) * MAX_TX_BUFFER); } void clear() { memset(&this->index[0], 255, MAX_TX_BUFFER); memset(&this->items[0], 0x00, sizeof(somfy_tx_queue_t) * MAX_TX_BUFFER); }
uint8_t length = 0; uint8_t length = 0;
@ -98,7 +98,7 @@ typedef struct somfy_tx_queue_t {
enum class somfy_flags_t : byte { enum class somfy_flags_t : byte {
Sun = 1 Sun = 1
}; };
typedef struct somfy_frame_t { struct somfy_frame_t {
bool valid = false; bool valid = false;
bool processed = false; bool processed = false;
radio_proto proto = radio_proto::RTS; radio_proto proto = radio_proto::RTS;
@ -209,7 +209,7 @@ class SomfyShade : public SomfyRemote {
void commitMyPosition(); void commitMyPosition();
}; };
typedef struct transceiver_config_t { struct transceiver_config_t {
bool printBuffer = false; bool printBuffer = false;
bool enabled = false; bool enabled = false;
uint8_t type = 56; // 56 or 80 bit protocol. uint8_t type = 56; // 56 or 80 bit protocol.

View file

@ -37,7 +37,7 @@ static void _rtrim(char *str) {
while(e >= 0 && (str[e] == ' ' || str[e] == '\n' || str[e] == '\r' || str[e] == '\t' || str[e] == '"')) {str[e] = '\0'; e--;} while(e >= 0 && (str[e] == ' ' || str[e] == '\n' || str[e] == '\r' || str[e] == '\t' || str[e] == '"')) {str[e] = '\0'; e--;}
} }
static void _trim(char *str) { _ltrim(str); _rtrim(str); } static void _trim(char *str) { _ltrim(str); _rtrim(str); }
typedef struct rebootDelay_t { struct rebootDelay_t {
bool reboot = false; bool reboot = false;
int rebootTime = 0; int rebootTime = 0;
bool closed = false; bool closed = false;