Function Serialize

Synopsis

#include <bta/gatt/database.h>

std::vector< gatt::StoredAttribute > Serialize() const

Description

No description yet.

Source

Lines 81-118 in bta/gatt/database.cc. Line 111 in bta/gatt/database.h.

std::vector<StoredAttribute> Database::Serialize() const {
  std::vector<StoredAttribute> nv_attr;

  if (services.empty()) return std::vector<StoredAttribute>();

  for (const Service& service : services) {
    // TODO: add constructor to NV_ATTR, use emplace_back
    nv_attr.push_back({service.handle,
                       service.is_primary ? PRIMARY_SERVICE : SECONDARY_SERVICE,
                       {.service = {.uuid = service.uuid,
                                    .end_handle = service.end_handle}}});
  }

  for (const Service& service : services) {
    for (const IncludedService& p_isvc : service.included_services) {
      nv_attr.push_back({p_isvc.handle,
                         INCLUDE,
                         {.included_service = {.handle = p_isvc.start_handle,
                                               .end_handle = p_isvc.end_handle,
                                               .uuid = p_isvc.uuid}}});
    }

    for (const Characteristic& charac : service.characteristics) {
      nv_attr.push_back(
          {charac.declaration_handle,
           CHARACTERISTIC,
           {.characteristic = {.properties = charac.properties,
                               .value_handle = charac.value_handle,
                               .uuid = charac.uuid}}});

      for (const Descriptor& desc : charac.descriptors) {
        nv_attr.push_back({desc.handle, desc.uuid, {}});
      }
    }
  }

  return nv_attr;
}





Add Discussion as Guest

Log in to DocsForge