Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

why QLowEnergyService::UnknownError



  • when i call a QLowEnergyService discoverDetails() ,i first receive a stateChange, new State is QLowEnergyService::DiscoveringServices, then i get a error ,it's QLowEnergyService::UnknownError, but QLowEnergyService::ServiceDiscovered didn't appear, i don't know why ? how to find the reason ? I can get nothing from the UnknownError,



  • I had the exact same problem today. Fixed it eventually by making the connection to QLowEnergyController::serviceDiscovered queued (Qt::QueuedConnection).

    I don't really understand why this helps, but apparently the QLowEnergyController cannot create a QLowEnergyService object in an unqueued callback from the serviceDiscovered event. Maybe the internal administration of QlowEnergyController is not completely done yet at the time of the event and creating a service object at that point results in an unknown error (error string is empty, so that also doesn't help). I looked at the code of the Low Energy Scanner example and there they also don't use a queued connection (although the Qt::autoconnection type can result in a queued connection). Looks like a sloppy implementation on QT side: code only works if called from a certain thread and error message is completely uninformative.


Log in to reply