FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
951 views 1 comments
by anonymous
I am currently running a Python script running on a TRB245 and sending some data using MQTT. I am now needing to include either the device IMEI or serial number in the data packet I am sending. I am unclear how I can get either the device IMEI or serial number using Python. I have looked through various Wiki's and forums without success so far.

I would appreciate if anyone can guide me how I can get this data using Python. I see there is a sys Python library with OpenWRT, but I would not know which method or parameter to use to find either of these device data fields.

Thanks

1 Answer

0 votes
by anonymous

Hi,

The best option to get the values you are looking for is to use os library, it's available by default on python3.9 installation.

basically with, os.system you can execute any CLI command on the router

import os

imei=os.system('gsmctl -i')

serial=os.system('mnf_info  -s')

Best answer
by anonymous
@PauliusRug Thanks very much for the very quick response and simple solution!