Browse Source

Support to build a core version of the firmware (<290Kb) keeping track of the board type for future reference

i18n
Xose Pérez 7 years ago
parent
commit
29b3ae7041
8 changed files with 58 additions and 13 deletions
  1. +1
    -1
      code/espurna/config/arduino.h
  2. +15
    -0
      code/espurna/config/general.h
  3. +4
    -2
      code/espurna/config/sensors.h
  4. +2
    -2
      code/espurna/espurna.ino
  5. +6
    -1
      code/espurna/mdns.ino
  6. +10
    -0
      code/espurna/utils.ino
  7. +5
    -3
      code/extra_scripts.py
  8. +15
    -4
      code/ota.py

+ 1
- 1
code/espurna/config/arduino.h View File

@ -71,7 +71,7 @@
//#define DOMOTICZ_SUPPORT 0
//#define HOMEASSISTANT_SUPPORT 0
//#define I2C_SUPPORT 1
//#define INFLUXDB_SUPPORT 0
//#define INFLUXDB_SUPPORT 1
//#define IR_SUPPORT 1
//#define LLMNR_SUPPORT 1 // Only with Arduino Core 2.4.0
//#define MDNS_SUPPORT 0


+ 15
- 0
code/espurna/config/general.h View File

@ -15,6 +15,21 @@
#define ARRAYINIT(type, name, ...) \
type name[] = {__VA_ARGS__};
//------------------------------------------------------------------------------
// ESPURNA CORE
//------------------------------------------------------------------------------
#ifdef ESPURNA_CORE
#define ALEXA_SUPPORT 0
#define DOMOTICZ_SUPPORT 0
#define HOMEASSISTANT_SUPPORT 0
#define MQTT_SUPPORT 0
#define NTP_SUPPORT 0
#define WEB_SUPPORT 0
#define SENSOR_SUPPORT 0
#define I2C_SUPPORT 0
#endif
//------------------------------------------------------------------------------
// TELNET
//------------------------------------------------------------------------------


+ 4
- 2
code/espurna/config/sensors.h View File

@ -438,15 +438,17 @@
// Sensor helpers configuration
// =============================================================================
#ifndef SENSOR_SUPPORT
#if ANALOG_SUPPORT || BH1750_SUPPORT || BMX280_SUPPORT || DALLAS_SUPPORT \
|| DHT_SUPPORT || DIGITAL_SUPPORT || ECH1560_SUPPORT \
|| EMON_ADC121_SUPPORT || EMON_ADS1X15_SUPPORT \
|| EMON_ANALOG_SUPPORT || EVENTS_SUPPORT || HLW8012_SUPPORT \
|| MHZ19_SUPPORT || PMSX003_SUPPORT || SHT3X_I2C_SUPPORT \
|| SI7021_SUPPORT || V9261F_SUPPORT
#define SENSOR_SUPPORT 1
#else
#define SENSOR_SUPPORT 0
#endif
#endif
// -----------------------------------------------------------------------------


+ 2
- 2
code/espurna/espurna.ino View File

@ -128,8 +128,7 @@ void welcome() {
// -------------------------------------------------------------------------
DEBUG_MSG_P(PSTR("[INIT] MANUFACTURER: %s\n"), MANUFACTURER);
DEBUG_MSG_P(PSTR("[INIT] DEVICE: %s\n"), DEVICE);
DEBUG_MSG_P(PSTR("[INIT] BOARD: %s\n"), getBoardName().c_str());
DEBUG_MSG_P(PSTR("[INIT] SUPPORT:"));
#if ALEXA_SUPPORT
@ -286,6 +285,7 @@ void setup() {
if (getSetting("hostname").length() == 0) {
setSetting("hostname", getIdentifier());
}
setBoardName();
// Cache loop delay value to speed things (recommended max 250ms)
_loopDelay = atol(getSetting("loopDelay", LOOP_DELAY_TIME).c_str());


+ 6
- 1
code/espurna/mdns.ino View File

@ -45,7 +45,7 @@ void mdnsSetup() {
// Public ESPurna related txt for OTA discovery
MDNS.addServiceTxt("arduino", "tcp", "app_name", APP_NAME);
MDNS.addServiceTxt("arduino", "tcp", "app_version", APP_VERSION);
MDNS.addServiceTxt("arduino", "tcp", "target_board", DEVICE_NAME);
MDNS.addServiceTxt("arduino", "tcp", "target_board", getBoardName());
{
char buffer[6];
itoa(ESP.getFlashChipRealSize() / 1024, buffer, 10);
@ -56,6 +56,11 @@ void mdnsSetup() {
itoa(ESP.getFlashChipSize() / 1024, buffer, 10);
MDNS.addServiceTxt("arduino", "tcp", "sdk_size", (const char *) buffer);
}
{
char buffer[6];
itoa(ESP.getFreeSketchSpace(), buffer, 10);
MDNS.addServiceTxt("arduino", "tcp", "free_space", (const char *) buffer);
}
_mdns_wifi_onSTA = WiFi.onStationModeGotIP([](WiFiEventStationModeGotIP ipInfo) {
_mdnsStart();


+ 10
- 0
code/espurna/utils.ino View File

@ -15,6 +15,16 @@ String getIdentifier() {
return String(buffer);
}
void setBoardName() {
#ifndef ESPURNA_CORE
setSetting("boardName", DEVICE_NAME);
#endif
}
String getBoardName() {
return getSetting("boardName", DEVICE_NAME);
}
String getCoreVersion() {
String version = ESP.getCoreVersion();
#ifdef ARDUINO_ESP8266_RELEASE


+ 5
- 3
code/extra_scripts.py View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
import time
Import("env")
# ------------------------------------------------------------------------------
@ -31,11 +32,12 @@ def clr(color, text):
# ------------------------------------------------------------------------------
def check_size(source, target, env):
time.sleep(1)
size = target[0].get_size()
print clr(Color.LIGHT_BLUE, "Binary size: %s bytes" % size)
if size > 512000:
print clr(Color.LIGHT_RED, "File too large for OTA!")
Exit(1)
#if size > 512000:
# print clr(Color.LIGHT_RED, "File too large for OTA!")
# Exit(1)
# ------------------------------------------------------------------------------
# Hooks


+ 15
- 4
code/ota.py View File

@ -38,15 +38,19 @@ def on_service_state_change(zeroconf, service_type, name, state_change):
device['app'] = info.properties.get('app_name', '')
device['version'] = info.properties.get('app_version', '')
device['device'] = info.properties.get('target_board', '')
device['mem_size'] = info.properties.get('mem_size', '')
device['sdk_size'] = info.properties.get('sdk_size', '')
if 'mem_size' in info.properties:
device['mem_size'] = info.properties.get('mem_size')
if 'sdk_size' in info.properties:
device['sdk_size'] = info.properties.get('sdk_size')
if 'free_space' in info.properties:
device['free_space'] = info.properties.get('free_space')
devices.append(device)
def list():
'''
Shows the list of discovered devices
'''
output_format="{:>3} {:<25}{:<25}{:<15}{:<15}{:<30}{:<10}{:<10}"
output_format="{:>3} {:<25}{:<25}{:<15}{:<15}{:<30}{:<10}{:<10}{:<10}"
print(output_format.format(
"#",
"HOSTNAME",
@ -56,8 +60,9 @@ def list():
"DEVICE",
"MEM_SIZE",
"SDK_SIZE",
"FREE_SPACE"
))
print "-" * 135
print "-" * 146
index = 0
for device in devices:
@ -71,6 +76,7 @@ def list():
device.get('device', ''),
device.get('mem_size', ''),
device.get('sdk_size', ''),
device.get('free_space', ''),
))
print
@ -161,6 +167,7 @@ if __name__ == '__main__':
# Parse command line options
parser = argparse.ArgumentParser(description=description)
#parser.add_argument("-v", "--verbose", help="show verbose output", default=0, action='count')
parser.add_argument("-c", "--core", help="flash ESPurna core", default=0, action='count')
parser.add_argument("-f", "--flash", help="flash device", default=0, action='count')
parser.add_argument("-s", "--sort", help="sort devices list by field", default='hostname')
args = parser.parse_args()
@ -194,6 +201,10 @@ if __name__ == '__main__':
device = flash()
if device:
# Flash core version?
if args.core > 0:
device['flags'] = "-DESPURNA_CORE " + device['flags']
env = "esp8266-%sm-ota" % device['size']
# Summary


Loading…
Cancel
Save