diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 25d3d0a..74c9f3a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -123,7 +123,7 @@ jobs: - name: Build ${{ matrix.name }} run: | 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 run: | diff --git a/ConfigFile.cpp b/ConfigFile.cpp index aa27ea4..3ee691f 100644 --- a/ConfigFile.cpp +++ b/ConfigFile.cpp @@ -58,7 +58,10 @@ bool ConfigFile::seekRecordByIndex(uint16_t ndx) { if(!this->file) { 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) { if(!this->file) return false; diff --git a/ConfigFile.h b/ConfigFile.h index 2ffb292..89d0827 100644 --- a/ConfigFile.h +++ b/ConfigFile.h @@ -8,7 +8,7 @@ #define CFG_REC_END '\n' #define CFG_TOK_NONE 0x00 -typedef struct config_header_t { +struct config_header_t { uint8_t version = 1; uint16_t recordSize = 0; uint16_t records = 0; @@ -63,4 +63,4 @@ class ShadeConfigFile : public ConfigFile { bool seekRecordById(uint8_t id); bool validate(); }; -#endif; +#endif diff --git a/ConfigSettings.cpp b/ConfigSettings.cpp index 5643cb4..06a473d 100644 --- a/ConfigSettings.cpp +++ b/ConfigSettings.cpp @@ -33,6 +33,7 @@ bool BaseSettings::saveFile(const char *filename) { this->toJSON(obj); serializeJson(doc, file); file.close(); + return true; } bool BaseSettings::parseValueString(JsonObject &obj, const char *prop, char *pdest, size_t size) { if(obj.containsKey(prop)) strlcpy(pdest, obj[prop], size); @@ -272,8 +273,8 @@ String WifiSettings::mapEncryptionType(int type) { return "WPA/WPA2/PSK"; case WIFI_AUTH_WPA2_ENTERPRISE: return "WPA/Enterprise"; - return "Unknown"; } + return "Unknown"; } void WifiSettings::print() { Serial.println("WIFI Settings"); diff --git a/Network.cpp b/Network.cpp index 604395e..f5a3bb4 100644 --- a/Network.cpp +++ b/Network.cpp @@ -314,11 +314,12 @@ bool Network::connect() { return this->connectWiFi(); } int Network::getStrengthByMac(const char *macAddr) { - int strength = -100; int n = WiFi.scanNetworks(true); 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 chipId = 0; @@ -416,6 +417,7 @@ bool Network::openSoftAP() { } yield(); } + return true; } bool Network::connected() { if(this->connType == conn_types::unset) return false; diff --git a/SSDP.cpp b/SSDP.cpp index 277ec30..dc6ee3b 100644 --- a/SSDP.cpp +++ b/SSDP.cpp @@ -728,7 +728,7 @@ void SSDPClass::_processRequest(AsyncUDPPacket &p) { this->_printPacket(&pkt); DEBUG_SSDP.println("--------------- ROOT ---------------------"); #endif - if(pkt.method == MULTICAST) + if(pkt.type == MULTICAST) this->_addToSendQueue(IPAddress(SSDP_MULTICAST_ADDR), SSDP_PORT, dev, pkt.st, pkt.mx, false); else this->_sendResponse(p.remoteIP(), p.remotePort(), dev, pkt.st, false); @@ -746,7 +746,7 @@ void SSDPClass::_processRequest(AsyncUDPPacket &p) { this->_printPacket(&pkt); DEBUG_SSDP.println("-------------- ACCEPT --------------------"); #endif - if(pkt.method == MULTICAST) + if(pkt.type == MULTICAST) this->_addToSendQueue(IPAddress(SSDP_MULTICAST_ADDR), SSDP_PORT, dev, pkt.st, pkt.mx, useUUID); else { this->_sendResponse(p.remoteIP(), p.remotePort(), dev, pkt.st, useUUID); diff --git a/SSDP.h b/SSDP.h index 9ba2eff..061c57a 100644 --- a/SSDP.h +++ b/SSDP.h @@ -38,7 +38,7 @@ typedef enum { MULTICAST, UNICAST } ssdp_req_types_t; -typedef struct ssdp_packet_t { +struct ssdp_packet_t { bool pending; unsigned long recvd; ssdp_method_t method; @@ -91,7 +91,7 @@ class UPNPDeviceType { char *getUSN(const char *st); void setChipId(uint32_t chipId); }; -typedef struct ssdp_response_t { +struct ssdp_response_t { bool waiting; IPAddress address; uint16_t port; diff --git a/Sockets.h b/Sockets.h index 3ac8894..8aaa41f 100644 --- a/Sockets.h +++ b/Sockets.h @@ -6,7 +6,7 @@ #define SOCK_MAX_ROOMS 1 #define ROOM_EMIT_FRAME 0 -typedef struct room_t { +struct room_t { uint8_t clients[5] = {255, 255, 255, 255}; uint8_t activeClients(); bool isJoined(uint8_t num); diff --git a/Somfy.h b/Somfy.h index 793f0e2..8a15527 100644 --- a/Somfy.h +++ b/Somfy.h @@ -4,7 +4,7 @@ #define SOMFY_MAX_SHADES 32 #define SOMFY_MAX_LINKED_REMOTES 7 -typedef struct appver_t { +struct appver_t { uint8_t major; uint8_t minor; uint8_t build; @@ -58,7 +58,7 @@ typedef enum { complete = 2 } t_status; -typedef struct somfy_rx_t { +struct somfy_rx_t { t_status status; uint8_t bit_length = 56; 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 byte index to make it so we don't have to reorganize // the storage each time we push or pop. -typedef struct somfy_rx_queue_t { +struct somfy_rx_queue_t { void init(); uint8_t length = 0; uint8_t index[MAX_RX_BUFFER]; @@ -80,12 +80,12 @@ typedef struct somfy_rx_queue_t { //void push(somfy_rx_t *rx); bool pop(somfy_rx_t *rx); }; -typedef struct somfy_tx_t { +struct somfy_tx_t { uint32_t await = 0; somfy_commands cmd; 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); } 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; @@ -98,7 +98,7 @@ typedef struct somfy_tx_queue_t { enum class somfy_flags_t : byte { Sun = 1 }; -typedef struct somfy_frame_t { +struct somfy_frame_t { bool valid = false; bool processed = false; radio_proto proto = radio_proto::RTS; @@ -209,7 +209,7 @@ class SomfyShade : public SomfyRemote { void commitMyPosition(); }; -typedef struct transceiver_config_t { +struct transceiver_config_t { bool printBuffer = false; bool enabled = false; uint8_t type = 56; // 56 or 80 bit protocol. diff --git a/Utils.h b/Utils.h index a386875..b2fa96f 100644 --- a/Utils.h +++ b/Utils.h @@ -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--;} } static void _trim(char *str) { _ltrim(str); _rtrim(str); } -typedef struct rebootDelay_t { +struct rebootDelay_t { bool reboot = false; int rebootTime = 0; bool closed = false;