Bluetooth: Mesh: Move model_find to public header

Allows models to find each other without direct access to the
composition data.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This commit is contained in:
Trond Einar Snekvik 2019-08-20 10:59:42 +02:00 committed by Johan Hedberg
commit b2463a7126
3 changed files with 25 additions and 7 deletions

View file

@ -415,6 +415,29 @@ int bt_mesh_model_publish(struct bt_mesh_model *model);
*/
struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod);
/** @brief Find a SIG model.
*
* @param elem Element to search for the model in.
* @param id Model ID of the model.
*
* @return A pointer to the Mesh model matching the given parameters, or NULL
* if no SIG model with the given ID exists in the given element.
*/
struct bt_mesh_model *bt_mesh_model_find(const struct bt_mesh_elem *elem,
u16_t id);
/** @brief Find a vendor model.
*
* @param elem Element to search for the model in.
* @param company Company ID of the model.
* @param id Model ID of the model.
*
* @return A pointer to the Mesh model matching the given parameters, or NULL
* if no vendor model with the given ID exists in the given element.
*/
struct bt_mesh_model *bt_mesh_model_find_vnd(const struct bt_mesh_elem *elem,
u16_t company, u16_t id);
/** Node Composition */
struct bt_mesh_comp {
u16_t cid;

View file

@ -730,7 +730,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
return 0;
}
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
struct bt_mesh_model *bt_mesh_model_find_vnd(const struct bt_mesh_elem *elem,
u16_t company, u16_t id)
{
u8_t i;
@ -745,7 +745,7 @@ struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
return NULL;
}
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem,
struct bt_mesh_model *bt_mesh_model_find(const struct bt_mesh_elem *elem,
u16_t id)
{
u8_t i;

View file

@ -20,11 +20,6 @@ u8_t bt_mesh_elem_count(void);
/* Find local element based on unicast or group address */
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr);
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
u16_t company, u16_t id);
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem,
u16_t id);
u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr);
bool bt_mesh_fixed_group_match(u16_t addr);