Skip to content

Commit

Permalink
Typo fixes, definitions change remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
redakker committed Nov 19, 2023
1 parent 8097a5b commit 82e9253
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 64 deletions.
6 changes: 3 additions & 3 deletions src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Database::save() {
logger << "data saved: " << data;
}

void Database::updateProperty(String property, String value) {
void Database::updateProperty(String property, String value) {
updateProperty(property, value, false);
}

Expand Down Expand Up @@ -150,11 +150,11 @@ void Database::jsonToDatabase(String json) {
// Save mechanism from hackers
// Data alaways have a name property, because the system initialize the EEPROM if the format is not correct.
// See the init() function
// Check the if name is available and it is the same az a board name. In case of matching, save the data
// Check if the name is available and it is the same az a board name. In case of matching, save the data
String value = tempJson["name"].as<String>();

if (String(BOARD_NAME).equals(value)) {
// update/add properties individually, overwrite the wole database remove some other properties from other settings source (MQTT ledstrip)
// update/add properties individually, overwrite the wole database skip some properties which
JsonObject documentRoot = tempJson.as<JsonObject>();
for (JsonPair keyValue : documentRoot) {
if (strcmp(keyValue.key().c_str(),"command") != 0)
Expand Down
127 changes: 66 additions & 61 deletions src/definitions.h
Original file line number Diff line number Diff line change
@@ -1,72 +1,77 @@
// VERSION
#define MAJOR_VERSION 1.11
#ifndef DEFINITIONS_H
#define DEFINITIONS_H

// Board specific setings
#define BOARD_NAME "blecker"
#define LED_BUILTIN 2
#define EEPROM_SIZE 1024
// VERSION
#define MAJOR_VERSION 1.11

// Software settings
#define SERVER_PORT 80
#define MQTT_MAX_TRY 10 // give the connect up after this amount of tries
#define MQTT_TOPIC "/blecker"
#define MQTT_IN_POSTFIX "/in"
// Board specific setings
#define BOARD_NAME "blecker"
#define LED_BUILTIN 2
#define EEPROM_SIZE 1024

#define MQTT_STATUS_ON_DEFAULT_VALUE "on"
#define MQTT_STATUS_OFF_DEFAULT_VALUE "off"
#define MQTT_STATUS_OFF_DEFAULT_RETAIN false
// Software settings
#define SERVER_PORT 80
#define MQTT_MAX_TRY 10 // give the connect up after this amount of tries
#define MQTT_TOPIC "/" BOARD_NAME
#define MQTT_IN_POSTFIX "/in"

#define MQTT_KEEPALILIVE_TIME 30000 // in milliseconds
#define MQTT_STATUS_ON_DEFAULT_VALUE "on"
#define MQTT_STATUS_OFF_DEFAULT_VALUE "off"
#define MQTT_STATUS_OFF_DEFAULT_RETAIN false

// Presence
#define DEFAULT_PRESENT "present"
#define DEFAULT_NOT_PRESENT "not_present"
#define BT_DEVICE_TIMEOUT 1500*60 // 60 seconds in milliseconds (it is doubled because of the mark mechanism) // After this time we sent a "not_home" mqtt message
#define BT_LIST_REBUILD_INTERVAL 1000*60*60 // Just clear the list after every hour and rebuild again, send "refresh" state time to time even if the device is not gone
#define BT_DEVICE_DATA_INTERVAL 1000*60 // Send the BLE device data time to time
#define DEVICE_DROP_OUT_COUNT 2 // We won't drop out in the first "not found" state, just decrease this value. Drop out when this is 0
#define PARSE_CHAR ";"
#define BT_DEFAULT_SCAN_INTERVAL 3000 // Scan is running after this timeout time to time
#define MQTT_KEEPALILIVE_TIME 30000 // in milliseconds

// Webhook
#define PRESENCE_WILDCARD "{presence}"
#define DEVICE_WILDCARD "{device}"
// Presence
#define DEFAULT_PRESENT "present"
#define DEFAULT_NOT_PRESENT "not_present"
#define BT_DEVICE_TIMEOUT 1500*60 // 60 seconds in milliseconds (it is doubled because of the mark mechanism) // After this time we sent a "not_home" mqtt message
#define BT_LIST_REBUILD_INTERVAL 1000*60*60 // Just clear the list after every hour and rebuild again, send "refresh" state time to time even if the device is not gone
#define BT_DEVICE_DATA_INTERVAL 1000*60 // Send the BLE device data time to time
#define DEVICE_DROP_OUT_COUNT 2 // We won't drop out in the first "not found" state, just decrease this value. Drop out when this is 0
#define PARSE_CHAR ";"
#define BT_DEFAULT_SCAN_INTERVAL 3000 // Scan is running after this timeout time to time

// Auto Discovery
#define HA_AUTODISCOVERY_INTERVAL 1000*60
// Webhook
#define PRESENCE_WILDCARD "{presence}"
#define DEVICE_WILDCARD "{device}"

// Network
#define WIFI_MAX_TRY 10
#define AP_IP {192, 168, 4, 1} // Change together with the string version
#define AP_IP_STRING "192.168.4.1" // Change together with the object version
#define AP_NETMASK {255, 255, 255, 0}
// Auto Discovery
#define HA_AUTODISCOVERY_INTERVAL 1000*60

// ERRORS
#define ERROR_NO_ERROR 0
#define ERROR_UNKNOWN 1
#define ERROR_WIFI 2
#define ERROR_MQTT 8
// Network
#define WIFI_MAX_TRY 10
#define AP_IP {192, 168, 4, 1} // Change together with the string version
#define AP_IP_STRING "192.168.4.1" // Change together with the object version
#define AP_NETMASK {255, 255, 255, 0}

#define COMMAND_CONFIG "config"
// ERRORS
#define ERROR_NO_ERROR 0
#define ERROR_UNKNOWN 1
#define ERROR_WIFI 2
#define ERROR_MQTT 8

// DATABASE PROPERTIES
#define DB_WIFI_NAME "ssid"
#define DB_WIFI_PASSWORD "pw"
#define DB_MQTT_SERVER "mqttserver"
#define DB_MQTT_PORT "mqttport"
#define DB_MQTT_USER "mqttuser"
#define DB_MQTT_PW "mqttpw"
#define DB_MQTT_TOPIC_PREFIX "mqttprefix"
#define DB_PRECENCE "present"
#define DB_NO_PRECENCE "notpresent"
#define DB_VERSION "version"
#define DB_DEVICES "devices"
#define DB_DETAILED_REPORT "detailed"
#define DB_HA_AUTODISCOVERY "hadisc"
#define DB_HA_AUTODISCOVERY_PREFIX "hadiscpref"
#define DB_REBOOT_TIMEOUT "reboot"
#define DB_WEBHOOK "webhook"
#define DB_DEVICE_STATUS_ON "status_on"
#define DB_DEVICE_STATUS_OFF "status_off"
#define DB_DEVICE_STATUS_RETAIN "status_retain"
#define DB_DEVICE_ID "deviceid"
#define COMMAND_CONFIG "config"

// DATABASE PROPERTIES
#define DB_WIFI_NAME "ssid"
#define DB_WIFI_PASSWORD "pw"
#define DB_MQTT_SERVER "mqttserver"
#define DB_MQTT_PORT "mqttport"
#define DB_MQTT_USER "mqttuser"
#define DB_MQTT_PW "mqttpw"
#define DB_MQTT_TOPIC_PREFIX "mqttprefix"
#define DB_PRECENCE "present"
#define DB_NO_PRECENCE "notpresent"
#define DB_VERSION "version"
#define DB_DEVICES "devices"
#define DB_DETAILED_REPORT "detailed"
#define DB_HA_AUTODISCOVERY "hadisc"
#define DB_HA_AUTODISCOVERY_PREFIX "hadiscpref"
#define DB_REBOOT_TIMEOUT "reboot"
#define DB_WEBHOOK "webhook"
#define DB_DEVICE_STATUS_ON "status_on"
#define DB_DEVICE_STATUS_OFF "status_off"
#define DB_DEVICE_STATUS_RETAIN "status_retain"
#define DB_DEVICE_ID "deviceid"

#endif

0 comments on commit 82e9253

Please sign in to comment.