psudo discovery from Appendix E
This commit is contained in:
parent
57c3247eaf
commit
0124123a71
|
@ -46,11 +46,120 @@ Controller::~Controller()
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Controller::findDevices
|
||||
* @param lowerBound
|
||||
* @param upperBound
|
||||
* @return
|
||||
*/
|
||||
bool Controller::findDevices(uint64_t lowerBound, uint64_t upperBound) const
|
||||
{
|
||||
bool device_found = false;
|
||||
bool response_received = false;
|
||||
|
||||
/// we have called to the lowest branch and are testing
|
||||
/// for a single device.
|
||||
if (lowerBound == upperBound) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// response_received = sendDiscMute(lowerBound);
|
||||
if (response_received)
|
||||
break;
|
||||
}
|
||||
if ( response_received ) {
|
||||
// Add device found at ‘LowerBound’ to list.
|
||||
}
|
||||
return !(response_received);
|
||||
}
|
||||
|
||||
/// look for a lower branch with active devices.
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// response_received = sendDiscUniqueBranch(lowerBound, upperBound);
|
||||
if (response_received)
|
||||
break;
|
||||
}
|
||||
|
||||
if ( response_received ) {
|
||||
device_found = true;
|
||||
|
||||
// check for single good response.
|
||||
// !!! remove during FULL DEBUGGING VALIDATION begin
|
||||
// if ( response checksum passes )// possibly only one device in branch.
|
||||
// {
|
||||
// // shortcut to avoid branching all the way down.
|
||||
// deviceFound = quick_find(response uid, lowerBound, upperBound);
|
||||
// }
|
||||
// !!! remove during FULL DEBUGGING VALIDATION end
|
||||
|
||||
/// choose next branches to test
|
||||
if (device_found == true ) { // Quick_Find indicates there are multiple devices in branch.
|
||||
uint64_t midPosition;
|
||||
midPosition = ((lowerBound & (0x0000800000000000-1)) +
|
||||
(upperBound & (0x0000800000000000-1))) / 2
|
||||
+ ((upperBound & 0x0000800000000000) ? 0x0000400000000000 : 0)
|
||||
+ ((lowerBound & 0x0000800000000000) ? 0x0000400000000000 :0);
|
||||
//go into next branch fork.
|
||||
device_found = findDevices(midPosition + 1, upperBound);
|
||||
device_found |= findDevices (lowerBound, midPosition);
|
||||
}
|
||||
}
|
||||
return device_found;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Controller::quick_find
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
bool Controller::quick_find([[maybe_unused]] const UID& uid,
|
||||
[[maybe_unused]] uint64_t lowerBound,
|
||||
[[maybe_unused]] uint64_t upperBound) const
|
||||
{
|
||||
/// The call to this sub-function should be removed during full discovery
|
||||
/// testing as it can mask other problems in the discovery implementation.
|
||||
|
||||
/// This sub-function can speed up discovery when there is only one device in
|
||||
/// the current branch by eliminating the need to fully branch to the lowest
|
||||
/// level of the discovery tree.
|
||||
|
||||
bool response_received = false;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// response_received = sendDiscMute(uid.uid);
|
||||
if (response_received)
|
||||
break;
|
||||
}
|
||||
|
||||
if ( response_received ) {
|
||||
// Add device found at ‘LowerBound’ to list.
|
||||
}
|
||||
|
||||
/// verify there is no other devices in this branch.
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// response_received = sendDiscUniqueBranch(lowerBound, upperBound);
|
||||
if (response_received)
|
||||
break;
|
||||
}
|
||||
|
||||
// if (response_received && checksum passed)
|
||||
// /// there is another single device response at this branch.
|
||||
// {
|
||||
// // return quick_find(response uid, lowerBound, upperBound);
|
||||
// }
|
||||
// else if (response_received && checksum failed)
|
||||
// /// there are possibly multiple devices... branch further
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Controller::rxDiscoveryResponse
|
||||
* @param message
|
||||
*/
|
||||
void Controller::rxDiscoveryResponse(__attribute__((unused)) const MsgPtr message)
|
||||
void Controller::rxDiscoveryResponse([[maybe_unused]] const MsgPtr message)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -60,7 +169,7 @@ void Controller::rxDiscoveryResponse(__attribute__((unused)) const MsgPtr messag
|
|||
* @brief Controller::rxGetResponse
|
||||
* @param message
|
||||
*/
|
||||
void Controller::rxGetResponse(__attribute__((unused)) const MsgPtr message)
|
||||
void Controller::rxGetResponse([[maybe_unused]] const MsgPtr message)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -70,7 +179,7 @@ void Controller::rxGetResponse(__attribute__((unused)) const MsgPtr message)
|
|||
* @brief Controller::rxSetResponse
|
||||
* @param message
|
||||
*/
|
||||
void Controller::rxSetResponse(__attribute__((unused)) const MsgPtr message)
|
||||
void Controller::rxSetResponse([[maybe_unused]] const MsgPtr message)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,12 @@ public:
|
|||
Controller();
|
||||
~Controller();
|
||||
|
||||
bool findDevices(uint64_t lowerBound = 0,
|
||||
uint64_t upperBound = 0xFFFFFFFFFFFE) const;
|
||||
|
||||
protected:
|
||||
bool quick_find(const UID &uid, uint64_t lowerBound, uint64_t upperBound) const;
|
||||
|
||||
virtual void rxDiscoveryResponse(const MsgPtr message);
|
||||
virtual void rxGetResponse(const MsgPtr message);
|
||||
virtual void rxSetResponse(const MsgPtr message);
|
||||
|
|
Loading…
Reference in New Issue