diff --git a/Caracal_Firmware.ino b/Caracal_Firmware.ino index a0f9026..6edc4a2 100644 --- a/Caracal_Firmware.ino +++ b/Caracal_Firmware.ino @@ -59,8 +59,19 @@ enum UpdateStatus { CONSTANTS */ -#define PIN_STATUS 10 +#define HW_GROUP 2 // Changes with hardware changes that require software changes + +#if HW_GROUP == 1 +#define PIN_STATUS 10 +#define PIN_ACTIVITY 9 // Unusable +#define PIN_CONFIG 0 +#endif + +#if HW_GROUP == 2 +#define PIN_STATUS 5 +#define PIN_ACTIVITY 4 #define PIN_CONFIG 0 +#endif #define WIFI_TIMEOUT 10000 #define UPDATE_START_DELAY 3000 @@ -69,8 +80,7 @@ enum UpdateStatus { GLOBAL VARIABLES */ -unsigned long HW_GROUP = 1; // Changes with hardware changes that require software changes -unsigned long FW_VERSION = 1808070003; // Changes with each release; must always increase +unsigned long FW_VERSION = 1812180001; // Changes with each release; must always increase unsigned long SP_VERSION = 0; // Loaded from SPIFFS; changed with each SPIFFS build; must always increase (uses timestamp as version) // FW & SPIFFS update settings @@ -221,6 +231,25 @@ void blinkLEDStatusLoop(unsigned int duration) { delay(duration); } +void setLEDActivity(bool state) { +#if HW_GROUP == 1 + digitalWrite(PIN_STATUS, state); +#else + digitalWrite(PIN_ACTIVITY, state); +#endif +} + +void blinkLEDActivitySingle(unsigned int duration) { + setLEDActivity(1); + delay(duration); + setLEDActivity(0); +} + +void blinkLEDActivityLoop(unsigned int duration) { + blinkLEDActivitySingle(duration); + delay(duration); +} + void handleConfigButton() { // Read the config button state to determine if it has been pressed or released btnState = !digitalRead(PIN_CONFIG); @@ -598,6 +627,7 @@ t_httpUpdate_return doUpdateInsecure(bool spiffs) { void doUpdate(bool spiffs) { // Set both LEDs on during update setLEDStatus(1); + setLEDActivity(1); pinMode(2, OUTPUT); digitalWrite(2, LOW); @@ -636,6 +666,9 @@ void setup() { WiFi.mode(WIFI_AP); pinMode(PIN_STATUS, OUTPUT); +#if HW_GROUP != 1 + pinMode(PIN_ACTIVITY, OUTPUT); +#endif pinMode(PIN_CONFIG, INPUT_PULLUP); //attachInterrupt(digitalPinToInterrupt(PIN_CONFIG), ISR_config, CHANGE); @@ -702,7 +735,8 @@ void setup() { #endif for (int i = 0; i < 3; i++) { - blinkLEDStatusLoop(125); + blinkLEDStatusLoop(60); + blinkLEDActivityLoop(60); } if (AP_ACTIVE) { @@ -733,12 +767,14 @@ void loop() { if (newClient) client = newClient; if (client) { while (client.available()) { - setLEDStatus(1); + setLEDActivity(1); Serial.write(client.read()); - setLEDStatus(0); + setLEDActivity(0); } while (Serial.available()) { + setLEDActivity(1); client.write(Serial.read()); + setLEDActivity(0); } } diff --git a/firmware.version b/firmware.version deleted file mode 100644 index 60fa7c8..0000000 --- a/firmware.version +++ /dev/null @@ -1 +0,0 @@ -1808070003 \ No newline at end of file diff --git a/firmware.bin b/firmware1.bin similarity index 84% rename from firmware.bin rename to firmware1.bin index 8c27a7c..ad81455 100644 Binary files a/firmware.bin and b/firmware1.bin differ diff --git a/firmware1.version b/firmware1.version new file mode 100644 index 0000000..8dd5607 --- /dev/null +++ b/firmware1.version @@ -0,0 +1 @@ +1812180001 \ No newline at end of file diff --git a/firmware2.bin b/firmware2.bin new file mode 100644 index 0000000..0337919 Binary files /dev/null and b/firmware2.bin differ diff --git a/firmware2.version b/firmware2.version new file mode 100644 index 0000000..8dd5607 --- /dev/null +++ b/firmware2.version @@ -0,0 +1 @@ +1812180001 \ No newline at end of file diff --git a/prepare_firmware.py b/prepare_firmware.py index b23b945..eb44042 100644 --- a/prepare_firmware.py +++ b/prepare_firmware.py @@ -10,16 +10,20 @@ import os import re import time -with open("WiFi_Shield.ino", 'r') as f: +with open("Caracal_Firmware.ino", 'r') as f: code = f.read() + +match = re.search(r"#define HW_GROUP (\d+)", code) +hw_version = match.group(1) match = re.search(r"FW_VERSION = (\d+);", code) fw_version = match.group(1) -with open("firmware.version", 'w') as f: - f.write(fw_version) +fname = "firmware{}.bin".format(hw_version) +if os.path.exists("Caracal_Firmware.ino.generic.bin"): + if os.path.exists(fname): + os.remove(fname) + os.rename("Caracal_Firmware.ino.generic.bin", fname) -if os.path.exists("WiFi_Shield.ino.generic.bin"): - if os.path.exists("firmware.bin"): - os.remove("firmware.bin") - os.rename("WiFi_Shield.ino.generic.bin", "firmware.bin") \ No newline at end of file + with open("firmware{}.version".format(hw_version), 'w') as f: + f.write(fw_version) \ No newline at end of file