Improve room assistant detection (#268)
This commit is contained in:
parent
5bb652c858
commit
69bf3b1e01
|
@ -456,20 +456,12 @@ bool BleFingerprint::query()
|
|||
pClient->setConnectTimeout(5);
|
||||
if (pClient->connect(address))
|
||||
{
|
||||
if (rmAsst)
|
||||
{
|
||||
auto sRmAst = pClient->getValue(roomAssistantService, rootAssistantCharacteristic);
|
||||
if (!sRmAst.empty())
|
||||
{
|
||||
setId(String("roomAssistant:") + kebabify(sRmAst).c_str(), ID_TYPE_RM_ASST);
|
||||
Serial.printf("%d RmAst | MAC: %s, ID: %-60s %s\n", xPortGetCoreID(), getMac().c_str(), getId().c_str(), sRmAst.c_str());
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
else if (allowQuery)
|
||||
bool iphone = true;
|
||||
if (allowQuery)
|
||||
{
|
||||
auto sMdl = pClient->getValue(deviceInformationService, modelChar);
|
||||
auto sName = pClient->getValue(genericAccessService, nameChar);
|
||||
iphone = sMdl.find("iPhone") == 0;
|
||||
if (!sName.empty() && !sMdl.empty() && sMdl.find(sName) == std::string::npos && sName.compare("Apple Watch") != 0)
|
||||
{
|
||||
Serial.printf("%d Name | MAC: %s, ID: %-60s %s\n", xPortGetCoreID(), getMac().c_str(), getId().c_str(), sName.c_str());
|
||||
|
@ -488,6 +480,18 @@ bool BleFingerprint::query()
|
|||
if (name.isEmpty()) name = sName.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
if (rmAsst || iphone) // For some reason we often don't get room asssistants service advertisement
|
||||
{
|
||||
|
||||
auto sRmAst = pClient->getValue(roomAssistantService, rootAssistantCharacteristic);
|
||||
if (!sRmAst.empty())
|
||||
{
|
||||
setId(String("roomAssistant:") + kebabify(sRmAst).c_str(), ID_TYPE_RM_ASST);
|
||||
Serial.printf("%d RmAst | MAC: %s, ID: %-60s %s\n", xPortGetCoreID(), getMac().c_str(), getId().c_str(), sRmAst.c_str());
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NimBLEDevice::deleteClient(pClient);
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
long getAge() { return millis() - lastSeenMillis; };
|
||||
bool getIgnore() { return ignore; };
|
||||
bool getAllowQuery() { return allowQuery; };
|
||||
bool getRmAsst() { return rmAsst; };
|
||||
int getSeenCount()
|
||||
{
|
||||
auto sc = seenCount;
|
||||
|
|
|
@ -87,10 +87,7 @@ void GUI::connected(bool wifi = false, bool mqtt = false)
|
|||
void GUI::added(BleFingerprint *f)
|
||||
{
|
||||
if (f->getIgnore()) return;
|
||||
if (f->getAllowQuery())
|
||||
Serial.printf("%d New Q | MAC: %s, ID: %-60s %s\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getDiscriminator().c_str());
|
||||
else
|
||||
Serial.printf("%d New | MAC: %s, ID: %-60s %s\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getDiscriminator().c_str());
|
||||
Serial.printf("%d New %s | MAC: %s, ID: %-60s %s\n", xPortGetCoreID(), f->getRmAsst() ? "R" : (f->getAllowQuery() ? "Q" : " "), f->getMac().c_str(), f->getId().c_str(), f->getDiscriminator().c_str());
|
||||
}
|
||||
|
||||
void GUI::removed(BleFingerprint *f, long age)
|
||||
|
|
Loading…
Reference in New Issue