@@ -445,6 +445,9 @@ static int encode(zcbor_state_t *zs)
445
445
#if defined(CONFIG_SHIELD_CTR_S1 )
446
446
zcbor_uint32_put (zs , MSG_KEY_IAQ_SENSOR );
447
447
{
448
+ struct app_data_iaq_sensors * sensors = & g_app_data .iaq .sensors ;
449
+ struct app_data_iaq_button * button = & g_app_data .iaq .button ;
450
+
448
451
zcbor_map_start_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
449
452
450
453
zcbor_uint32_put (zs , MSG_KEY_TEMPERATURE );
@@ -455,12 +458,11 @@ static int encode(zcbor_state_t *zs)
455
458
{
456
459
zcbor_list_start_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
457
460
458
- zcbor_uint64_put (zs , g_app_data . iaq . timestamp );
461
+ zcbor_uint64_put (zs , sensors -> timestamp );
459
462
zcbor_uint32_put (zs , g_app_config .interval_aggreg );
460
463
461
- for (int i = 0 ; i < g_app_data .iaq .measurement_count ; i ++ ) {
462
- put_sample_mul (zs ,
463
- & g_app_data .iaq .measurements [i ].temperature ,
464
+ for (int i = 0 ; i < sensors -> measurement_count ; i ++ ) {
465
+ put_sample_mul (zs , & sensors -> measurements [i ].temperature ,
464
466
100.f );
465
467
}
466
468
@@ -477,10 +479,10 @@ static int encode(zcbor_state_t *zs)
477
479
{
478
480
zcbor_list_start_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
479
481
480
- zcbor_uint64_put (zs , g_app_data . iaq . timestamp );
482
+ zcbor_uint64_put (zs , sensors -> timestamp );
481
483
zcbor_uint32_put (zs , g_app_config .interval_aggreg );
482
- for (int i = 0 ; i < g_app_data . iaq . measurement_count ; i ++ ) {
483
- put_sample_mul (zs , & g_app_data . iaq . measurements [i ].humidity ,
484
+ for (int i = 0 ; i < sensors -> measurement_count ; i ++ ) {
485
+ put_sample_mul (zs , & sensors -> measurements [i ].humidity ,
484
486
100.f );
485
487
}
486
488
@@ -497,11 +499,11 @@ static int encode(zcbor_state_t *zs)
497
499
{
498
500
zcbor_list_start_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
499
501
500
- zcbor_uint64_put (zs , g_app_data . iaq . timestamp );
502
+ zcbor_uint64_put (zs , sensors -> timestamp );
501
503
zcbor_uint32_put (zs , g_app_config .interval_aggreg );
502
504
503
- for (int i = 0 ; i < g_app_data . iaq . measurement_count ; i ++ ) {
504
- put_sample (zs , & g_app_data . iaq . measurements [i ].illuminance );
505
+ for (int i = 0 ; i < sensors -> measurement_count ; i ++ ) {
506
+ put_sample (zs , & sensors -> measurements [i ].illuminance );
505
507
}
506
508
507
509
zcbor_list_end_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
@@ -517,11 +519,11 @@ static int encode(zcbor_state_t *zs)
517
519
{
518
520
zcbor_list_start_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
519
521
520
- zcbor_uint64_put (zs , g_app_data . iaq . timestamp );
522
+ zcbor_uint64_put (zs , sensors -> timestamp );
521
523
zcbor_uint32_put (zs , g_app_config .interval_aggreg );
522
524
523
- for (int i = 0 ; i < g_app_data . iaq . measurement_count ; i ++ ) {
524
- put_sample (zs , & g_app_data . iaq . measurements [i ].altitude );
525
+ for (int i = 0 ; i < sensors -> measurement_count ; i ++ ) {
526
+ put_sample (zs , & sensors -> measurements [i ].altitude );
525
527
}
526
528
527
529
zcbor_list_end_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
@@ -537,11 +539,11 @@ static int encode(zcbor_state_t *zs)
537
539
{
538
540
zcbor_list_start_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
539
541
540
- zcbor_uint64_put (zs , g_app_data . iaq . timestamp );
542
+ zcbor_uint64_put (zs , sensors -> timestamp );
541
543
zcbor_uint32_put (zs , g_app_config .interval_aggreg );
542
544
543
- for (int i = 0 ; i < g_app_data . iaq . measurement_count ; i ++ ) {
544
- put_sample (zs , & g_app_data . iaq . measurements [i ].pressure );
545
+ for (int i = 0 ; i < sensors -> measurement_count ; i ++ ) {
546
+ put_sample (zs , & sensors -> measurements [i ].pressure );
545
547
}
546
548
547
549
zcbor_list_end_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
@@ -557,11 +559,11 @@ static int encode(zcbor_state_t *zs)
557
559
{
558
560
zcbor_list_start_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
559
561
560
- zcbor_uint64_put (zs , g_app_data . iaq . timestamp );
562
+ zcbor_uint64_put (zs , sensors -> timestamp );
561
563
zcbor_uint32_put (zs , g_app_config .interval_aggreg );
562
564
563
- for (int i = 0 ; i < g_app_data . iaq . measurement_count ; i ++ ) {
564
- put_sample (zs , & g_app_data . iaq . measurements [i ].co2_conc );
565
+ for (int i = 0 ; i < sensors -> measurement_count ; i ++ ) {
566
+ put_sample (zs , & sensors -> measurements [i ].co2_conc );
565
567
}
566
568
567
569
zcbor_list_end_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
@@ -577,12 +579,11 @@ static int encode(zcbor_state_t *zs)
577
579
{
578
580
zcbor_list_start_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
579
581
580
- zcbor_uint64_put (zs , g_app_data . iaq . timestamp );
582
+ zcbor_uint64_put (zs , sensors -> timestamp );
581
583
zcbor_uint32_put (zs , g_app_config .interval_aggreg );
582
584
583
- for (int i = 0 ; i < g_app_data .iaq .measurement_count ; i ++ ) {
584
- zcbor_int32_put (
585
- zs , g_app_data .iaq .measurements [i ].motion_count );
585
+ for (int i = 0 ; i < sensors -> measurement_count ; i ++ ) {
586
+ zcbor_int32_put (zs , sensors -> measurements [i ].motion_count );
586
587
}
587
588
588
589
zcbor_list_end_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
@@ -598,12 +599,11 @@ static int encode(zcbor_state_t *zs)
598
599
{
599
600
zcbor_list_start_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
600
601
601
- zcbor_uint64_put (zs , g_app_data . iaq . timestamp );
602
+ zcbor_uint64_put (zs , button -> timestamp );
602
603
zcbor_uint32_put (zs , g_app_config .interval_aggreg );
603
604
604
- for (int i = 0 ; i < g_app_data .iaq .measurement_count ; i ++ ) {
605
- zcbor_int32_put (zs ,
606
- g_app_data .iaq .measurements [i ].press_count );
605
+ for (int i = 0 ; i < button -> measurement_count ; i ++ ) {
606
+ zcbor_int32_put (zs , button -> measurements [i ].press_count );
607
607
}
608
608
609
609
zcbor_list_end_encode (zs , ZCBOR_VALUE_IS_INDEFINITE_LENGTH );
0 commit comments