Use static MPM protolist on simu

Resolves #1793
This commit is contained in:
Raphael Coeffic
2022-04-18 10:18:17 +02:00
committed by Raphael Coeffic
parent 97d26b6088
commit f39f7a87ed
2 changed files with 53 additions and 41 deletions
+21 -10
View File
@@ -52,6 +52,14 @@ constexpr uint8_t MULTI_INVALID_PROTO = 0xFF;
constexpr uint32_t MULTI_PROTOLIST_TIMEOUT = 100; // 100ms constexpr uint32_t MULTI_PROTOLIST_TIMEOUT = 100; // 100ms
constexpr uint32_t MULTI_PROTOLIST_START_TIMEOUT = 3000; // 3s constexpr uint32_t MULTI_PROTOLIST_START_TIMEOUT = 3000; // 3s
MultiRfProtocols::MultiRfProtocols(unsigned int moduleIdx) : moduleIdx(moduleIdx)
{
#if defined(SIMU)
// prevent scanning from starting on simu
fillBuiltinProtos();
#endif
}
bool MultiRfProtocols::RfProto::parse(const uint8_t* data, uint8_t len) bool MultiRfProtocols::RfProto::parse(const uint8_t* data, uint8_t len)
{ {
const char* s = (const char*)data; const char* s = (const char*)data;
@@ -297,7 +305,18 @@ bool MultiRfProtocols::scanReply(const uint8_t* packet, uint8_t len)
break; break;
case ScanInvalid: { case ScanInvalid: {
// TODO: fill with static list (sorted) fillBuiltinProtos();
} break;
default:
break;
}
return false;
}
void MultiRfProtocols::fillBuiltinProtos()
{
const mm_protocol_definition* pdef = const mm_protocol_definition* pdef =
getMultiProtocolDefinition(MODULE_SUBTYPE_MULTI_FIRST); getMultiProtocolDefinition(MODULE_SUBTYPE_MULTI_FIRST);
@@ -310,8 +329,7 @@ bool MultiRfProtocols::scanReply(const uint8_t* packet, uint8_t len)
if (pdef->protocol == MM_RF_CUSTOM_SELECTED) break; // skip custom proto if (pdef->protocol == MM_RF_CUSTOM_SELECTED) break; // skip custom proto
char tmp[8]; char tmp[8];
rfProto.label = rfProto.label = getStringAtIndex(tmp, STR_MULTI_PROTOCOLS, pdef->protocol);
getStringAtIndex(tmp, STR_MULTI_PROTOCOLS, pdef->protocol);
rfProto.flags = rfProto.flags =
(pdef->failsafe ? 0x01 : 0) | (pdef->disable_ch_mapping ? 0x02 : 0); (pdef->failsafe ? 0x01 : 0) | (pdef->disable_ch_mapping ? 0x02 : 0);
@@ -337,11 +355,4 @@ bool MultiRfProtocols::scanReply(const uint8_t* packet, uint8_t len)
scanState = ScanEnd; scanState = ScanEnd;
setModuleMode(moduleIdx, MODULE_MODE_NORMAL); setModuleMode(moduleIdx, MODULE_MODE_NORMAL);
} break;
default:
break;
}
return false;
} }
+2 -1
View File
@@ -42,7 +42,8 @@ class MultiRfProtocols
uint8_t currentProto = 0; uint8_t currentProto = 0;
uint8_t totalProtos = 0; uint8_t totalProtos = 0;
MultiRfProtocols(unsigned int moduleIdx) : moduleIdx(moduleIdx) {} MultiRfProtocols(unsigned int moduleIdx);
void fillBuiltinProtos();
public: public: