Function NextDescriptorRangeToExplore

Synopsis

#include <bta/gatt/database_builder.h>

std::pair< uint16_t, uint16_t > NextDescriptorRangeToExplore()

Description

No description yet.

Source

Lines 145-176 in bta/gatt/database_builder.cc. Line 52 in bta/gatt/database_builder.h.

std::pair<uint16_t, uint16_t> DatabaseBuilder::NextDescriptorRangeToExplore() {
  Service* service = FindService(database.services, pending_service.first);
  if (!service || service->characteristics.empty()) {
    return {HANDLE_MAX, HANDLE_MAX};
  }

  for (auto it = service->characteristics.cbegin();
       it != service->characteristics.cend(); it++) {
    if (it->declaration_handle > pending_characteristic) {
      auto next = std::next(it);

      /* Characteristic Declaration is followed by Characteristic Value
       * Declaration, first descriptor is after that, see BT Spect 5.0 Vol 3,
       * Part G 3.3.2 and 3.3.3 */
      uint16_t start = it->declaration_handle + 2;
      uint16_t end;
      if (next != service->characteristics.end())
        end = next->declaration_handle - 1;
      else
        end = service->end_handle;

      // No place for descriptor - skip to next characteristic
      if (start > end) continue;

      pending_characteristic = start;
      return {start, end};
    }
  }

  pending_characteristic = HANDLE_MAX;
  return {HANDLE_MAX, HANDLE_MAX};
}





Add Discussion as Guest

Log in to DocsForge