Skip to content

Commit 5a0b9b2

Browse files
authored
Merge pull request #15 from rene-d/develop
Develop
2 parents 9be563f + a0452b5 commit 5a0b9b2

37 files changed

+376
-83
lines changed

.github/workflows/release.yml

+20-6
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ jobs:
3131
platformio run -e esp01s_prod -e esp12e_prod -t buildfs
3232
3333
cd .pio/build
34-
zip --junk-paths ../../wifinfo-esp01_1m.zip esp01s_prod/*.bin
35-
zip --junk-paths ../../wifinfo-esp12e.zip esp12e_prod/*.bin
34+
zip --junk-paths ../../esp01_1m.zip esp01s_prod/*.bin
35+
zip --junk-paths ../../esp12e.zip esp12e_prod/*.bin
36+
37+
cd ../..
38+
tools/mkarduinosrc.py arduino.zip
3639
3740
- name: Create Release
3841
id: create_release
@@ -45,24 +48,35 @@ jobs:
4548
draft: false
4649
prerelease: false
4750

48-
- name: Upload Release Asset 1
51+
- name: Upload Release Asset ESP01S
4952
id: upload-release-asset-1
5053
uses: actions/upload-release-asset@v1
5154
env:
5255
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5356
with:
5457
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
55-
asset_path: ./wifinfo-esp01_1m.zip
58+
asset_path: ./esp01_1m.zip
5659
asset_name: wifinfo-esp01_1m.zip
5760
asset_content_type: application/zip
5861

59-
- name: Upload Release Asset 2
62+
- name: Upload Release Asset ESP12E
6063
id: upload-release-asset-2
6164
uses: actions/upload-release-asset@v1
6265
env:
6366
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6467
with:
6568
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
66-
asset_path: ./wifinfo-esp12e.zip
69+
asset_path: ./esp12e.zip
6770
asset_name: wifinfo-esp12e.zip
6871
asset_content_type: application/zip
72+
73+
- name: Upload Release Asset Sources
74+
id: upload-release-asset-3
75+
uses: actions/upload-release-asset@v1
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
with:
79+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
80+
asset_path: ./arduino.zip
81+
asset_name: wifinfo-arduino-sources.zip
82+
asset_content_type: application/zip

.github/workflows/tests.yml

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
xsltproc gtest2html.xslt build/test_detail.xml > artifacts/test_detail.html
3535
gcovr -r . --html -o artifacts/coverage.html
3636
37+
- name: Amalgamation for Arduino IDE
38+
run: |
39+
tools/mkarduinosrc.py -1 artifacts/wifinfo-amalgamation.zip
40+
3741
- name: Archive tests and code coverage results
3842
uses: actions/upload-artifact@v1
3943
with:

.gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
.vscode/c_cpp_properties.json
2-
.vscode/launch.json
3-
.vscode/settings.json
4-
.vscode/.ropeproject/
1+
.vscode/
52
data/
63
.pio/
74
build/

.vscode/extensions.json

-7
This file was deleted.

CMakeLists.txt

+8-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ endif()
4545
#
4646
#
4747
add_executable(tic
48-
test/test_support.cpp
49-
test/test_teleinfo.cpp
5048
test/test_config.cpp
51-
test/test_tic.cpp
52-
test/test_sys.cpp
5349
test/test_filesystem.cpp
50+
test/test_led_enabled.cpp
51+
test/test_led_disabled.cpp
52+
test/test_sys.cpp
53+
test/test_teleinfo.cpp
54+
test/test_tic.cpp
55+
test/test_support.cpp
5456
test/mock_time.cpp
5557
test/mock.cpp
5658
test/mock_support.cpp)
@@ -72,7 +74,7 @@ target_link_libraries(tic
7274

7375
target_link_libraries(tic PUBLIC coverage_config)
7476

75-
target_compile_definitions(tic PRIVATE ENABLE_CLI DEBUG)
77+
target_compile_definitions(tic PRIVATE ENABLE_CLI ENABLE_DEBUG PLATFORMIO=1 WIFINFO_VERSION=\"test\")
7678

7779
#
7880
#
@@ -81,7 +83,7 @@ add_executable(gen_eeprom
8183
target_include_directories(gen_eeprom
8284
PRIVATE src
8385
PRIVATE test/support)
84-
86+
target_compile_definitions(gen_eeprom PRIVATE PLATFORMIO=1 WIFINFO_VERSION=\"test\")
8587

8688
#
8789
#

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@ La page HTML est compressée avec [html-minifier](https://github.com/kangax/html
124124

125125
### Options de compilation
126126

127-
- `DEBUG` : active la sortie sur le port série TX et vitesse 115200. Non utilisable avec un compteur, il faut utiliser le client de test pour injecter des trames.
127+
- `ENABLE_DEBUG` : active la sortie sur le port série TX et vitesse 115200. Non utilisable avec un compteur, il faut utiliser le client de test pour injecter des trames.
128128
- `ENABLE_CLI` : active les commandes par port série (`TAB` ou `ESC`)
129-
- `DISABLE_LED` : désactive l'utilisation de LED pour les cartes qui n'en ont pas
129+
- `ENABLE_LED` : active l'utilisation de LED pour les cartes qui en ont une (esp01s, esp12e)
130130
- `ENABLE_OTA` : rajoute le code pour les mises à jour OTA **(non testé)**
131+
- `ENABLE_CPULOAD` : mesure de manière empirique la charge CPU
131132

132-
Nota: Sans l'option `DEBUG`, le port série est réglé à 1200 7E1 en RX uniquement. Il y a suffisamment d'outils de mise au point pour ne pas à devoir tester avec un compteur ou un autre microcontrôleur qui simule la téléinformation.
133+
Nota: Sans l'option `ENABLE_DEBUG`, le port série est réglé à 1200 7E1 en RX uniquement. Il y a suffisamment d'outils de mise au point pour ne pas à devoir tester avec un compteur ou un autre microcontrôleur qui simule la téléinformation.
133134

134135
### PlatformtIO
135136

@@ -220,7 +221,7 @@ L'interface alors sera disponible à cette adresse: <http://localhost:5001/>, av
220221

221222
La mise en place d'une stack sonde/InfluxDB/Grafana est grandement simplifiée grâce à Docker.
222223

223-
Le fichier [docker-compose.yaml](dashboard/docker-compose.yaml) rassemble les trois services:
224+
Le fichier [docker-compose.yaml](tools/dashboard/docker-compose.yaml) rassemble les trois services:
224225

225226
- la sonde, écrite en Python, qui récupère les données en JSON via une connexion SSE avec le module
226227
- la base de données InfluxDB de type TSBD

platformio.ini

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ board = esp12e
1818
framework = arduino
1919
monitor_speed = 115200
2020
;build_flags = -DDEBUG_ESP_UPDATER -DDEBUG_ESP_PORT=Serial
21-
src_build_flags = -DDEBUG -DENABLE_CLI # -DENABLE_CPULOAD -DENABLE_OTA
21+
src_build_flags = -DENABLE_DEBUG -DENABLE_CLI -DENABLE_LED -DENABLE_OTA # -DENABLE_CPULOAD
2222
lib_deps = SimpleCLI
2323
extra_scripts = post:prep_data_folder.py
2424
check_tool = cppcheck, clangtidy
@@ -32,7 +32,7 @@ platform = espressif8266
3232
board = esp01_1m
3333
framework = arduino
3434
monitor_speed = 115200
35-
src_build_flags = -DDEBUG -DENABLE_CLI -DLED_BUILTIN=2
35+
src_build_flags = -DENABLE_DEBUG -DENABLE_CLI -DLED_BUILTIN=2 -DENABLE_LED
3636
lib_deps = SimpleCLI
3737
extra_scripts = post:prep_data_folder.py
3838

@@ -42,7 +42,7 @@ platform = espressif8266
4242
board = esp01_1m
4343
framework = arduino
4444
monitor_speed = 115200
45-
src_build_flags = -DDEBUG -DENABLE_CLI -DDISABLE_LED
45+
src_build_flags = -DENABLE_DEBUG -DENABLE_CLI
4646
lib_deps = SimpleCLI
4747
extra_scripts = post:prep_data_folder.py
4848

@@ -52,15 +52,16 @@ platform = espressif8266
5252
board = esp01_1m
5353
framework = arduino
5454
monitor_speed = 1200
55-
src_build_flags = -DLED_BUILTIN=2
55+
src_build_flags = -DLED_BUILTIN=2 -DENABLE_LED -DENABLE_OTA
5656
lib_deps = SimpleCLI
5757
extra_scripts = post:prep_data_folder.py
5858

59-
; nodeMCU ou similaire
59+
; NodeMCU 1.0 ou similaire, pas de sortie série
6060
[env:esp12e_prod]
6161
platform = espressif8266
6262
board = esp12e
6363
framework = arduino
6464
monitor_speed = 1200
65+
src_build_flags = -DLED_BUILTIN=2 -DENABLE_LED -DENABLE_OTA
6566
lib_deps = SimpleCLI
6667
extra_scripts = post:prep_data_folder.py

src/cli.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// module téléinformation client
22
// rene-d 2020
33

4+
#include "settings.h"
45
#include "cli.h"
56
#include "config.h"
67
#include "filesystem.h"
@@ -17,6 +18,8 @@
1718
#include <SimpleCLI.h>
1819

1920
extern "C" uint32_t _EEPROM_start;
21+
extern "C" uint32_t _FS_start;
22+
extern "C" uint32_t _FS_end;
2023

2124
static void cli_eeprom_dump(uint8_t bytesPerRow, size_t size);
2225

@@ -186,6 +189,9 @@ void cli_setup()
186189
Serial.printf_P(PSTR("checkFlashConfig : %d\n"), ESP.checkFlashConfig());
187190
Serial.printf_P(PSTR("FlashChipVendorId : 0x%x\n"), ESP.getFlashChipVendorId());
188191
Serial.printf_P(PSTR("EEPROM_start : 0x%08x\n"), (uint32_t)&_EEPROM_start - 0x40200000);
192+
Serial.printf_P(PSTR("EEPROM_end : 0x%08x\n"), (uint32_t)&_EEPROM_start - 0x40200000 + SPI_FLASH_SEC_SIZE);
193+
Serial.printf_P(PSTR("FS_start : 0x%08x\n"), (uint32_t)&_FS_start - 0x40200000);
194+
Serial.printf_P(PSTR("FS_end : 0x%08x\n"), (uint32_t)&_FS_end - 0x40200000);
189195

190196
Serial.printf_P(PSTR("FreeHeap : %u\n"), ESP.getFreeHeap());
191197
Serial.printf_P(PSTR("MaxFreeBlockSize : %u\n"), ESP.getMaxFreeBlockSize());
@@ -239,8 +245,8 @@ int cli_loop_read()
239245
if (Serial.available())
240246
{
241247
int c = Serial.read();
242-
if ((c == 0x09) || (c == 0x1B)) // ESC non présent dans une trame de téléinfo
243-
{ // TAB possible en séparateur, mais pas rencontré
248+
if ((c == 0x09) || (c == 0x1B) || (c == '`')) // ESC non présent dans une trame de téléinfo
249+
{ // TAB possible en séparateur, mais pas rencontré
244250
cli_mode = true;
245251
Serial.print("$ ");
246252
}

src/config.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
//
2424
// **********************************************************************************
2525

26+
#include "settings.h"
2627
#include "config.h"
2728
#include "jsonbuilder.h"
2829
#include "strncpy_s.h"
@@ -364,7 +365,7 @@ void config_handle_form(ESP8266WebServer &server)
364365
// We validated config ?
365366
if (server.hasArg("save"))
366367
{
367-
#ifdef DEBUG
368+
#ifdef ENABLE_DEBUG
368369
Serial.println(F("===== Posted configuration"));
369370
for (int i = 0; i < server.args(); ++i)
370371
Serial.printf(" %3d %-20s = %s\n", i, server.argName(i).c_str(), server.arg(i).c_str());
@@ -373,10 +374,10 @@ void config_handle_form(ESP8266WebServer &server)
373374

374375
// Wi-Fi et avancé
375376
strncpy_s(config.ssid, server.arg(CFG_FORM_SSID), CFG_SSID_LENGTH);
376-
strncpy_s(config.psk, server.arg(CFG_FORM_PSK), CFG_SSID_LENGTH);
377+
strncpy_s(config.psk, server.arg(CFG_FORM_PSK), CFG_PSK_LENGTH);
377378
strncpy_s(config.host, server.arg(CFG_FORM_HOST), CFG_HOSTNAME_LENGTH);
378-
strncpy_s(config.ap_psk, server.arg(CFG_FORM_AP_PSK), CFG_SSID_LENGTH);
379-
strncpy_s(config.ota_auth, server.arg(CFG_FORM_OTA_AUTH), CFG_SSID_LENGTH);
379+
strncpy_s(config.ap_psk, server.arg(CFG_FORM_AP_PSK), CFG_PSK_LENGTH);
380+
strncpy_s(config.ota_auth, server.arg(CFG_FORM_OTA_AUTH), CFG_PSK_LENGTH);
380381
config.ota_port = validate_int(server.arg(CFG_FORM_OTA_PORT), 0, 65535, DEFAULT_OTA_PORT);
381382

382383
config.sse_freq = validate_int(server.arg(CFG_FORM_SSE_FREQ), 0, 360, 0);

src/cpuload.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// module téléinformation client
22
// rene-d 2020
33

4+
#include "settings.h"
5+
46
#ifdef ENABLE_CPULOAD
57

68
#include "cpuload.h"
@@ -25,7 +27,7 @@ void cpuload_loop()
2527

2628
perf_counter = 0;
2729

28-
#ifdef DEBUG
30+
#ifdef ENABLE_DEBUG
2931
if (perf_index == 0)
3032
{
3133
cpuload_print(Serial);
@@ -34,6 +36,17 @@ void cpuload_loop()
3436
}
3537
}
3638

39+
int cpuload_cpu()
40+
{
41+
uint32_t sum = 0;
42+
for (int i = 0; i < 10; ++i)
43+
{
44+
sum += perfs[i];
45+
}
46+
sum /= 10;
47+
return (100 * (MAX_COUNTER_80MHZ - sum)) / MAX_COUNTER_80MHZ;
48+
}
49+
3750
void cpuload_print(Print &prt)
3851
{
3952
uint32_t sum = 0;

src/cpuload.h

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
void cpuload_loop();
99
void cpuload_print(Print &prt);
10+
int cpuload_cpu();
1011

1112
class StringPrint : public Print
1213
{

src/emptyserial.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
struct EmptySerialClass
99
{
10-
void printf(const char *format, ...) {}
11-
void printf_P(PGM_P format, ...) {}
10+
void printf(const char *, ...) {}
11+
void printf_P(PGM_P, ...) {}
1212
void print(const __FlashStringHelper *) {}
1313
void print(const String &) {}
1414
void print(const char[]) {}
@@ -22,7 +22,7 @@ struct EmptySerialClass
2222
void print(const Printable &) {}
2323

2424
void println(const __FlashStringHelper *) {}
25-
void println(const String &s) {}
25+
void println(const String &) {}
2626
void println(const char[]) {}
2727
void println(char) {}
2828
void println(unsigned char, int = DEC) {}
@@ -37,7 +37,7 @@ struct EmptySerialClass
3737
void flush() {}
3838
};
3939

40-
#ifndef DEBUG
40+
#ifndef ENABLE_DEBUG
4141
extern EmptySerialClass EmptySerial;
4242
#define Serial EmptySerial
4343
#endif

src/filesystem.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// module téléinformation client
22
// rene-d 2020
33

4+
#include "settings.h"
45
#include "filesystem.h"
56
#include "jsonbuilder.h"
67

src/httpreq.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// module téléinformation client
22
// rene-d 2020
33

4+
#include "settings.h"
45
#include "httpreq.h"
56

67
#include <ESP8266HTTPClient.h>

src/led.h

+8-10
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@
55

66
#include <Arduino.h>
77

8-
#ifdef DISABLE_LED
9-
10-
// pas de buildin led sur certains ESP-01
11-
12-
#define led_setup()
13-
#define led_on()
14-
#define led_off()
15-
#define led_toggle()
16-
17-
#else
8+
#ifdef ENABLE_LED
189

1910
inline void led_setup()
2011
{
@@ -36,4 +27,11 @@ inline void led_toggle()
3627
digitalWrite(LED_BUILTIN, 1 - digitalRead(LED_BUILTIN));
3728
}
3829

30+
#else
31+
32+
#define led_setup()
33+
#define led_on()
34+
#define led_off()
35+
#define led_toggle()
36+
3937
#endif

0 commit comments

Comments
 (0)