mirror of https://github.com/arendst/Tasmota.git
Fix sensor number and identations
This commit is contained in:
parent
1a02f52de9
commit
ed92cdc74c
|
@ -20,7 +20,7 @@
|
||||||
Version Date Action Description
|
Version Date Action Description
|
||||||
--------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
0.9.1.0 20191216 integrate - Added pin specifications from Tasmota WEB UI
|
0.9.1.0 20191216 integrate - Added pin specifications from Tasmota WEB UI. Minor tweaks.
|
||||||
---
|
---
|
||||||
0.9.0.0 20190817 started - further development by Christian Baars - https://github.com/Staars/Sonoff-Tasmota
|
0.9.0.0 20190817 started - further development by Christian Baars - https://github.com/Staars/Sonoff-Tasmota
|
||||||
forked - from arendst/tasmota - https://github.com/arendst/Sonoff-Tasmota
|
forked - from arendst/tasmota - https://github.com/arendst/Sonoff-Tasmota
|
||||||
|
@ -299,17 +299,6 @@ void UBXinitCFG(void){
|
||||||
UBXSerial->write( pgm_read_byte(UBLOX_INIT+i) );
|
UBXSerial->write( pgm_read_byte(UBLOX_INIT+i) );
|
||||||
}
|
}
|
||||||
DEBUG_SENSOR_LOG(PSTR("UBX: turn off NMEA"));
|
DEBUG_SENSOR_LOG(PSTR("UBX: turn off NMEA"));
|
||||||
|
|
||||||
/*
|
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " GA #%d: %s " D_TO " %d/%d/%d"),
|
|
||||||
Settings.knx_GA_registered,
|
|
||||||
device_param_ga[GAop-1],
|
|
||||||
GA_FNUM, GA_AREA, GA_FDEF );
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UBXTriggerTele(void){
|
void UBXTriggerTele(void){
|
||||||
|
@ -435,11 +424,10 @@ uint32_t UBXprocessGPS() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// DEBUG_SENSOR_LOG(PSTR("UBX: got none or unknown Message"));
|
// DEBUG_SENSOR_LOG(PSTR("UBX: got none or unknown Message"));
|
||||||
if(data_bytes!=0){
|
if(data_bytes!=0) {
|
||||||
UBX.state.non_empty_loops++;
|
UBX.state.non_empty_loops++;
|
||||||
DEBUG_SENSOR_LOG(PSTR("UBX: got %u bytes, non-empty-loop: %u"), data_bytes, UBX.state.non_empty_loops);
|
DEBUG_SENSOR_LOG(PSTR("UBX: got %u bytes, non-empty-loop: %u"), data_bytes, UBX.state.non_empty_loops);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
UBX.state.non_empty_loops = 0; // now a hidden GPS-device reset is unlikely
|
UBX.state.non_empty_loops = 0; // now a hidden GPS-device reset is unlikely
|
||||||
}
|
}
|
||||||
return MT_NONE;
|
return MT_NONE;
|
||||||
|
@ -449,7 +437,7 @@ uint32_t UBXprocessGPS() {
|
||||||
| * callback functions for the download
|
| * callback functions for the download
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
#ifdef USE_FLOG
|
#ifdef USE_FLOG
|
||||||
void UBXsendHeader(void){
|
void UBXsendHeader(void) {
|
||||||
WebServer->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
WebServer->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||||
WebServer->sendHeader(F("Content-Disposition"), F("attachment; filename=TASMOTA.gpx"));
|
WebServer->sendHeader(F("Content-Disposition"), F("attachment; filename=TASMOTA.gpx"));
|
||||||
WSSend(200, CT_STREAM, F(
|
WSSend(200, CT_STREAM, F(
|
||||||
|
@ -461,17 +449,17 @@ void UBXsendHeader(void){
|
||||||
}
|
}
|
||||||
|
|
||||||
void UBXsendRecord(uint8_t *buf){
|
void UBXsendRecord(uint8_t *buf){
|
||||||
char record[100];
|
char record[100];
|
||||||
char stime[32];
|
char stime[32];
|
||||||
UBX_t::entry_t *entry = (UBX_t::entry_t*)buf;
|
UBX_t::entry_t *entry = (UBX_t::entry_t*)buf;
|
||||||
snprintf_P(stime, sizeof(stime), GetDT(entry->time).c_str());
|
snprintf_P(stime, sizeof(stime), GetDT(entry->time).c_str());
|
||||||
char lat[12];
|
char lat[12];
|
||||||
char lon[12];
|
char lon[12];
|
||||||
dtostrfd((double)entry->lat/10000000.0f,7,lat);
|
dtostrfd((double)entry->lat/10000000.0f,7,lat);
|
||||||
dtostrfd((double)entry->lon/10000000.0f,7,lon);
|
dtostrfd((double)entry->lon/10000000.0f,7,lon);
|
||||||
snprintf_P(record, sizeof(record),PSTR("<trkpt\n\t lat=\"%s\" lon=\"%s\">\n\t<time>%s</time>\n</trkpt>\n"),lat ,lon, stime);
|
snprintf_P(record, sizeof(record),PSTR("<trkpt\n\t lat=\"%s\" lon=\"%s\">\n\t<time>%s</time>\n</trkpt>\n"),lat ,lon, stime);
|
||||||
// DEBUG_SENSOR_LOG(PSTR("FLOG: DL %u %u"), Flog->sector.dword_buffer[k+j],Flog->sector.dword_buffer[k+j+1]);
|
// DEBUG_SENSOR_LOG(PSTR("FLOG: DL %u %u"), Flog->sector.dword_buffer[k+j],Flog->sector.dword_buffer[k+j+1]);
|
||||||
WebServer->sendContent_P(record);
|
WebServer->sendContent_P(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UBXsendFooter(void){
|
void UBXsendFooter(void){
|
||||||
|
@ -482,8 +470,8 @@ void UBXsendFooter(void){
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
void UBXsendFile(void){
|
void UBXsendFile(void){
|
||||||
if (!HttpCheckPriviledgedAccess()) { return; }
|
if (!HttpCheckPriviledgedAccess()) { return; }
|
||||||
Flog->startDownload(sizeof(UBX.rec_buffer),UBXsendHeader,UBXsendRecord,UBXsendFooter);
|
Flog->startDownload(sizeof(UBX.rec_buffer),UBXsendHeader,UBXsendRecord,UBXsendFooter);
|
||||||
}
|
}
|
||||||
#endif //USE_FLOG
|
#endif //USE_FLOG
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
|
@ -512,69 +500,67 @@ void UBXSetRate(uint16_t interval){
|
||||||
|
|
||||||
|
|
||||||
void UBXSelectMode(uint16_t mode){
|
void UBXSelectMode(uint16_t mode){
|
||||||
DEBUG_SENSOR_LOG(PSTR("UBX: set mode to %u"),mode);
|
DEBUG_SENSOR_LOG(PSTR("UBX: set mode to %u"),mode);
|
||||||
switch(mode){
|
switch(mode){
|
||||||
#ifdef USE_FLOG
|
#ifdef USE_FLOG
|
||||||
case 0:
|
case 0:
|
||||||
Flog->mode = 0; // write once to all available sectors, then stop
|
Flog->mode = 0; // write once to all available sectors, then stop
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Flog->mode = 1; // write to all available sectors, then restart and overwrite the older ones
|
Flog->mode = 1; // write to all available sectors, then restart and overwrite the older ones
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
UBX.mode.filter_noise = true; // filter out horizontal drift noise, TODO: find useful values
|
UBX.mode.filter_noise = true; // filter out horizontal drift noise, TODO: find useful values
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
UBX.mode.filter_noise = false;
|
UBX.mode.filter_noise = false;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
Flog->startRecording(true);
|
Flog->startRecording(true);
|
||||||
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: start recording - appending"));
|
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: start recording - appending"));
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
Flog->startRecording(false);
|
Flog->startRecording(false);
|
||||||
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: start recording - new log"));
|
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: start recording - new log"));
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if(Flog->recording == true){
|
if(Flog->recording == true){
|
||||||
Flog->stopRecording();
|
Flog->stopRecording();
|
||||||
}
|
}
|
||||||
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: stop recording"));
|
AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: stop recording"));
|
||||||
break;
|
break;
|
||||||
|
#endif //USE_FLOG
|
||||||
case 7:
|
case 7:
|
||||||
UBX.mode.send_when_new = 1; // send mqtt on new postion + TELE -> consider to set TELE to a very high value
|
UBX.mode.send_when_new = 1; // send mqtt on new postion + TELE -> consider to set TELE to a very high value
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
UBX.mode.send_when_new = 0; // only TELE
|
UBX.mode.send_when_new = 0; // only TELE
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
if (timeServer.beginListening()){
|
if (timeServer.beginListening()){
|
||||||
UBX.mode.runningNTP = true;
|
UBX.mode.runningNTP = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
UBX.mode.runningNTP = false;
|
UBX.mode.runningNTP = false;
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
UBX.mode.forceUTCupdate = true;
|
UBX.mode.forceUTCupdate = true;
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
UBX.mode.forceUTCupdate = false;
|
UBX.mode.forceUTCupdate = false;
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
Settings.latitude = UBX.state.last_lat;
|
Settings.latitude = UBX.state.last_lat;
|
||||||
Settings.longitude = UBX.state.last_lon;
|
Settings.longitude = UBX.state.last_lon;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
#endif //USE_FLOG
|
|
||||||
default:
|
default:
|
||||||
if(mode>1000 && mode <1066) {
|
if(mode>1000 && mode <1066) {
|
||||||
// UBXSetRate(mode-1000); // min. 1001 = 0.001 Hz, but will be converted to 1/65535 anyway ~0.015 Hz, max. 2000 = 1.000 Hz
|
// UBXSetRate(mode-1000); // min. 1001 = 0.001 Hz, but will be converted to 1/65535 anyway ~0.015 Hz, max. 2000 = 1.000 Hz
|
||||||
UBXSetRate(mode-1000); // set interval between measurements in seconds from 1 to 65
|
UBXSetRate(mode-1000); // set interval between measurements in seconds from 1 to 65
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UBX.mode.send_UI_only = true;
|
UBX.mode.send_UI_only = true;
|
||||||
UBXTriggerTele();
|
UBXTriggerTele();
|
||||||
}
|
}
|
||||||
|
@ -601,8 +587,7 @@ bool UBXHandlePOSLLH(){
|
||||||
UBXTriggerTele();
|
UBXTriggerTele();
|
||||||
}
|
}
|
||||||
return true; // new position
|
return true; // new position
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
DEBUG_SENSOR_LOG(PSTR("UBX: no valid position data"));
|
DEBUG_SENSOR_LOG(PSTR("UBX: no valid position data"));
|
||||||
}
|
}
|
||||||
return false; // no GPS-fix
|
return false; // no GPS-fix
|
||||||
|
@ -611,12 +596,13 @@ bool UBXHandlePOSLLH(){
|
||||||
void UBXHandleSTATUS(){
|
void UBXHandleSTATUS(){
|
||||||
DEBUG_SENSOR_LOG(PSTR("UBX: gpsFix: %u, valid: %u"),UBX.Message.navStatus.gpsFix, (UBX.Message.navStatus.flags)&1);
|
DEBUG_SENSOR_LOG(PSTR("UBX: gpsFix: %u, valid: %u"),UBX.Message.navStatus.gpsFix, (UBX.Message.navStatus.flags)&1);
|
||||||
if((UBX.Message.navStatus.flags)&1){
|
if((UBX.Message.navStatus.flags)&1){
|
||||||
UBX.state.gpsFix = UBX.Message.navStatus.gpsFix; //only store fixed status if flag is valid
|
UBX.state.gpsFix = UBX.Message.navStatus.gpsFix; //only store fixed status if flag is valid
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
UBX.state.gpsFix = 0; // without valid flag, everything is "no fix"
|
UBX.state.gpsFix = 0; // without valid flag, everything is "no fix"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UBXHandleTIME(){
|
void UBXHandleTIME(){
|
||||||
DEBUG_SENSOR_LOG(PSTR("UBX: UTC-Time: %u-%u-%u %u:%u:%u"),UBX.Message.navTime.year, UBX.Message.navTime.month ,UBX.Message.navTime.day,UBX.Message.navTime.hour,UBX.Message.navTime.min,UBX.Message.navTime.sec);
|
DEBUG_SENSOR_LOG(PSTR("UBX: UTC-Time: %u-%u-%u %u:%u:%u"),UBX.Message.navTime.year, UBX.Message.navTime.month ,UBX.Message.navTime.day,UBX.Message.navTime.hour,UBX.Message.navTime.min,UBX.Message.navTime.sec);
|
||||||
if(UBX.Message.navTime.valid.UTC){
|
if(UBX.Message.navTime.valid.UTC){
|
||||||
|
@ -636,7 +622,8 @@ void UBXHandleTIME(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UBXHandleOther(void){
|
void UBXHandleOther(void)
|
||||||
|
{
|
||||||
if(UBX.state.non_empty_loops>6){ // we expect only 4-5 non-empty loops in a row, could change with other sensor speed (Hz)
|
if(UBX.state.non_empty_loops>6){ // we expect only 4-5 non-empty loops in a row, could change with other sensor speed (Hz)
|
||||||
UBXinitCFG(); // this should only happen with lots of NMEA-messages, but it is only a guess!!
|
UBXinitCFG(); // this should only happen with lots of NMEA-messages, but it is only a guess!!
|
||||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("UBX: possible device-reset, will re-init"));
|
AddLog_P(LOG_LEVEL_ERROR, PSTR("UBX: possible device-reset, will re-init"));
|
||||||
|
@ -647,7 +634,8 @@ void UBXHandleOther(void){
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
|
|
||||||
void UBXTimeServer(){
|
void UBXTimeServer()
|
||||||
|
{
|
||||||
if(UBX.mode.runningNTP){
|
if(UBX.mode.runningNTP){
|
||||||
timeServer.processOneRequest(Rtc.utc_time, UBX.state.last_iTOW%1000);
|
timeServer.processOneRequest(Rtc.utc_time, UBX.state.last_iTOW%1000);
|
||||||
}
|
}
|
||||||
|
@ -662,17 +650,17 @@ void UBXLoop(void)
|
||||||
|
|
||||||
switch(msgType){
|
switch(msgType){
|
||||||
case MT_NAV_POSLLH:
|
case MT_NAV_POSLLH:
|
||||||
new_position = UBXHandlePOSLLH();
|
new_position = UBXHandlePOSLLH();
|
||||||
break;
|
break;
|
||||||
case MT_NAV_STATUS:
|
case MT_NAV_STATUS:
|
||||||
UBXHandleSTATUS();
|
UBXHandleSTATUS();
|
||||||
break;
|
break;
|
||||||
case MT_NAV_TIME:
|
case MT_NAV_TIME:
|
||||||
UBXHandleTIME();
|
UBXHandleTIME();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UBXHandleOther();
|
UBXHandleOther();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FLOG
|
#ifdef USE_FLOG
|
||||||
|
@ -752,8 +740,7 @@ void UBXShow(bool json)
|
||||||
if(UBX.mode.send_UI_only){
|
if(UBX.mode.send_UI_only){
|
||||||
uint32_t i = UBX.state.log_interval / 10;
|
uint32_t i = UBX.state.log_interval / 10;
|
||||||
ResponseAppend_P(PSTR("\"fil\":%u,\"int\":%u}"),UBX.mode.filter_noise, i);
|
ResponseAppend_P(PSTR("\"fil\":%u,\"int\":%u}"),UBX.mode.filter_noise, i);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
ResponseAppend_P(PSTR("\"lat\":%s,\"lon\":%s,\"height\":%s,\"hAcc\":%s,\"vAcc\":%s}"), lat, lon, height, hAcc, vAcc);
|
ResponseAppend_P(PSTR("\"lat\":%s,\"lon\":%s,\"height\":%s,\"hAcc\":%s,\"vAcc\":%s}"), lat, lon, height, hAcc, vAcc);
|
||||||
}
|
}
|
||||||
#ifdef USE_FLOG
|
#ifdef USE_FLOG
|
||||||
|
@ -768,7 +755,7 @@ void UBXShow(bool json)
|
||||||
#ifdef USE_FLOG
|
#ifdef USE_FLOG
|
||||||
WSContentSend_PD(HTTP_SNS_FLOGVER, Flog->num_sectors, Flog->size, Flog->current_sector, Flog->sectors_left, Flog->sector.header.physical_start_sector);
|
WSContentSend_PD(HTTP_SNS_FLOGVER, Flog->num_sectors, Flog->size, Flog->current_sector, Flog->sectors_left, Flog->sector.header.physical_start_sector);
|
||||||
if(Flog->recording){
|
if(Flog->recording){
|
||||||
WSContentSend_PD(HTTP_SNS_FLOGREC, Flog->sector.header.buf_pointer - 8);
|
WSContentSend_PD(HTTP_SNS_FLOGREC, Flog->sector.header.buf_pointer - 8);
|
||||||
}
|
}
|
||||||
#endif //USE_FLOG
|
#endif //USE_FLOG
|
||||||
#endif // DEBUG_TASMOTA_SENSOR
|
#endif // DEBUG_TASMOTA_SENSOR
|
||||||
|
@ -794,10 +781,10 @@ void UBXShow(bool json)
|
||||||
|
|
||||||
bool UBXCmd(void) {
|
bool UBXCmd(void) {
|
||||||
bool serviced = true;
|
bool serviced = true;
|
||||||
if (XdrvMailbox.data_len > 0) {
|
if (XdrvMailbox.data_len > 0) {
|
||||||
UBXSelectMode(XdrvMailbox.payload);
|
UBXSelectMode(XdrvMailbox.payload);
|
||||||
Response_P(S_JSON_UBX_COMMAND_NVALUE, XdrvMailbox.command, XdrvMailbox.payload);
|
Response_P(S_JSON_UBX_COMMAND_NVALUE, XdrvMailbox.command, XdrvMailbox.payload);
|
||||||
}
|
}
|
||||||
return serviced;
|
return serviced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,7 +792,7 @@ bool UBXCmd(void) {
|
||||||
* Interface
|
* Interface
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#define XSNS_58 58
|
#define XSNS_58 58
|
||||||
|
|
||||||
bool Xsns58(uint8_t function)
|
bool Xsns58(uint8_t function)
|
||||||
{
|
{
|
||||||
|
@ -816,12 +803,12 @@ bool Xsns58(uint8_t function)
|
||||||
case FUNC_INIT:
|
case FUNC_INIT:
|
||||||
UBXDetect();
|
UBXDetect();
|
||||||
break;
|
break;
|
||||||
case FUNC_COMMAND_SENSOR:
|
case FUNC_COMMAND_SENSOR:
|
||||||
if (XSNS_92 == XdrvMailbox.index){
|
if (XSNS_58 == XdrvMailbox.index){
|
||||||
result = UBXCmd();
|
result = UBXCmd();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FUNC_EVERY_50_MSECOND:
|
case FUNC_EVERY_50_MSECOND:
|
||||||
UBXTimeServer();
|
UBXTimeServer();
|
||||||
break;
|
break;
|
||||||
case FUNC_EVERY_100_MSECOND:
|
case FUNC_EVERY_100_MSECOND:
|
||||||
|
@ -834,8 +821,8 @@ bool Xsns58(uint8_t function)
|
||||||
break;
|
break;
|
||||||
#ifdef USE_FLOG
|
#ifdef USE_FLOG
|
||||||
case FUNC_WEB_ADD_HANDLER:
|
case FUNC_WEB_ADD_HANDLER:
|
||||||
WebServer->on("/UBX", UBXsendFile);
|
WebServer->on("/UBX", UBXsendFile);
|
||||||
break;
|
break;
|
||||||
#endif //USE_FLOG
|
#endif //USE_FLOG
|
||||||
case FUNC_JSON_APPEND:
|
case FUNC_JSON_APPEND:
|
||||||
UBXShow(1);
|
UBXShow(1);
|
||||||
|
|
Loading…
Reference in New Issue