Class DatabaseBuilder

Synopsis

#include <bta/gatt/database_builder.h>

class DatabaseBuilder

Description

No description yet.

Methods

AddCharacteristic
AddDescriptor
AddIncludedService
AddService
Build
Clear
CurrentlyExploredService
InProgress
NextDescriptorRangeToExplore
StartNextServiceExploration
ToString

Source

Lines 28-82 in bta/gatt/database_builder.h.

class DatabaseBuilder {
 public:
  constexpr static std::pair<uint16_t, uint16_t> EXPLORE_END =
      std::make_pair(0xFFFF, 0xFFFF);

  void AddService(uint16_t handle, uint16_t end_handle,
                  const bluetooth::Uuid& uuid, bool is_primary);
  void AddIncludedService(uint16_t handle, const bluetooth::Uuid& uuid,
                          uint16_t start_handle, uint16_t end_handle);
  void AddCharacteristic(uint16_t handle, uint16_t value_handle,
                         const bluetooth::Uuid& uuid, uint8_t properties);
  void AddDescriptor(uint16_t handle, const bluetooth::Uuid& uuid);

  /* Returns true if next service exploration started, false if there are no
   * more services to explore. */
  bool StartNextServiceExploration();

  /* Return pair with start and end handle of the currently explored service.
   */
  const std::pair<uint16_t, uint16_t>& CurrentlyExploredService();

  /* Return pair with start and end handle of the descriptor range to discover,
   * or DatabaseBuilder::EXPLORE_END if no more descriptors left.
   */
  std::pair<uint16_t, uint16_t> NextDescriptorRangeToExplore();

  /* Returns true, if GATT discovery is in progress, false if discovery was not
   * started, or is already finished.
   */
  // TODO(jpawlowski): in the future, we might create this object only for the
  // time of discovery, in such case InProgress won't be needed, because object
  // existence will mean discovery is pending
  bool InProgress() const;

  /* Call this method at end of GATT discovery, to obtain object representing
   * the database of remote device */
  Database Build();

  void Clear();

  /* Return text representation of internal state for debugging purposes */
  std::string ToString() const;

 private:
  Database database;
  /* Start and end handle of service that is currently being discovered on the
   * remote device */
  std::pair<uint16_t, uint16_t> pending_service;
  /* Characteristic inside pending_service that is currently being explored */
  uint16_t pending_characteristic;

  /* sorted, unique set of start_handle, end_handle pair of all services that
   * have not yet been discovered */
  std::set<std::pair<uint16_t, uint16_t>> services_to_discover;
};





Add Discussion as Guest

Log in to DocsForge