Separating code concerns for bluetooth mesh models

Hi,

I'm wondering if I'm missing something. I've been creating a bluetooth mesh light with hue, saturation, brightness, on/off, etc. models. However, my model_handler.c file is becoming huge!! I've based it on the nrf examples here, but since

static void led_set(struct bt_mesh_onoff_srv *srv, struct bt_mesh_msg_ctx *ctx,
		    const struct bt_mesh_onoff_set *set,
		    struct bt_mesh_onoff_status *rsp)
{
	struct led_ctx *led = CONTAINER_OF(srv, struct led_ctx, srv);
	int led_idx = led - &led_ctx[0];

....

the setters and getters depend on the led_ctx, and the led_ctx is a composition of the handlers (which contain the setters and getters), I can't seem to move anything out of this one file! Ideally, I'd move all the onoff logic into one file, the hue logic into another file, the context into another file, and the model_handling simply composes these. Am I missing the way to do this with macros I don't know about?

Thanks!

Related