Bluetooth: Mesh: Add model callback structure

Adds a structure of callbacks for each model instance. This allows for
more flexible model implementations, that can interact with the Mesh
stack without going through the application.

For now, only an init callback is added, replacing the init mechanism in
the foundation models. The init callback does not provide the primary
flag that used to be in the foundation model callbacks, but replaces
this with an inline function in access.h.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This commit is contained in:
Trond Einar Snekvik 2019-08-19 10:05:36 +02:00 committed by Johan Hedberg
commit c2c05c916a
11 changed files with 147 additions and 73 deletions

View file

@ -384,12 +384,12 @@ static void attention_off(struct k_work *work)
}
}
int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary)
static int health_srv_init(struct bt_mesh_model *model)
{
struct bt_mesh_health_srv *srv = model->user_data;
if (!srv) {
if (!primary) {
if (!bt_mesh_model_in_primary(model)) {
return 0;
}
@ -408,13 +408,17 @@ int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary)
srv->model = model;
if (primary) {
if (bt_mesh_model_in_primary(model)) {
health_srv = srv;
}
return 0;
}
const struct bt_mesh_model_cb bt_mesh_health_srv_cb = {
.init = health_srv_init,
};
void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
{
struct bt_mesh_health_srv *srv;