Device Database#

API and Callbacks for the Device Database Component.

This component provides an API to add/remove a device from a list of known devices, and to record their list of endpoints and clusters.

API#

sl_zigbee_af_device_database_find_device_by_status(sl_zigbee_af_device_discovery_status_t status)

Find the first device that matches input status.

Find device by EUI64.

sl_zigbee_af_device_database_add(sl_802154_long_addr_t eui64, uint8_t macCapabilities)

Add to the device database.

bool
sl_zigbee_af_device_database_erase_device(sl_802154_long_addr_t eui64)

Erase device from device database.

bool
sl_zigbee_af_device_database_set_endpoints(const sl_802154_long_addr_t eui64, const uint8_t *endpointList, uint8_t endpointCount)

Set device endpoints.

uint8_t
sl_zigbee_af_device_database_get_device_endpoint_from_index(const sl_802154_long_addr_t eui64, uint8_t index)

Get device endpoint from index.

uint8_t
sl_zigbee_af_device_database_get_index_from_endpoint(uint8_t endpoint, const sl_802154_long_addr_t eui64)

Get endpoint index for a given endpoint value on the specified device.

bool
sl_zigbee_af_device_database_set_clusters_for_endpoint(const sl_802154_long_addr_t eui64, const sl_zigbee_af_cluster_list_t *clusterList)

Set clusters for device endpoint.

bool

Searches for any entries that have a failed discovery state (SL_ZIGBEE_AF_DEVICE_DISCOVERY_STATUS_FAILED) and whose number of failures is less than ::maxFailureCount. Clears those entries' statuses by setting them to SL_ZIGBEE_AF_DEVICE_DISCOVERY_STATUS_NEW.

bool
sl_zigbee_af_device_database_set_status(const sl_802154_long_addr_t deviceEui64, sl_zigbee_af_device_discovery_status_t newStatus)

Set device database status for a given device. This API is used by other components to handle device state when probing the device, for instance. The generic device state is stored in this Device Database component, but this component performs no action based on that state.

sl_zigbee_af_device_database_add_device_with_all_info(const sl_zigbee_af_device_info_t *newDevice)

Add device to database with all information filled out.

sl_zigbee_af_device_database_does_device_have_cluster(sl_802154_long_addr_t deviceEui64, sl_zigbee_af_cluster_id_t clusterToFind, bool server, uint8_t *returnEndpoint)

Check if a device has cluster.

void
sl_zigbee_af_device_database_create_new_search(sl_zigbee_af_device_database_iterator_t *iterator)

Create a new search. Resets iterator starting index to 0.

sl_zigbee_af_device_database_find_device_supporting_cluster(sl_zigbee_af_device_database_iterator_t *iterator, sl_zigbee_af_cluster_id_t clusterToFind, bool server, uint8_t *returnEndpoint)

Finds the next device that supports the given cluster.

API Documentation#

sl_zigbee_af_device_database_get_device_by_index#

const sl_zigbee_af_device_info_t * sl_zigbee_af_device_database_get_device_by_index (uint16_t index)

Get device by index.

Parameters
TypeDirectionArgument NameDescription
uint16_t[in]index

The index into the database.

Returns

  • NULL if no device exists at that index, else a valid pointer to the entry.


sl_zigbee_af_device_database_find_device_by_status#

const sl_zigbee_af_device_info_t * sl_zigbee_af_device_database_find_device_by_status (sl_zigbee_af_device_discovery_status_t status)

Find the first device that matches input status.

Parameters
TypeDirectionArgument NameDescription
sl_zigbee_af_device_discovery_status_t[in]status

The status to look for.

Returns

  • NULL if no device matches status, else a valid pointer to the entry.


sl_zigbee_af_device_database_find_device_by_eui64#

const sl_zigbee_af_device_info_t * sl_zigbee_af_device_database_find_device_by_eui64 (sl_802154_long_addr_t eui64)

Find device by EUI64.

Parameters
TypeDirectionArgument NameDescription
sl_802154_long_addr_t[in]eui64

The EUI to search for.

Returns

  • NULL if device is not found, else a valid pointer to the entry.


sl_zigbee_af_device_database_add#

sl_status_t sl_zigbee_af_device_database_add (sl_802154_long_addr_t eui64, uint8_t macCapabilities)

Add to the device database.

Parameters
TypeDirectionArgument NameDescription
sl_802154_long_addr_t[in]eui64

The EUI to add.

uint8_t[in]macCapabilities

The MAC capabilities for the device.

Returns

  • SL_STATUS_OK upon success, SL_STATUS_ALREADY_EXISTS if device is already in table, else SL_STATUS_FULL if table is full.


sl_zigbee_af_device_database_erase_device#

bool sl_zigbee_af_device_database_erase_device (sl_802154_long_addr_t eui64)

Erase device from device database.

Parameters
TypeDirectionArgument NameDescription
sl_802154_long_addr_t[in]eui64

The EUI to search for.

Returns

  • True if the device is found, else false.


sl_zigbee_af_device_database_set_endpoints#

bool sl_zigbee_af_device_database_set_endpoints (const sl_802154_long_addr_t eui64, const uint8_t * endpointList, uint8_t endpointCount)

Set device endpoints.

Parameters
TypeDirectionArgument NameDescription
const sl_802154_long_addr_t[in]eui64

The EUI to search for.

const uint8_t *[in]endpointList

A list of endpoints to add in the database entry for ::eui64.

uint8_t[in]endpointCount

The length of endpointList.

Returns

  • True if the device is found, else false.


sl_zigbee_af_device_database_get_device_endpoint_from_index#

uint8_t sl_zigbee_af_device_database_get_device_endpoint_from_index (const sl_802154_long_addr_t eui64, uint8_t index)

Get device endpoint from index.

Parameters
TypeDirectionArgument NameDescription
const sl_802154_long_addr_t[in]eui64

The EUI to search for.

uint8_t[in]index

The endpoint index to retrieve.

Returns

  • The endpoint value from the entry at the given index.


sl_zigbee_af_device_database_get_index_from_endpoint#

uint8_t sl_zigbee_af_device_database_get_index_from_endpoint (uint8_t endpoint, const sl_802154_long_addr_t eui64)

Get endpoint index for a given endpoint value on the specified device.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]endpoint

The endpoint relevant to ::eui64.

const sl_802154_long_addr_t[in]eui64

The EUI to search for.

Returns

  • The index at which ::endpoint is stored in the entry for ::eui64, else 0xFF if the device or endpoint are not found.


sl_zigbee_af_device_database_set_clusters_for_endpoint#

bool sl_zigbee_af_device_database_set_clusters_for_endpoint (const sl_802154_long_addr_t eui64, const sl_zigbee_af_cluster_list_t * clusterList)

Set clusters for device endpoint.

Parameters
TypeDirectionArgument NameDescription
const sl_802154_long_addr_t[in]eui64

The EUI to search for.

const sl_zigbee_af_cluster_list_t *[in]clusterList

Cluster and endpoint information from ::eui64.

Returns

  • True upon successful update, else false if device or endpoint on device is not found.

Note


sl_zigbee_af_device_database_clear_all_failed_discovery_status#

bool sl_zigbee_af_device_database_clear_all_failed_discovery_status (uint8_t maxFailureCount)

Searches for any entries that have a failed discovery state (SL_ZIGBEE_AF_DEVICE_DISCOVERY_STATUS_FAILED) and whose number of failures is less than ::maxFailureCount. Clears those entries' statuses by setting them to SL_ZIGBEE_AF_DEVICE_DISCOVERY_STATUS_NEW.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]maxFailureCount

The maximum number of failures to filter for when looking for entries in the SL_ZIGBEE_AF_DEVICE_DISCOVERY_STATUS_FAILED state. If an entry has a failure count greater than or equal to ::maxFailureCount, then its status won't be cleared.

Returns

  • True if at least one entry was cleared, false otherwise.

Note

  • This component works alongside the Device Query Service component, which manages device status in this Device Database component. The user is not expected to call these APIs to update device status.


sl_zigbee_af_device_database_set_status#

bool sl_zigbee_af_device_database_set_status (const sl_802154_long_addr_t deviceEui64, sl_zigbee_af_device_discovery_status_t newStatus)

Set device database status for a given device. This API is used by other components to handle device state when probing the device, for instance. The generic device state is stored in this Device Database component, but this component performs no action based on that state.

Parameters
TypeDirectionArgument NameDescription
const sl_802154_long_addr_t[in]deviceEui64

The EUI to search for.

sl_zigbee_af_device_discovery_status_t[in]newStatus

The status to set.

Returns

  • True if the device is found, else false.

Note

  • This component works alongside the Device Query Service component, which manages device status in this Device Database component. The user is not expected to call these APIs to update device status.


sl_zigbee_af_device_database_add_device_with_all_info#

sl_status_t sl_zigbee_af_device_database_add_device_with_all_info (const sl_zigbee_af_device_info_t * newDevice)

Add device to database with all information filled out.

Parameters
TypeDirectionArgument NameDescription
const sl_zigbee_af_device_info_t *[in]newDevice

Pointer with complete device entry information.

Returns

  • SL_STATUS_OK upon success, SL_STATUS_ALREADY_EXISTS if device is already in table, else SL_STATUS_FULL if table is full.


sl_zigbee_af_device_database_does_device_have_cluster#

sl_status_t sl_zigbee_af_device_database_does_device_have_cluster (sl_802154_long_addr_t deviceEui64, sl_zigbee_af_cluster_id_t clusterToFind, bool server, uint8_t * returnEndpoint)

Check if a device has cluster.

Parameters
TypeDirectionArgument NameDescription
sl_802154_long_addr_t[in]deviceEui64

The EUI to search for.

sl_zigbee_af_cluster_id_t[in]clusterToFind

Cluster to search for.

bool[in]server

True to find server-side cluster, false for client-side.

uint8_t *[out]returnEndpoint

Upon success, filled in with the endpoint matching the input cluster.

Returns

  • SL_STATUS_OK if found, SL_STATUS_INVALID_PARAMETER if device not in database, else SL_STATUS_NOT_FOUND if device is found but no match on cluster.


sl_zigbee_af_device_database_create_new_search#

void sl_zigbee_af_device_database_create_new_search (sl_zigbee_af_device_database_iterator_t * iterator)

Create a new search. Resets iterator starting index to 0.

Parameters
TypeDirectionArgument NameDescription
sl_zigbee_af_device_database_iterator_t *[out]iterator

Param to update. Essentially has its deviceIndex set to 0.

Note

Returns

  • None

Note

  • This function is used when a caller wants to know which index in the database matches a given search criterion.


sl_zigbee_af_device_database_find_device_supporting_cluster#

sl_status_t sl_zigbee_af_device_database_find_device_supporting_cluster (sl_zigbee_af_device_database_iterator_t * iterator, sl_zigbee_af_cluster_id_t clusterToFind, bool server, uint8_t * returnEndpoint)

Finds the next device that supports the given cluster.

Parameters
TypeDirectionArgument NameDescription
sl_zigbee_af_device_database_iterator_t *[inout]iterator

Upon success, deviceIndex field is updated with index of device matching cluster.

sl_zigbee_af_cluster_id_t[in]clusterToFind

Cluster to search for.

bool[in]server

True to find server-side cluster, false for client-side.

uint8_t *[out]returnEndpoint

Upon success, filled in with the endpoint matching the input cluster.

Returns

  • SL_STATUS_OK if found, SL_STATUS_INVALID_INDEX if iterator index is beyond max table size, else SL_STATUS_NOT_FOUND if no device in the database supports the desired cluster.