-
Notifications
You must be signed in to change notification settings - Fork 0
/
phone.py
41 lines (34 loc) · 1.08 KB
/
phone.py
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
39
40
41
import gammu
import logging as log
class Phone:
def __init__(self):
self.sm = gammu.StateMachine()
# Read ~/.gammurc
self.sm.ReadConfig()
self.sm.Init()
self.print_status()
def send_sms(self, recipient: str, message: str):
smsinfo = {
"Class": -1,
"Unicode": False,
"Entries": [
{
"ID": "ConcatenatedTextLong",
"Buffer": message,
}
],
}
encoded = gammu.EncodeSMS(smsinfo)
# Send messages
for message in encoded:
# Fill in numbers
message["SMSC"] = {"Location": 1}
message["Number"] = recipient
# Actually send the message
self.sm.SendSMS(message)
def print_status(self):
netinfo = self.sm.GetNetworkInfo()
log.info(f"Network name: {netinfo['NetworkName']}")
log.info(f"Network code: {netinfo['NetworkCode']}")
log.info(f"LAC: {netinfo['LAC']}")
log.info(f"CID: {netinfo['CID']}")