mirror of https://github.com/arendst/Tasmota.git
add error checking for init
This commit is contained in:
parent
ffb388dcb1
commit
6c189b40bf
|
@ -246,6 +246,7 @@ struct UBX_t {
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
uint32_t init:1;
|
||||||
uint32_t filter_noise:1;
|
uint32_t filter_noise:1;
|
||||||
uint32_t send_when_new:1; // no teleinterval
|
uint32_t send_when_new:1; // no teleinterval
|
||||||
uint32_t send_UI_only:1;
|
uint32_t send_UI_only:1;
|
||||||
|
@ -321,6 +322,7 @@ void UBXTriggerTele(void)
|
||||||
|
|
||||||
void UBXDetect(void)
|
void UBXDetect(void)
|
||||||
{
|
{
|
||||||
|
UBX.mode.init = 0;
|
||||||
if ((pin[GPIO_GPS_RX] < 99) && (pin[GPIO_GPS_TX] < 99)) {
|
if ((pin[GPIO_GPS_RX] < 99) && (pin[GPIO_GPS_TX] < 99)) {
|
||||||
UBXSerial = new TasmotaSerial(pin[GPIO_GPS_RX], pin[GPIO_GPS_TX], 1, 0, 96); // 64 byte buffer is NOT enough
|
UBXSerial = new TasmotaSerial(pin[GPIO_GPS_RX], pin[GPIO_GPS_TX], 1, 0, 96); // 64 byte buffer is NOT enough
|
||||||
if (UBXSerial->begin(9600)) {
|
if (UBXSerial->begin(9600)) {
|
||||||
|
@ -331,8 +333,13 @@ void UBXDetect(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UBXinitCFG(); // turn off NMEA, only use "our" UBX-messages
|
||||||
|
UBX.mode.init = 1;
|
||||||
|
|
||||||
UBXinitCFG(); // turn of NMEA, only use "our" UBX-messages
|
|
||||||
#ifdef USE_FLOG
|
#ifdef USE_FLOG
|
||||||
if (!Flog) {
|
if (!Flog) {
|
||||||
Flog = new FLOG; // init Flash Log
|
Flog = new FLOG; // init Flash Log
|
||||||
|
@ -813,11 +820,12 @@ bool Xsns60(uint8_t function)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (true) {
|
if (FUNC_INIT == function) {
|
||||||
|
UBXDetect();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UBX.mode.init) {
|
||||||
switch (function) {
|
switch (function) {
|
||||||
case FUNC_INIT:
|
|
||||||
UBXDetect();
|
|
||||||
break;
|
|
||||||
case FUNC_COMMAND_SENSOR:
|
case FUNC_COMMAND_SENSOR:
|
||||||
if (XSNS_60 == XdrvMailbox.index) {
|
if (XSNS_60 == XdrvMailbox.index) {
|
||||||
result = UBXCmd();
|
result = UBXCmd();
|
||||||
|
|
Loading…
Reference in New Issue