Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linky #47

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ bool readConfig (bool clear_on_error)
return false;
}

// Check the config for new elements Compteur
if (config.compteur_modele[0] == '\0')
strcpy_P(config.compteur_modele, CFG_COMPTEUR_DEFAULT_MODELE);
if (config.compteur_tic[0] == '\0')
strcpy_P(config.compteur_tic, CFG_COMPTEUR_DEFAULT_TIC);

return true ;
}

Expand Down Expand Up @@ -187,6 +193,11 @@ void showConfig()
if (config.config & CFG_LCD) DebugF(" LCD");
_wdt_feed();

DebuglnF("\r\n===== Compteur");
DebugF("Modèle :"); Debugln(config.compteur_modele);
DebugF("TIC :"); Debugln(config.compteur_tic);
_wdt_feed();

DebuglnF("\r\n===== Emoncms");
DebugF("host :"); Debugln(config.emoncms.host);
DebugF("port :"); Debugln(config.emoncms.port);
Expand Down Expand Up @@ -232,6 +243,10 @@ void resetConfig(void)
config.ota_port = DEFAULT_OTA_PORT ;

// Add other init default config here

// Compteur
strcpy_P(config.compteur_modele, CFG_COMPTEUR_DEFAULT_MODELE);
strcpy_P(config.compteur_tic, CFG_COMPTEUR_DEFAULT_TIC);

// Emoncms
strcpy_P(config.emoncms.host, CFG_EMON_DEFAULT_HOST);
Expand Down
36 changes: 23 additions & 13 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
#define CFG_PSK_SIZE 64
#define CFG_HOSTNAME_SIZE 16

#define CFG_COMPTEUR_MODELE_SIZE 12
#define CFG_COMPTEUR_TIC_SIZE 10
#define CFG_COMPTEUR_DEFAULT_MODELE "electronique"
#define CFG_COMPTEUR_DEFAULT_TIC "historique"

#define CFG_EMON_HOST_SIZE 32
#define CFG_EMON_APIKEY_SIZE 32
#define CFG_EMON_URL_SIZE 32
Expand Down Expand Up @@ -72,6 +77,9 @@
#define CFG_FORM_OTA_AUTH FPSTR("ota_auth")
#define CFG_FORM_OTA_PORT FPSTR("ota_port")

#define CFG_FORM_COMPTEUR_MODELE FPSTR("compteur_modele")
#define CFG_FORM_COMPTEUR_TIC FPSTR("compteur_tic")

#define CFG_FORM_EMON_HOST FPSTR("emon_host")
#define CFG_FORM_EMON_PORT FPSTR("emon_port")
#define CFG_FORM_EMON_URL FPSTR("emon_url")
Expand Down Expand Up @@ -127,19 +135,21 @@ typedef struct
// 1024 bytes total including CRC
typedef struct
{
char ssid[CFG_SSID_SIZE+1]; // SSID
char psk[CFG_PSK_SIZE+1]; // Pre shared key
char host[CFG_HOSTNAME_SIZE+1]; // Hostname
char ap_psk[CFG_PSK_SIZE+1]; // Access Point Pre shared key
char ota_auth[CFG_PSK_SIZE+1]; // OTA Authentication password
uint32_t config; // Bit field register
uint16_t ota_port; // OTA port
uint8_t led_bright; // RGB Led brightness 0-255
uint16_t oled_type; // Display OLED type (1306 or 1106)
uint8_t filler[128]; // in case adding data in config avoiding loosing current conf by bad crc
_emoncms emoncms; // Emoncms configuration
_jeedom jeedom; // jeedom configuration
uint8_t filler1[256]; // Another filler in case we need more
char ssid[CFG_SSID_SIZE+1]; // SSID
char psk[CFG_PSK_SIZE+1]; // Pre shared key
char host[CFG_HOSTNAME_SIZE+1]; // Hostname
char ap_psk[CFG_PSK_SIZE+1]; // Access Point Pre shared key
char ota_auth[CFG_PSK_SIZE+1]; // OTA Authentication password
uint32_t config; // Bit field register
uint16_t ota_port; // OTA port
uint8_t led_bright; // RGB Led brightness 0-255
uint16_t oled_type; // Display OLED type (1306 or 1106)
char compteur_modele[CFG_COMPTEUR_MODELE_SIZE+1]; // Modele de compteur
char compteur_tic[CFG_COMPTEUR_TIC_SIZE+1]; // TIC mode
uint8_t filler[104]; // in case adding data in config avoiding loosing current conf by bad crc
_emoncms emoncms; // Emoncms configuration
_jeedom jeedom; // jeedom configuration
uint8_t filler1[256]; // Another filler in case we need more
uint16_t crc;
} _Config;

Expand Down
Binary file modified data/css/remora.css.gz
Binary file not shown.
Binary file modified data/index.htm.gz
Binary file not shown.
Binary file modified data/js/remora.js.gz
Binary file not shown.
16 changes: 12 additions & 4 deletions remora_soft.ino
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,6 @@ void mysetup()

#elif defined (ESP8266)

#ifdef MOD_TELEINFO
// Init de la téléinformation
Serial.begin(1200, SERIAL_7E1);
#endif

// Clear our global flags
config.config = 0;
Expand Down Expand Up @@ -523,6 +519,18 @@ void mysetup()
rgb_brightness = config.led_bright;
DebugF("RGB Brightness: "); Debugln(rgb_brightness);

// Init de la téléinformation
#ifdef MOD_TELEINFO
if (strcmp(config.compteur_tic, "standard") == 0) {
Debugln("TIC standard : Serial 9600 bps");
Serial.begin(9600, SERIAL_7E1);
}
else {
Debugln("Tic historique : Serial 1200 bps");
Serial.begin(1200, SERIAL_7E1);
}
#endif

// Connection au Wifi ou Vérification
WifiHandleConn(true);

Expand Down
9 changes: 8 additions & 1 deletion tinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,14 @@ bool tinfo_setup(bool wait_data)
Debugflush();

#ifdef SPARK
Serial1.begin(1200); // Port série RX/TX on serial1 for Spark
if (strcmp(config.compteur_modele, "linky") && strcmp(config.compteur_tic, "standard")) {
Debugln("TIC standard : Serial 9600 bps");
Serial1.begin(9600); // Port série RX/TX on serial1 for Spark
}
else{
Debugln("TIC historique : Serial 1200 bps");
Serial1.begin(1200); // Port série RX/TX on serial1 for Spark
}
#endif

// reset du timeout de detection de la teleinfo
Expand Down
22 changes: 21 additions & 1 deletion webdev/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,26 @@ <h3 id="advancedCollapse" class="panel-title clickable" data-toggle="collapse" d
</div>
</div>

<div class="form-group">
<label class="col-sm-3 control-label">Modèle de Compteur</label>
<div class="col-sm-9">
<select id="compteur_modele" name="compteur_modele" class="form-control col-sm-2">
<option value="electronique">Électronique</option>
<option value="linky">Linky</option>
</select>
</div>
</div>

<div class="form-group compteur_tic">
<label class="col-sm-3 control-label">Mode TIC</label>
<div class="col-sm-9">
<select id="compteur_tic" name="compteur_tic" class="form-control col-sm-2">
<option value="historique">Historique</option>
<option value="standard">Standard</option>
</select>
</div>
</div>

<!--
<div class="form-group">
<label class="col-sm-3 control-label">Options actives</label>
Expand Down Expand Up @@ -691,4 +711,4 @@ <h4 class="modal-title">Redémarrage Remora en cours</h4>
<div class="loader-section section-left"></div>
<div class="loader-section section-right"></div>
</div>
</html>
</html>
23 changes: 22 additions & 1 deletion webdev/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@
ledBrightSlider.slider('refresh');
});
}
if (form_data.compteur_modele == 'linky') {
$('.compteur_tic').show();
} else {
$('.compteur_tic').hide();
}
})
.fail(function() { console.error( "error while requestiong configuration data" ); });
$('#tab_scan_data').bootstrapTable('refresh',{silent:true, showLoading:true, url:'/wifiscan.json'});
Expand Down Expand Up @@ -427,6 +432,11 @@
$('#jdom_finger').val('');
}

// On force le mode TIC historique pour les compteurs électronique
if ($('#compteur_modele').val() != 'linky') {
$('#compteur_tic').val('historique');
}

$.post('/config_form.json', $("#frm_config").serialize())
.done( function(msg, textStatus, xhr) {
Notify(2, 'ok', 'success', 'Enregistrement effectué', xhr.status+' '+msg);
Expand Down Expand Up @@ -525,6 +535,17 @@
//$("#cfg_led_bright")
//.on('slideStop',function(){ wsSend('$rgbb:'+$('#cfg_led_bright').slider('getValue'));});

// Gestion du mode TIC
$('.compteur_tic').hide();
$('#compteur_modele').change(function() {
$('.compteur_tic').hide();
$("#compteur_modele option:selected" ).each(function() {
if ($(this).val() == 'linky') {
$('.compteur_tic').show();
}
});
});

var url = document.location.toString(),
full = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: '');
if (debug) console.log ('url: ' + url);
Expand All @@ -544,4 +565,4 @@
// enlever le loader, tout est prêt
$('body').addClass('loaded');
});
}(jQuery);
}(jQuery);
2 changes: 1 addition & 1 deletion webdev/js/remora.js

Large diffs are not rendered by default.

47 changes: 27 additions & 20 deletions webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,28 +441,31 @@ void getConfJSONData(String & r)
r = FPSTR(FP_JSON_START);

r+="\"";
r+=CFG_FORM_SSID; r+=FPSTR(FP_QCQ); r+=config.ssid; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_PSK; r+=FPSTR(FP_QCQ); r+=config.psk; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_HOST; r+=FPSTR(FP_QCQ); r+=config.host; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_AP_PSK; r+=FPSTR(FP_QCQ); r+=config.ap_psk; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_HOST; r+=FPSTR(FP_QCQ); r+=config.emoncms.host; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_PORT; r+=FPSTR(FP_QCQ); r+=config.emoncms.port; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_URL; r+=FPSTR(FP_QCQ); r+=config.emoncms.url; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_KEY; r+=FPSTR(FP_QCQ); r+=config.emoncms.apikey; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_NODE; r+=FPSTR(FP_QCQ); r+=config.emoncms.node; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_FREQ; r+=FPSTR(FP_QCQ); r+=config.emoncms.freq; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_OTA_AUTH; r+=FPSTR(FP_QCQ); r+=config.ota_auth; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_OTA_PORT; r+=FPSTR(FP_QCQ); r+=config.ota_port; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_LED_BRIGHT; r+=FPSTR(FP_QCQ);
r+=CFG_FORM_SSID; r+=FPSTR(FP_QCQ); r+=config.ssid; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_PSK; r+=FPSTR(FP_QCQ); r+=config.psk; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_HOST; r+=FPSTR(FP_QCQ); r+=config.host; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_AP_PSK; r+=FPSTR(FP_QCQ); r+=config.ap_psk; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_HOST; r+=FPSTR(FP_QCQ); r+=config.emoncms.host; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_PORT; r+=FPSTR(FP_QCQ); r+=config.emoncms.port; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_URL; r+=FPSTR(FP_QCQ); r+=config.emoncms.url; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_KEY; r+=FPSTR(FP_QCQ); r+=config.emoncms.apikey; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_NODE; r+=FPSTR(FP_QCQ); r+=config.emoncms.node; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_EMON_FREQ; r+=FPSTR(FP_QCQ); r+=config.emoncms.freq; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_OTA_AUTH; r+=FPSTR(FP_QCQ); r+=config.ota_auth; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_OTA_PORT; r+=FPSTR(FP_QCQ); r+=config.ota_port; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_LED_BRIGHT; r+=FPSTR(FP_QCQ);
r+=map(config.led_bright, 0, 255, 0, 100); r+= FPSTR(FP_QCNL);

r+=CFG_FORM_JDOM_HOST; r+=FPSTR(FP_QCQ); r+=config.jeedom.host; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_PORT; r+=FPSTR(FP_QCQ); r+=config.jeedom.port; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_URL; r+=FPSTR(FP_QCQ); r+=config.jeedom.url; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_KEY; r+=FPSTR(FP_QCQ); r+=config.jeedom.apikey; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_ADCO; r+=FPSTR(FP_QCQ); r+=config.jeedom.adco; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_FING; r+=FPSTR(FP_QCQ); r+=getFingerPrint(); r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_FREQ; r+=FPSTR(FP_QCQ); r+=config.jeedom.freq;
r+=CFG_FORM_COMPTEUR_MODELE; r+=FPSTR(FP_QCQ); r+=config.compteur_modele; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_COMPTEUR_TIC; r+=FPSTR(FP_QCQ); r+=config.compteur_tic; r+= FPSTR(FP_QCNL);

r+=CFG_FORM_JDOM_HOST; r+=FPSTR(FP_QCQ); r+=config.jeedom.host; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_PORT; r+=FPSTR(FP_QCQ); r+=config.jeedom.port; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_URL; r+=FPSTR(FP_QCQ); r+=config.jeedom.url; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_KEY; r+=FPSTR(FP_QCQ); r+=config.jeedom.apikey; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_ADCO; r+=FPSTR(FP_QCQ); r+=config.jeedom.adco; r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_FING; r+=FPSTR(FP_QCQ); r+=getFingerPrint(); r+= FPSTR(FP_QCNL);
r+=CFG_FORM_JDOM_FREQ; r+=FPSTR(FP_QCQ); r+=config.jeedom.freq;

r+= F("\"");
// Json end
Expand Down Expand Up @@ -898,6 +901,10 @@ void handleFormConfig(AsyncWebServerRequest *request)
rgb_brightness = config.led_bright;
}

// Modele compteur
strncpy(config.compteur_modele, request->getParam("compteur_modele", true)->value().c_str(), CFG_COMPTEUR_MODELE_SIZE);
strncpy(config.compteur_tic, request->getParam("compteur_tic", true)->value().c_str(), CFG_COMPTEUR_TIC_SIZE);

// Emoncms
strncpy(config.emoncms.host, request->getParam("emon_host", true)->value().c_str(), CFG_EMON_HOST_SIZE );
strncpy(config.emoncms.url, request->getParam("emon_url", true)->value().c_str(), CFG_EMON_URL_SIZE );
Expand Down