80
80
81
81
#define DEFAULT_PROTO_TYPE (const char*)"IP"
82
82
#define DEFAULT_APN (const char*)""
83
+
84
+ #define SQNS_SW_FULL_BAND_SUPPORT 41000
85
+ #define SQNS_SW_5_8_BAND_SUPPORT 39000
83
86
/******************************************************************************
84
87
DECLARE PRIVATE DATA
85
88
******************************************************************************/
@@ -119,6 +122,7 @@ static void lte_pause_ppp(void);
119
122
static bool lte_check_attached (bool legacy );
120
123
static void lte_check_init (void );
121
124
static bool lte_check_sim_present (void );
125
+ static int lte_get_modem_version (void );
122
126
STATIC mp_obj_t lte_suspend (mp_obj_t self_in );
123
127
STATIC mp_obj_t lte_connect (mp_uint_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args );
124
128
@@ -281,6 +285,31 @@ static bool lte_check_legacy_version(void) {
281
285
return true;
282
286
}
283
287
288
+ static int lte_get_modem_version (void )
289
+ {
290
+ lte_task_cmd_data_t cmd = { .timeout = LTE_RX_TIMEOUT_MAX_MS };
291
+
292
+ /* Get modem version */
293
+ memcpy (cmd .data , "AT!=\"showver\"" , strlen ("AT!=\"showver\"" ));
294
+ char * ver = NULL ;
295
+
296
+ lteppp_send_at_command (& cmd , & modlte_rsp );
297
+ ver = strstr (modlte_rsp .data , "Software :" );
298
+
299
+ if (ver != NULL )
300
+ {
301
+ ver = strstr (ver , "[" );
302
+ char * ver_close = strstr (ver , "]" );
303
+ int v = 0 ;
304
+ if (ver != NULL && ver_close != NULL && ver_close > ver ) {
305
+ ver [ver_close - ver ] = '\0' ;
306
+ ver ++ ;
307
+ v = atoi (ver );
308
+ }
309
+ return v ;
310
+ }
311
+ return 0 ;
312
+ }
284
313
285
314
static void lte_check_init (void ) {
286
315
if (!lte_obj .init ) {
@@ -554,8 +583,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(lte_deinit_obj, 1, lte_deinit);
554
583
555
584
STATIC mp_obj_t lte_attach (mp_uint_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
556
585
lte_check_init ();
557
- bool is_new_band_support = false;
558
-
586
+ bool is_hw_new_band_support = false;
587
+ bool is_sw_new_band_support = false;
559
588
STATIC const mp_arg_t allowed_args [] = {
560
589
{ MP_QSTR_band , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
561
590
{ MP_QSTR_apn , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
@@ -579,27 +608,25 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t
579
608
if (lteppp_get_state () < E_LTE_ATTACHING ) {
580
609
581
610
if (!lte_obj .carrier ) {
582
-
611
+ /* Get configured bands in modem */
583
612
lte_task_cmd_data_t cmd = { .timeout = LTE_RX_TIMEOUT_MAX_MS };
584
613
memcpy (cmd .data , "AT+SMDD" , strlen ("AT+SMDD" ));
585
614
lteppp_send_at_command (& cmd , & modlte_rsp );
586
-
587
- if (strstr (modlte_rsp .data , "17 bands" ) == NULL )
615
+ /* Dummy command for command response > Uart buff size */
616
+ memcpy (cmd .data , "Pycom_Dummy" , strlen ("Pycom_Dummy" ));
617
+ while (modlte_rsp .data_remaining )
588
618
{
589
- memcpy (cmd .data , "Pycom_Dummy" , strlen ("Pycom_Dummy" ));
590
- while (modlte_rsp .data_remaining )
619
+ if ((strstr (modlte_rsp .data , "17 bands" ) != NULL ) && !is_hw_new_band_support )
591
620
{
592
- lteppp_send_at_command (& cmd , & modlte_rsp );
593
- if (strstr (modlte_rsp .data , "<band p=\"5\">" ) != NULL )
594
- {
595
- is_new_band_support = true;
596
- break ;
597
- }
621
+ is_hw_new_band_support = true;
598
622
}
623
+ lteppp_send_at_command (& cmd , & modlte_rsp );
599
624
}
600
- else
625
+ int version = lte_get_modem_version ();
626
+
627
+ if (version > 0 && version > SQNS_SW_FULL_BAND_SUPPORT )
601
628
{
602
- is_new_band_support = true;
629
+ is_sw_new_band_support = true;
603
630
}
604
631
// configuring scanning in all bands
605
632
lte_push_at_command ("AT!=\"clearscanconfig\"" , LTE_RX_TIMEOUT_MIN_MS );
@@ -608,17 +635,58 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t
608
635
if (args [0 ].u_obj == mp_const_none ) {
609
636
lte_push_at_command ("AT!=\"RRC::addScanBand band=3\"" , LTE_RX_TIMEOUT_MIN_MS );
610
637
lte_push_at_command ("AT!=\"RRC::addScanBand band=4\"" , LTE_RX_TIMEOUT_MIN_MS );
611
- if (is_new_band_support ) {
638
+ if (is_hw_new_band_support && version > SQNS_SW_5_8_BAND_SUPPORT ) {
612
639
lte_push_at_command ("AT!=\"RRC::addScanBand band=5\"" , LTE_RX_TIMEOUT_MIN_MS );
613
640
lte_push_at_command ("AT!=\"RRC::addScanBand band=8\"" , LTE_RX_TIMEOUT_MIN_MS );
614
641
}
615
642
lte_push_at_command ("AT!=\"RRC::addScanBand band=12\"" , LTE_RX_TIMEOUT_MIN_MS );
616
643
lte_push_at_command ("AT!=\"RRC::addScanBand band=13\"" , LTE_RX_TIMEOUT_MIN_MS );
617
644
lte_push_at_command ("AT!=\"RRC::addScanBand band=20\"" , LTE_RX_TIMEOUT_MIN_MS );
618
645
lte_push_at_command ("AT!=\"RRC::addScanBand band=28\"" , LTE_RX_TIMEOUT_MIN_MS );
619
- } else {
646
+ }
647
+ else
648
+ {
620
649
uint32_t band = mp_obj_get_int (args [0 ].u_obj );
621
- if (band == 3 ) {
650
+ /* Check band support */
651
+ switch (band )
652
+ {
653
+ case 5 :
654
+ case 8 :
655
+ if (!is_hw_new_band_support )
656
+ {
657
+ nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_ValueError , "band %d not supported by this board hardware!" , band ));
658
+ }
659
+ else if (version < SQNS_SW_5_8_BAND_SUPPORT )
660
+ {
661
+ nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_ValueError , "band %d not supported by current modem Firmware, please upgrade!" , band ));
662
+ }
663
+ break ;
664
+ case 1 :
665
+ case 2 :
666
+ case 14 :
667
+ case 17 :
668
+ case 18 :
669
+ case 19 :
670
+ case 25 :
671
+ case 26 :
672
+ case 66 :
673
+ if (!is_sw_new_band_support )
674
+ {
675
+ nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_ValueError , "band %d not supported by current modem Firmware, please upgrade!" , band ));
676
+ }
677
+ if (!is_hw_new_band_support )
678
+ {
679
+ nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_ValueError , "band %d not supported by this board hardware!" , band ));
680
+ }
681
+ break ;
682
+ default :
683
+ break ;
684
+ }
685
+ if (band == 1 ) {
686
+ lte_push_at_command ("AT!=\"RRC::addScanBand band=1\"" , LTE_RX_TIMEOUT_MIN_MS );
687
+ } else if (band == 2 ) {
688
+ lte_push_at_command ("AT!=\"RRC::addScanBand band=2\"" , LTE_RX_TIMEOUT_MIN_MS );
689
+ } else if (band == 3 ) {
622
690
lte_push_at_command ("AT!=\"RRC::addScanBand band=3\"" , LTE_RX_TIMEOUT_MIN_MS );
623
691
} else if (band == 4 ) {
624
692
lte_push_at_command ("AT!=\"RRC::addScanBand band=4\"" , LTE_RX_TIMEOUT_MIN_MS );
@@ -630,10 +698,24 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t
630
698
lte_push_at_command ("AT!=\"RRC::addScanBand band=12\"" , LTE_RX_TIMEOUT_MIN_MS );
631
699
} else if (band == 13 ) {
632
700
lte_push_at_command ("AT!=\"RRC::addScanBand band=13\"" , LTE_RX_TIMEOUT_MIN_MS );
701
+ } else if (band == 14 ) {
702
+ lte_push_at_command ("AT!=\"RRC::addScanBand band=14\"" , LTE_RX_TIMEOUT_MIN_MS );
703
+ } else if (band == 17 ) {
704
+ lte_push_at_command ("AT!=\"RRC::addScanBand band=17\"" , LTE_RX_TIMEOUT_MIN_MS );
705
+ } else if (band == 18 ) {
706
+ lte_push_at_command ("AT!=\"RRC::addScanBand band=18\"" , LTE_RX_TIMEOUT_MIN_MS );
707
+ } else if (band == 19 ) {
708
+ lte_push_at_command ("AT!=\"RRC::addScanBand band=19\"" , LTE_RX_TIMEOUT_MIN_MS );
633
709
} else if (band == 20 ) {
634
710
lte_push_at_command ("AT!=\"RRC::addScanBand band=20\"" , LTE_RX_TIMEOUT_MIN_MS );
711
+ } else if (band == 25 ) {
712
+ lte_push_at_command ("AT!=\"RRC::addScanBand band=25\"" , LTE_RX_TIMEOUT_MIN_MS );
713
+ } else if (band == 26 ) {
714
+ lte_push_at_command ("AT!=\"RRC::addScanBand band=26\"" , LTE_RX_TIMEOUT_MIN_MS );
635
715
} else if (band == 28 ) {
636
716
lte_push_at_command ("AT!=\"RRC::addScanBand band=28\"" , LTE_RX_TIMEOUT_MIN_MS );
717
+ } else if (band == 66 ) {
718
+ lte_push_at_command ("AT!=\"RRC::addScanBand band=66\"" , LTE_RX_TIMEOUT_MIN_MS );
637
719
} else {
638
720
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_ValueError , "band %d not supported" , band ));
639
721
}
0 commit comments