54
54
#define BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK BT_MESH_MODEL_OP_2(0x82, 0x03)
55
55
#define BT_MESH_MODEL_OP_GEN_ONOFF_STATUS BT_MESH_MODEL_OP_2(0x82, 0x04)
56
56
57
- static void gen_onoff_set (struct bt_mesh_model * model ,
58
- struct bt_mesh_msg_ctx * ctx ,
59
- struct net_buf_simple * buf );
57
+ static int gen_onoff_set (struct bt_mesh_model * model ,
58
+ struct bt_mesh_msg_ctx * ctx ,
59
+ struct net_buf_simple * buf );
60
60
61
- static void gen_onoff_set_unack (struct bt_mesh_model * model ,
62
- struct bt_mesh_msg_ctx * ctx ,
63
- struct net_buf_simple * buf );
61
+ static int gen_onoff_set_unack (struct bt_mesh_model * model ,
62
+ struct bt_mesh_msg_ctx * ctx ,
63
+ struct net_buf_simple * buf );
64
64
65
- static void gen_onoff_get (struct bt_mesh_model * model ,
66
- struct bt_mesh_msg_ctx * ctx ,
67
- struct net_buf_simple * buf );
65
+ static int gen_onoff_get (struct bt_mesh_model * model ,
66
+ struct bt_mesh_msg_ctx * ctx ,
67
+ struct net_buf_simple * buf );
68
68
69
- static void gen_onoff_status (struct bt_mesh_model * model ,
70
- struct bt_mesh_msg_ctx * ctx ,
71
- struct net_buf_simple * buf );
69
+ static int gen_onoff_status (struct bt_mesh_model * model ,
70
+ struct bt_mesh_msg_ctx * ctx ,
71
+ struct net_buf_simple * buf );
72
72
73
73
/*
74
74
* Client Configuration Declaration
@@ -127,9 +127,9 @@ BT_MESH_MODEL_PUB_DEFINE(gen_onoff_pub_cli_s_2, NULL, 2 + 2);
127
127
*/
128
128
129
129
static const struct bt_mesh_model_op gen_onoff_srv_op [] = {
130
- { BT_MESH_MODEL_OP_GEN_ONOFF_GET , 0 , gen_onoff_get },
131
- { BT_MESH_MODEL_OP_GEN_ONOFF_SET , 2 , gen_onoff_set },
132
- { BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK , 2 , gen_onoff_set_unack },
130
+ { BT_MESH_MODEL_OP_GEN_ONOFF_GET , BT_MESH_LEN_EXACT ( 0 ) , gen_onoff_get },
131
+ { BT_MESH_MODEL_OP_GEN_ONOFF_SET , BT_MESH_LEN_EXACT ( 2 ) , gen_onoff_set },
132
+ { BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK , BT_MESH_LEN_EXACT ( 2 ) , gen_onoff_set_unack },
133
133
BT_MESH_MODEL_OP_END ,
134
134
};
135
135
@@ -138,7 +138,7 @@ static const struct bt_mesh_model_op gen_onoff_srv_op[] = {
138
138
*/
139
139
140
140
static const struct bt_mesh_model_op gen_onoff_cli_op [] = {
141
- { BT_MESH_MODEL_OP_GEN_ONOFF_STATUS , 1 , gen_onoff_status },
141
+ { BT_MESH_MODEL_OP_GEN_ONOFF_STATUS , BT_MESH_LEN_EXACT ( 1 ) , gen_onoff_status },
142
142
BT_MESH_MODEL_OP_END ,
143
143
};
144
144
@@ -277,9 +277,9 @@ static uint16_t primary_net_idx;
277
277
*
278
278
*/
279
279
280
- static void gen_onoff_get (struct bt_mesh_model * model ,
281
- struct bt_mesh_msg_ctx * ctx ,
282
- struct net_buf_simple * buf )
280
+ static int gen_onoff_get (struct bt_mesh_model * model ,
281
+ struct bt_mesh_msg_ctx * ctx ,
282
+ struct net_buf_simple * buf )
283
283
{
284
284
NET_BUF_SIMPLE_DEFINE (msg , 2 + 1 + 4 );
285
285
struct onoff_state * onoff_state = model -> user_data ;
@@ -292,11 +292,13 @@ static void gen_onoff_get(struct bt_mesh_model *model,
292
292
if (bt_mesh_model_send (model , ctx , & msg , NULL , NULL )) {
293
293
printk ("Unable to send On Off Status response\n" );
294
294
}
295
+
296
+ return 0 ;
295
297
}
296
298
297
- static void gen_onoff_set_unack (struct bt_mesh_model * model ,
298
- struct bt_mesh_msg_ctx * ctx ,
299
- struct net_buf_simple * buf )
299
+ static int gen_onoff_set_unack (struct bt_mesh_model * model ,
300
+ struct bt_mesh_msg_ctx * ctx ,
301
+ struct net_buf_simple * buf )
300
302
{
301
303
struct net_buf_simple * msg = model -> pub -> msg ;
302
304
struct onoff_state * onoff_state = model -> user_data ;
@@ -331,28 +333,34 @@ static void gen_onoff_set_unack(struct bt_mesh_model *model,
331
333
printk ("bt_mesh_model_publish err %d\n" , err );
332
334
}
333
335
}
336
+
337
+ return 0 ;
334
338
}
335
339
336
- static void gen_onoff_set (struct bt_mesh_model * model ,
337
- struct bt_mesh_msg_ctx * ctx ,
338
- struct net_buf_simple * buf )
340
+ static int gen_onoff_set (struct bt_mesh_model * model ,
341
+ struct bt_mesh_msg_ctx * ctx ,
342
+ struct net_buf_simple * buf )
339
343
{
340
344
printk ("gen_onoff_set\n" );
341
345
342
- gen_onoff_set_unack (model , ctx , buf );
343
- gen_onoff_get (model , ctx , buf );
346
+ (void )gen_onoff_set_unack (model , ctx , buf );
347
+ (void )gen_onoff_get (model , ctx , buf );
348
+
349
+ return 0 ;
344
350
}
345
351
346
- static void gen_onoff_status (struct bt_mesh_model * model ,
347
- struct bt_mesh_msg_ctx * ctx ,
348
- struct net_buf_simple * buf )
352
+ static int gen_onoff_status (struct bt_mesh_model * model ,
353
+ struct bt_mesh_msg_ctx * ctx ,
354
+ struct net_buf_simple * buf )
349
355
{
350
356
uint8_t state ;
351
357
352
358
state = net_buf_simple_pull_u8 (buf );
353
359
354
360
printk ("Node 0x%04x OnOff status from 0x%04x with state 0x%02x\n" ,
355
361
bt_mesh_model_elem (model )-> addr , ctx -> addr , state );
362
+
363
+ return 0 ;
356
364
}
357
365
358
366
static int output_number (bt_mesh_output_action_t action , uint32_t number )
@@ -487,7 +495,7 @@ static void button_pressed_worker(struct k_work *work)
487
495
*/
488
496
489
497
net_buf_simple_add_u8 (& msg , sw -> onoff_state );
490
- gen_onoff_set_unack (mod_srv , & ctx , & msg );
498
+ ( void ) gen_onoff_set_unack (mod_srv , & ctx , & msg );
491
499
return ;
492
500
}
493
501
0 commit comments