committed by
Raphael Coeffic
parent
97d26b6088
commit
f39f7a87ed
@@ -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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user