81
81
82
82
struct observe_node {
83
83
sys_snode_t node ;
84
- struct net_app_ctx * net_app_ctx ;
84
+ struct lwm2m_ctx * ctx ;
85
85
struct lwm2m_obj_path path ;
86
86
u8_t token [8 ];
87
87
s64_t event_timestamp ;
@@ -226,7 +226,7 @@ static int engine_add_observer(struct net_app_ctx *app_ctx,
226
226
227
227
/* make sure this observer doesn't exist already */
228
228
SYS_SLIST_FOR_EACH_CONTAINER (& engine_observer_list , obs , node ) {
229
- if (obs -> net_app_ctx == app_ctx &&
229
+ if (& obs -> ctx -> net_app_ctx == app_ctx &&
230
230
memcmp (& obs -> path , path , sizeof (* path )) == 0 ) {
231
231
/* quietly update the token information */
232
232
memcpy (obs -> token , token , tkl );
@@ -255,7 +255,8 @@ static int engine_add_observer(struct net_app_ctx *app_ctx,
255
255
256
256
/* copy the values and add it to the list */
257
257
observe_node_data [i ].used = true;
258
- observe_node_data [i ].net_app_ctx = app_ctx ;
258
+ observe_node_data [i ].ctx = CONTAINER_OF (app_ctx ,
259
+ struct lwm2m_ctx , net_app_ctx );
259
260
memcpy (& observe_node_data [i ].path , path , sizeof (* path ));
260
261
memcpy (observe_node_data [i ].token , token , tkl );
261
262
observe_node_data [i ].tkl = tkl ;
@@ -2444,12 +2445,9 @@ static int generate_notify_message(struct observe_node *obs,
2444
2445
struct lwm2m_output_context out ;
2445
2446
struct lwm2m_engine_context context ;
2446
2447
struct lwm2m_obj_path path ;
2447
- struct lwm2m_ctx * client_ctx ;
2448
2448
int ret = 0 ;
2449
2449
2450
- client_ctx = CONTAINER_OF (obs -> net_app_ctx ,
2451
- struct lwm2m_ctx , net_app_ctx );
2452
- if (!client_ctx ) {
2450
+ if (!obs -> ctx ) {
2453
2451
SYS_LOG_ERR ("observer has no valid LwM2M ctx!" );
2454
2452
return - EINVAL ;
2455
2453
}
@@ -2472,7 +2470,7 @@ static int generate_notify_message(struct observe_node *obs,
2472
2470
obs -> path .level ,
2473
2471
sprint_token (obs -> token , obs -> tkl ),
2474
2472
lwm2m_sprint_ip_addr (
2475
- & obs -> net_app_ctx -> default_ctx -> remote ),
2473
+ & obs -> ctx -> net_app_ctx . default_ctx -> remote ),
2476
2474
k_uptime_get ());
2477
2475
2478
2476
obj_inst = get_engine_obj_inst (obs -> path .obj_id ,
@@ -2484,7 +2482,7 @@ static int generate_notify_message(struct observe_node *obs,
2484
2482
return - EINVAL ;
2485
2483
}
2486
2484
2487
- ret = lwm2m_init_message (obs -> net_app_ctx , out .out_zpkt , & pkt ,
2485
+ ret = lwm2m_init_message (& obs -> ctx -> net_app_ctx , out .out_zpkt , & pkt ,
2488
2486
ZOAP_TYPE_CON , ZOAP_RESPONSE_CODE_CONTENT ,
2489
2487
0 , obs -> token , obs -> tkl );
2490
2488
if (ret ) {
@@ -2523,13 +2521,13 @@ static int generate_notify_message(struct observe_node *obs,
2523
2521
goto cleanup ;
2524
2522
}
2525
2523
2526
- pending = lwm2m_init_message_pending (client_ctx , out .out_zpkt );
2524
+ pending = lwm2m_init_message_pending (obs -> ctx , out .out_zpkt );
2527
2525
if (!pending ) {
2528
2526
ret = - ENOMEM ;
2529
2527
goto cleanup ;
2530
2528
}
2531
2529
2532
- reply = zoap_reply_next_unused (client_ctx -> replies ,
2530
+ reply = zoap_reply_next_unused (obs -> ctx -> replies ,
2533
2531
CONFIG_LWM2M_ENGINE_MAX_REPLIES );
2534
2532
if (!reply ) {
2535
2533
SYS_LOG_ERR ("No resources for waiting for replies." );
@@ -2540,15 +2538,15 @@ static int generate_notify_message(struct observe_node *obs,
2540
2538
zoap_reply_init (reply , & request );
2541
2539
reply -> reply = notify_message_reply_cb ;
2542
2540
2543
- ret = lwm2m_udp_sendto (obs -> net_app_ctx , pkt );
2541
+ ret = lwm2m_udp_sendto (& obs -> ctx -> net_app_ctx , pkt );
2544
2542
if (ret < 0 ) {
2545
2543
SYS_LOG_ERR ("Error sending LWM2M packet (err:%d)." , ret );
2546
2544
goto cleanup ;
2547
2545
}
2548
2546
SYS_LOG_DBG ("NOTIFY MSG: SENT" );
2549
2547
2550
2548
zoap_pending_cycle (pending );
2551
- k_delayed_work_submit (& client_ctx -> retransmit_work , pending -> timeout );
2549
+ k_delayed_work_submit (& obs -> ctx -> retransmit_work , pending -> timeout );
2552
2550
return ret ;
2553
2551
2554
2552
cleanup :
0 commit comments