Skip to content

Commit 4914ae8

Browse files
authored
Merge pull request #124 from Mia1234567890/main
[EG912NENAAR03A02M16_OCPU_QPY_V04][band]新增设置、获取、恢复接口
2 parents 223dbc3 + 1dd6972 commit 4914ae8

File tree

2 files changed

+428
-0
lines changed

2 files changed

+428
-0
lines changed

en-us/api/QuecPythonClasslib.md

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,6 +3173,218 @@ This function sets the current modem functionality.
31733173

31743174

31753175

3176+
##### band Setting and obtaining
3177+
3178+
##### band value comparison table
3179+
3180+
| NET MODE | BAND VALUE |
3181+
| --------------- | ------------------------------------------------------------ |
3182+
| EGPRS(GSM) | EGSM900 - 0x1<br/>DCS1800 - 0x2<br/>GSM850 - 0x4<br/>PCS1900 - 0x8 |
3183+
| LTE/eMTC/NB-IoT | BAND1 - 0x1<br/>BAND2 - 0x2<br/>BAND3 - 0x4<br/>BAND4 - 0x8<br/>BAND5 - 0x10<br/>BAND8 - 0x80<br/>BAND12 - 0x800<br/>BAND13 - 0x1000<br/>BAND18 - 0x20000<br/>BAND19 - 0x40000<br/>BAND20 - 0x80000<br/>BAND25 - 0x1000000<br/>BAND26 - 0x2000000<br/>BAND27 - 0x4000000<br/>BAND28 - 0x8000000<br/>BAND31 - 0x40000000<br/>BAND66 - 0x20000000000000000<br/>BAND71 - 0x400000000000000000<br/>BAND72 - 0x800000000000000000<br/>BAND73 - 0x1000000000000000000<br/>BAND85 - 0x1000000000000000000000<br/> |
3184+
3185+
##### band of BG95M3
3186+
3187+
| NET MODE | BAND VALUE |
3188+
| -------- | ------------------------------------------------------------ |
3189+
| eMTC | B1/B2/B3/B4/B5/B8/B12/B13/B18/B19/B20/B25/B26/B27/B28/B66/B85 |
3190+
| NB-IoT | B1/B2/B3/B4/B5/B8/B12/B13/B18/B19/B20/B25/B28/B66/B71/B85 |
3191+
| EGPRS | GSM850/EGSM900/DCS1800/PCS1900 |
3192+
3193+
##### band of EG912NENAA
3194+
3195+
| NET MODE | BAND VALUE |
3196+
| -------- | ------------------------------------ |
3197+
| LTE | B1/B3/B5/B7/B8/B20/B28/B31/B72 |
3198+
| EGPRS | EGSM900/DCS1800 |
3199+
3200+
3201+
3202+
##### band Setting
3203+
3204+
> **net.setBand(net_rat, gsm_band, band_tuple)**
3205+
3206+
Set required bands, that is, lock the bands specified by the user if the module supports them。 (Platforms are currently supported:CATM/EG912NENAA)
3207+
3208+
* Parameter
3209+
3210+
| Parameter | Type | Description |
3211+
| ---------- | ----- | ------------------------------------------------------------ |
3212+
| net_rat | int | Specify which net mode band is to be set<br>0 - GSM<br>1 - LTE<br>2 - CATM<br>3 - NB<br>note:The CATM platform does not support LTE<br/>The EG912NENAA platform just support GSM and LTE |
3213+
| gsm_band | int | gsm band value<br/>0x01 - GSM_EGSM900<br/>0x02 - GSM_DCS1800<br>0x04 - GSM_GSM850<br/>0x08 - GSM_PCS1900 |
3214+
| band_tuple | tuple | band value of other network modes,Is a tuple of four elements, each of which cannot exceed 4 bytes. The format is as follows:<br>(band_hh, band_hl, band_lh, band_ll)|
3215+
3216+
* Return Value
3217+
3218+
* 0 Successful execution.
3219+
* -1 Failed execution.
3220+
3221+
* Example
3222+
3223+
```python
3224+
import net
3225+
import utime
3226+
3227+
'''
3228+
You can use the following two interfaces to set and obtain bands
3229+
'''
3230+
def set_band(net_rat, band_value):
3231+
if net_rat == 0:
3232+
retval = net.setBand(0, band_value, (0, 0, 0, 0))
3233+
else:
3234+
band_hh = (band_value & 0xFFFFFFFF000000000000000000000000) >> 96
3235+
band_hl = (band_value & 0x00000000FFFFFFFF0000000000000000) >> 64
3236+
band_lh = (band_value & 0x0000000000000000FFFFFFFF00000000) >> 32
3237+
band_ll = (band_value & 0x000000000000000000000000FFFFFFFF)
3238+
retval = net.setBand(net_rat, 0, (band_hh, band_hl, band_lh, band_ll))
3239+
return retval
3240+
3241+
3242+
def get_band(net_rat):
3243+
return net.getBand(net_rat)
3244+
3245+
#======================================================================================================
3246+
3247+
'''
3248+
Set the band of the GSM network to 0xa, that is, DCS1800 + PCS1900
3249+
0xa = 0x2(DCS1800) + 0x8(PCS1900)
3250+
'''
3251+
def set_gsm_band_example():
3252+
print('Set GSM band to 0xa example:')
3253+
gsm_band = get_band(0)
3254+
print('GSM band value before setting:{}'.format(gsm_band))
3255+
ret = set_band(0, 0xa)
3256+
if ret == 0:
3257+
print('Set GSM band successfully.')
3258+
else:
3259+
print('Set GSM band failed.')
3260+
utime.sleep(1) # It takes a certain period of time to set the band. After a delay period, you can obtain the new result
3261+
gsm_band = get_band(0)
3262+
print('GSM band value after setting:{}'.format(gsm_band))
3263+
return ret
3264+
3265+
3266+
'''
3267+
Set the eMTC network band to 0x15, that is, set BAND1+BAND3+BAND5
3268+
0x15 = 0x1(BAND1) + 0x4(BAND3) + 0x10(BAND5)
3269+
'''
3270+
def set_camt_band_example():
3271+
print('Set CATM band to 0x15 example:')
3272+
catm_band = get_band(2)
3273+
print('CATM band value before setting:{}'.format(catm_band))
3274+
ret = set_band(2, 0x15)
3275+
if ret == 0:
3276+
print('Set CATM band successfully.')
3277+
else:
3278+
print('Set CATM band failed.')
3279+
utime.sleep(1)
3280+
catm_band = get_band(2)
3281+
print('CATM band value after setting:{}'.format(catm_band))
3282+
return ret
3283+
3284+
3285+
'''
3286+
Set the eMTC network band to 0x1000800000000000020011,that is, set BAND1+BAND5+BAND18+BAND71+BAND85
3287+
0x1000400000000000020011 = 0x1 + 0x10 + 0x20000 + 0x400000000000000000 + 0x1000000000000000000000
3288+
'''
3289+
def set_nb_band_example():
3290+
print('Set NB band to 0x1000400000000000020011 example:')
3291+
nb_band = get_band(3)
3292+
print('NB band value before setting:{}'.format(nb_band))
3293+
ret = set_band(3, 0x1000400000000000020011)
3294+
if ret == 0:
3295+
print('Set NB band successfully.')
3296+
else:
3297+
print('Set NB band failed.')
3298+
utime.sleep(1)
3299+
nb_band = get_band(3)
3300+
print('NB band value after setting:{}'.format(nb_band))
3301+
return ret
3302+
3303+
3304+
def main():
3305+
set_gsm_band_example()
3306+
utime.sleep(1)
3307+
set_camt_band_example()
3308+
utime.sleep(1)
3309+
set_nb_band_example()
3310+
3311+
3312+
if __name__ == '__main__':
3313+
main()
3314+
3315+
3316+
#===================================================================================================
3317+
#result
3318+
Set GSM band to 0xa example:
3319+
GSM band value before setting:0xf
3320+
Set GSM band successfully.
3321+
GSM band value after setting:0xa
3322+
3323+
Set CATM band to 0x15 example:
3324+
CATM band value before setting:0x10000200000000090e189f
3325+
Set CATM band successfully.
3326+
CATM band value after setting:0x15
3327+
3328+
Set NB band to 0x1000400000000000020011 example:
3329+
NB band value before setting:0x10004200000000090e189f
3330+
Set NB band successfully.
3331+
NB band value after setting:0x1000400000000000020011
3332+
3333+
```
3334+
3335+
3336+
3337+
##### band obtaining
3338+
3339+
> **net.getBand(net_rat)**
3340+
3341+
Band obtaining。(Platforms are currently supported:CATM/EG912NENAA)
3342+
3343+
* Parameter
3344+
3345+
| Parameter | Type | Description |
3346+
| ------- | ---- | ------------------------------------------------------------ |
3347+
| net_rat | int | Specify which net mode band is to be get<br>0 - GSM<br>1 - LTE<br>2 - CATM<br>3 - NB<br>note:The CATM platform does not support LTE<br/>The EG912NENAA platform just support GSM and LTE |
3348+
3349+
* Return Value
3350+
3351+
Return the band value as a hexadecimal string.
3352+
3353+
* example
3354+
3355+
```python
3356+
net.getBand(2)
3357+
'0x10000200000000090e189f'
3358+
```
3359+
3360+
3361+
3362+
##### band Restores the initial value
3363+
3364+
> **net.bandRst()**
3365+
3366+
band Restores the initial value。(Platforms are currently supported:EG912NENAA)
3367+
3368+
* Parameter
3369+
3370+
* NA
3371+
3372+
* Return Value
3373+
3374+
* 0 Successful execution.
3375+
* -1 Failed execution.
3376+
3377+
* Example
3378+
3379+
```python
3380+
#Set it to another band and call the interface to check whether the interface is successfully restored to the initial value
3381+
#EG912NENAA platform initial value:gsm_band:0x3(EGSM900/DCS1800 ) lte_band:0x8000000000480800D5(B1/B3/B5/B7/B8/B20/B28/B31/B72 )
3382+
net.bandRst()
3383+
0
3384+
```
3385+
3386+
3387+
31763388
#### checkNet - Wait for Network to be Ready
31773389

31783390
Function: The checkNet module is mainly used for the script programs [auto-startup], and provides APIs to wait for the network to be ready. If it times out or exits abnormally, the program returns an error code. Therefore, if there are network-related operations in the your program, the method in the checkNet module should be called at the beginning of the user program to wait for the network to be ready. Of course, you can also implement the functions of this module by yourselves.

0 commit comments

Comments
 (0)