@@ -555,6 +555,86 @@ STATIC mp_obj_t mod_pycom_lte_modem_on_boot (mp_uint_t n_args, const mp_obj_t *a
555
555
}
556
556
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (mod_pycom_lte_modem_on_boot_obj , 0 , 1 , mod_pycom_lte_modem_on_boot );
557
557
558
+ STATIC mp_obj_t mod_pycom_pybytes_lte_config (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
559
+ enum { ARG_carrier , ARG_apn , ARG_cid , ARG_band , ARG_type , ARG_reset };
560
+ STATIC const mp_arg_t allowed_args [] = {
561
+ { MP_QSTR_carrier , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
562
+ { MP_QSTR_apn , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
563
+ { MP_QSTR_cid , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
564
+ { MP_QSTR_band , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
565
+ { MP_QSTR_type , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
566
+ { MP_QSTR_reset , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
567
+
568
+ };
569
+
570
+ mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
571
+ mp_arg_parse_all (n_args , pos_args , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
572
+
573
+ pycom_pybytes_lte_config_t pycom_pybytes_lte_config = config_get_pybytes_lte_config ();
574
+
575
+ if (n_args == 0 ) {
576
+ mp_obj_tuple_t * t = MP_OBJ_TO_PTR (mp_obj_new_tuple (6 , NULL ));
577
+
578
+ if (pycom_pybytes_lte_config .carrier [0 ] == 0xFF && pycom_pybytes_lte_config .carrier [1 ] == 0xFF && pycom_pybytes_lte_config .carrier [2 ] == 0xFF )
579
+ {
580
+ t -> items [ARG_carrier ] = mp_const_none ;
581
+ }
582
+ else
583
+ {
584
+ t -> items [ARG_carrier ] = mp_obj_new_str ((const char * )pycom_pybytes_lte_config .carrier , strlen ((const char * )pycom_pybytes_lte_config .carrier ));
585
+ }
586
+
587
+ if (pycom_pybytes_lte_config .apn [0 ] == 0xFF && pycom_pybytes_lte_config .apn [1 ] == 0xFF && pycom_pybytes_lte_config .apn [2 ] == 0xFF )
588
+ {
589
+ t -> items [ARG_apn ] = mp_const_none ;
590
+ }
591
+ else
592
+ {
593
+ t -> items [ARG_apn ] = mp_obj_new_str ((const char * )pycom_pybytes_lte_config .apn , strlen ((const char * )pycom_pybytes_lte_config .apn ));
594
+ }
595
+ if (pycom_pybytes_lte_config .cid == 0xFF )
596
+ {
597
+ t -> items [ARG_cid ] = mp_obj_new_int (1 );
598
+ }
599
+ else
600
+ {
601
+ t -> items [ARG_cid ] = mp_obj_new_int (pycom_pybytes_lte_config .cid );
602
+ }
603
+ if (pycom_pybytes_lte_config .band == 0xFF )
604
+ {
605
+ t -> items [ARG_band ] = mp_const_none ;
606
+ }
607
+ else
608
+ {
609
+ t -> items [ARG_band ] = mp_obj_new_int (pycom_pybytes_lte_config .band );
610
+ }
611
+ if (pycom_pybytes_lte_config .type [0 ] == 0xFF )
612
+ {
613
+ t -> items [ARG_type ] = mp_const_none ;
614
+ }
615
+ else
616
+ {
617
+ t -> items [ARG_type ] = mp_obj_new_str ((const char * )pycom_pybytes_lte_config .type , strlen ((const char * )pycom_pybytes_lte_config .type ));
618
+ }
619
+ if (pycom_pybytes_lte_config .reset == 0xff )
620
+ {
621
+ t -> items [ARG_reset ] = mp_const_false ;
622
+ }
623
+ else
624
+ {
625
+ t -> items [ARG_reset ] = mp_obj_new_bool (pycom_pybytes_lte_config .reset );
626
+ }
627
+ return MP_OBJ_FROM_PTR (t );
628
+
629
+ } else {
630
+ nlr_raise (mp_obj_new_exception_msg (& mp_type_ValueError , "Error this functionality is not yet supported!" ));
631
+ }
632
+
633
+ return mp_const_none ;
634
+ }
635
+
636
+ STATIC MP_DEFINE_CONST_FUN_OBJ_KW (mod_pycom_pybytes_lte_config_obj , 0 , mod_pycom_pybytes_lte_config );
637
+
558
638
STATIC mp_obj_t mod_pycom_bootmgr (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
559
639
enum { ARG_boot_partition , ARG_fs_type , ARG_safeboot , ARG_status };
560
640
STATIC const mp_arg_t allowed_args [] = {
@@ -731,6 +811,7 @@ STATIC const mp_map_elem_t pycom_module_globals_table[] = {
731
811
{ MP_OBJ_NEW_QSTR (MP_QSTR_pybytes_extra_preferences ), (mp_obj_t )& mod_pycom_pybytes_extra_preferences_obj },
732
812
{ MP_OBJ_NEW_QSTR (MP_QSTR_pybytes_force_update ), (mp_obj_t )& mod_pycom_pybytes_force_update_obj },
733
813
{ MP_OBJ_NEW_QSTR (MP_QSTR_smart_config_on_boot ), (mp_obj_t )& mod_pycom_smartConfig_obj },
814
+ { MP_OBJ_NEW_QSTR (MP_QSTR_pybytes_lte_config ), (mp_obj_t )& mod_pycom_pybytes_lte_config_obj },
734
815
#endif //(VARIANT == PYBYTES)
735
816
{ MP_OBJ_NEW_QSTR (MP_QSTR_bootmgr ), (mp_obj_t )& mod_pycom_bootmgr_obj },
736
817
0 commit comments