Salamek / huawei-lte-api

API For huawei LAN/WAN LTE Modems
GNU Lesser General Public License v3.0
376 stars 92 forks source link

+ sign disapper #63

Closed goldandy closed 4 years ago

goldandy commented 4 years ago

Hi I'm using B315 Huawei LTE router. When I tried to send SMS by API with python, i got OK but SMS wasn't arrived

~ % python3 huawei.py
{'DeviceName': 'B315s-22', 'SerialNumber': 'Q2Q8W1830500XXXX', 'Imei': '35534908865XXXX', 'Imsi': '25002027427XXXX', 'Iccid': '89701020274279XXXX', 'Msisdn': '+79207505548', 'HardwareVersion': 'WL1B310FM01', 'SoftwareVersion': '21.329.01.00.00', 'WebUIVersion': '21.313.05.00.00_Mod1.5', 'MacAddress1': '04:79:70:6C:79:DE', 'MacAddress2': None, 'ProductFamily': 'LTE', 'Classify': 'cpe', 'supportmode': None, 'workmode': 'LTE', 'WanIPAddress': '100.88.26.XX', 'WanIPv6Address': None}
{'SaveMode': '0', 'Validity': '10752', 'Sca': '+79202909090', 'UseSReport': '0', 'SendType': '1'}
OK
OK 

This is my python script

import sys
from huawei_lte_api.Client import Client
from huawei_lte_api.AuthorizedConnection import AuthorizedConnection
from huawei_lte_api.Connection import Connection

connection = AuthorizedConnection('http://admin:admin@192.168.8.1/')

client = Client(connection) # This just simplifies access to separate API groups, you can use device = Device(connection) if you want

print(client.device.information())
print(client.sms.config())
print(client.sms.send_sms([+796728585XX], "Test message"))
print(client.user.logout())

I checked both requests from python and from GUI and find out, that in case of python I can't see "+" sign in the front of mobile number

Python output

<?xml version="1.0" encoding="UTF-8" ?><request><Index>-1</Index><Phones><Phone>796728585XX</Phone></Phones><Sca></Sca><Content>Test message</Content><Length>12</Length><Reserved>1</Reserved><Date>2020-01-21 09:27:49</Date></request>

GUI output

<?xml version="1.0" encoding="UTF-8"?><request><Index>-1</Index><Phones><Phone>+796728585XX</Phone></Phones><Sca></Sca><Content>testnumber2</Content><Length>11</Length><Reserved>1</Reserved><Date>2020-01-21 12:33:20</Date></request>

Is it something wrong with my script or my B315 is not fully supported?

Thanks Andrey

Salamek commented 4 years ago

@goldandy your phone number was evaluated as a number, since you did not put it inside '', just change

[+796728585XX]

to

['+796728585XX']
goldandy commented 4 years ago

Great, thanks a lot, now it works! You did a great job :) Sure you can add B315 in the list of supported model

Andrey