/* Send an OnOff Set message from the Generic OnOff Client to all nodes.  */
static int gen_onoff_send(bool val)
/* Send an OnOff Set message from the Generic OnOff Client to all nodes.  */
static int gen_onoff_send(bool val)
{
	struct bt_mesh_msg_ctx ctx = {
		.app_idx = models[3].keys[0],
		.addr = BT_MESH_ADDR_ALL_NODES,
		.send_ttl = BT_MESH_TTL_DEFAULT,
	};
	static uint8_t tid;
	if (ctx.app_idx == BT_MESH_KEY_UNUSED) {
		printk("The Generic OnOff Client must be bound to a key before "
		       "sending.\n");
		return -ENOENT;
	}
	BT_MESH_MODEL_BUF_DEFINE(buf, OP_ONOFF_SET_UNACK, 2);
	bt_mesh_model_msg_init(&buf, OP_ONOFF_SET_UNACK);
	net_buf_simple_add_u8(&buf, val);
	net_buf_simple_add_u8(&buf, tid++);
	printk("Sending OnOff Set: %s\n", onoff_str[val]);
	return bt_mesh_model_send(&models[3], &ctx, &buf, NULL, NULL);
}