-
Notifications
You must be signed in to change notification settings - Fork 317
Expand file tree
/
Copy pathown_number_demo.py
More file actions
executable file
·38 lines (27 loc) · 885 Bytes
/
own_number_demo.py
File metadata and controls
executable file
·38 lines (27 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
"""\
Demo: read own phone number
"""
from __future__ import print_function
import logging
PORT = '/dev/vmodem0'
BAUDRATE = 115200
PIN = None # SIM card PIN (if any)
from gsmmodem.modem import GsmModem
def main():
print('Initializing modem...')
# Uncomment the following line to see what the modem is doing:
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE)
modem.connect(PIN)
number = modem.ownNumber
print("The SIM card phone number is:")
print(number)
# Uncomment the following block to change your own number.
# modem.ownNumber = "+000123456789" # lease empty for removing the phone entry altogether
# number = modem.ownNumber
# print("A new phone number is:")
# print(number)
# modem.close();
if __name__ == '__main__':
main()