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