@@ -67,7 +67,7 @@ enum network_module_state {
67
67
/* State object.
68
68
* Used to transfer context data between state changes.
69
69
*/
70
- struct state_object {
70
+ struct network_state_object {
71
71
/* This must be first */
72
72
struct smf_ctx ctx ;
73
73
@@ -87,10 +87,11 @@ static void state_disconnected_idle_run(void *obj);
87
87
static void state_disconnected_searching_entry (void * obj );
88
88
static void state_disconnected_searching_run (void * obj );
89
89
static void state_disconnecting_entry (void * obj );
90
+ static void state_disconnecting_run (void * obj );
90
91
static void state_connected_run (void * obj );
91
92
static void state_connected_entry (void * obj );
92
93
93
- static struct state_object network_state ;
94
+ static struct network_state_object network_state ;
94
95
95
96
/* State machine definition */
96
97
static const struct smf_state states [] = {
@@ -116,7 +117,7 @@ static const struct smf_state states[] = {
116
117
& states [STATE_RUNNING ],
117
118
NULL ), /* No initial transition */
118
119
[STATE_DISCONNECTING ] =
119
- SMF_CREATE_STATE (state_disconnecting_entry , NULL , NULL ,
120
+ SMF_CREATE_STATE (state_disconnecting_entry , state_disconnecting_run , NULL ,
120
121
& states [STATE_RUNNING ],
121
122
NULL ), /* No initial transition */
122
123
};
@@ -221,7 +222,7 @@ static void lte_lc_evt_handler(const struct lte_lc_evt *const evt)
221
222
.edrx_cfg = evt -> edrx_cfg ,
222
223
};
223
224
224
- LOG_DBG ("eDRX parameters received, mode: %d, eDRX: %0.2f s, PTW: %f s" ,
225
+ LOG_DBG ("eDRX parameters received, mode: %d, eDRX: %0.2f s, PTW: %.02f s" ,
225
226
msg .edrx_cfg .mode , (double )msg .edrx_cfg .edrx , (double )msg .edrx_cfg .ptw );
226
227
227
228
network_msg_send (& msg );
@@ -256,6 +257,24 @@ static void sample_network_quality(void)
256
257
network_msg_send (& msg );
257
258
}
258
259
260
+ static void request_system_mode (void )
261
+ {
262
+ int err ;
263
+ struct network_msg msg = {
264
+ .type = NETWORK_SYSTEM_MODE_RESPONSE ,
265
+ };
266
+ enum lte_lc_system_mode_preference dummy_preference ;
267
+
268
+ err = lte_lc_system_mode_get (& msg .system_mode , & dummy_preference );
269
+ if (err ) {
270
+ LOG_ERR ("lte_lc_system_mode_get, error: %d" , err );
271
+ SEND_FATAL_ERROR ();
272
+ return ;
273
+ }
274
+
275
+ network_msg_send (& msg );
276
+ }
277
+
259
278
static int network_disconnect (void )
260
279
{
261
280
int err ;
@@ -306,7 +325,7 @@ static void state_running_entry(void *obj)
306
325
307
326
static void state_running_run (void * obj )
308
327
{
309
- struct state_object const * state_object = obj ;
328
+ struct network_state_object const * state_object = obj ;
310
329
311
330
LOG_DBG ("state_running_run" );
312
331
@@ -323,6 +342,9 @@ static void state_running_run(void *obj)
323
342
case NETWORK_QUALITY_SAMPLE_REQUEST :
324
343
sample_network_quality ();
325
344
break ;
345
+ case NETWORK_SYSTEM_MODE_REQUEST :
346
+ request_system_mode ();
347
+ break ;
326
348
default :
327
349
break ;
328
350
}
@@ -350,7 +372,7 @@ static void state_disconnected_entry(void *obj)
350
372
351
373
static void state_disconnected_run (void * obj )
352
374
{
353
- struct state_object const * state_object = obj ;
375
+ struct network_state_object const * state_object = obj ;
354
376
355
377
LOG_DBG ("state_disconnected_run" );
356
378
@@ -398,7 +420,7 @@ static void state_disconnected_searching_entry(void *obj)
398
420
399
421
static void state_disconnected_searching_run (void * obj )
400
422
{
401
- struct state_object const * state_object = obj ;
423
+ struct network_state_object const * state_object = obj ;
402
424
403
425
LOG_DBG ("state_disconnected_searching_run" );
404
426
@@ -421,7 +443,7 @@ static void state_disconnected_searching_run(void *obj)
421
443
422
444
static void state_disconnected_idle_run (void * obj )
423
445
{
424
- struct state_object const * state_object = obj ;
446
+ struct network_state_object const * state_object = obj ;
425
447
426
448
LOG_DBG ("state_disconnected_idle_run" );
427
449
@@ -432,7 +454,6 @@ static void state_disconnected_idle_run(void *obj)
432
454
case NETWORK_DISCONNECT :
433
455
STATE_EVENT_HANDLED (network_state );
434
456
break ;
435
- case NETWORK_SEARCH_START : __fallthrough ;
436
457
case NETWORK_CONNECT :
437
458
STATE_SET (network_state , STATE_DISCONNECTED_SEARCHING );
438
459
break ;
@@ -451,7 +472,7 @@ static void state_connected_entry(void *obj)
451
472
452
473
static void state_connected_run (void * obj )
453
474
{
454
- struct state_object const * state_object = obj ;
475
+ struct network_state_object const * state_object = obj ;
455
476
456
477
LOG_DBG ("state_connected_run" );
457
478
@@ -492,6 +513,21 @@ static void state_disconnecting_entry(void *obj)
492
513
}
493
514
}
494
515
516
+ static void state_disconnecting_run (void * obj )
517
+ {
518
+ struct network_state_object const * state_object = obj ;
519
+
520
+ LOG_DBG ("state_disconnecting_run" );
521
+
522
+ if (& NETWORK_CHAN == state_object -> chan ) {
523
+ struct network_msg msg = MSG_TO_NETWORK_MSG (state_object -> msg_buf );
524
+
525
+ if (msg .type == NETWORK_DISCONNECTED ) {
526
+ STATE_SET (network_state , STATE_DISCONNECTED_IDLE );
527
+ }
528
+ }
529
+ }
530
+
495
531
static void network_wdt_callback (int channel_id , void * user_data )
496
532
{
497
533
LOG_ERR ("Network watchdog expired, Channel: %d, Thread: %s" ,
0 commit comments