Beispiel #1
0
def reply_sms(message):
    global sms_type, sms_format, sms_source, sms_modem, sms_message, network_reply_mode
    print('\n')
    print("Sending SMS reply...")
    print('\n')
    time.sleep(2)
    if talkgroup_reply_mode == 0:
        shark.do_send_sms(sms_type, sms_format, sms_source, sms_modem, message)
    # For testing purposes, below is set to group SMS due to issues with AT-D878. o_ indicates override, see above
    else:
        shark.do_send_sms(o_sms_type, o_sms_format, o_sms_source, sms_modem,
                          message)
    print("SMS type: " + sms_type)
    print("Format: " + sms_format)
    print("Source: " + sms_source)
    print("Message: " + message)
    print('Modem/Network (0 = network, 1 = modem): ' + sms_modem)
    if sms_modem == 0:
        print('Network')
    if sms_modem == 1:
        print('RF Modem')
    #print('Network Reply - 0 = off, 1 = on: ' + str(network_reply_mode))
    if str(network_reply_mode) == '0':
        print('Network reply disabled.')
    if str(network_reply_mode) == '1':
        print('Network reply enabled.')
Beispiel #2
0
def get_email():
    # Use e-mail variables from above
    pop_server = poplib.POP3_SSL(email_server, pop_port)
    pop_server.user(email_user)
    pop_server.pass_(email_password)

    # Get the number of mail messages
    numMessages = len(pop_server.list()[1])

    # print
    print("E-Mail messages received:")

    #List the subject line of each message, then sort for "TO-", where DMR ID is extracted
    for mList in range(numMessages):
        # Used to number messages with "TO-" in subject, for deletion later
        del_msg = mList + 1
        # Actually filter by subject
        for rec_email_msg in pop_server.retr(mList + 1)[1]:
            if rec_email_msg.startswith(b'Subject: TO-'):
                string_email_message = rec_email_msg.decode('utf-8')
                for iem in string_email_message.split():
                    if iem.startswith('TO-'):
                        # Get DMR ID
                        dmr_dst = iem.replace('TO-', '')
                        # Form SMS message, presently includes destination DMR ID, will fix later
                        dmr_email_msg = string_email_message.replace(
                            'Subject: TO-', '')
                        print('Destination: ' + dmr_dst)
                        print('Message: ' + dmr_email_msg)
                        print('\n')
                        print('Sending messages via SMS...')
                        # Email to specific DMR ID not implimented yet, send to talkgroup 9
                        shark.do_send_sms(o_sms_type, o_sms_format,
                                          o_sms_source, sms_modem,
                                          dmr_email_msg)
                        print('Deleting message')
                        pop_server.dele(del_msg)
                        #break
    pop_server.quit()
Beispiel #3
0
def tg_sms_send(message):
    global tg_sms
    print('Sending SMS to talkgroup ' + tg_sms)
    time.sleep(1)
    if network_reply_mode == 1:
        sms_modem = 0
    if network_reply_mode == 0:
        sms_modem = 1
    print('Mode selected')
    if tg_sms_all_formats == 1:
        print('Sending in ETSI format')
        shark.do_send_sms(o_sms_type, '0', tg_sms, sms_modem, message)
        time.sleep(10)
        print('Sending in UDP format')
        shark.do_send_sms(o_sms_type, '1', tg_sms, sms_modem, message)
        time.sleep(10)
        print('Sending in UDP/Chinese format')
        shark.do_send_sms(o_sms_type, '2', tg_sms, sms_modem, message)
    if tg_sms_all_formats == 0:
        shark.do_send_sms(o_sms_type, o_sms_format, tg_sms, sms_modem, message)
    time.sleep(1)
Beispiel #4
0
#!/usr/bin/python
import re, binascii, shark
#shark.do_login()
shark.do_checkauth()
# First option is for calltype (0 - private, 1 - group), then format (0 - ETSI, 1 - UDP, 2 - UDP/Chinese).
# Third option is the destination DMR ID, send to modem (1) or network (0), and the last is the actual message.
shark.do_send_sms( '0', '1','9998', '1', 'How long can this message be? 1234567' )

Beispiel #5
0
def aprs_receive_loop(packet):
    global parse_packet, aprs_message_packet, AIS_send

    # Message ACK packet
    #aprs_msg_ack = hotspot_callsign + '>APRS,TCPIP*:' + ':' + parse_packet['from'] +':ack' + parse_packet['msgNo']
    # Retrieve value from dictionary key
    #print(par_pak['from'])
    #######
    # convert bytes to utf-8 string, ignore errors from non utf-8 bytes
    pak_str = packet.decode('utf-8', errors='ignore').strip()
    # Parse packet into dictionary
    parse_packet = aprslib.parse(pak_str)
    with open(map_csv, 'rt') as map_file:
        map_read = csv.reader(map_file)
        ######
        if 'bulletin' in parse_packet['format']:
            print('Bulletin Received...')
            print('Bulletin from: ' + parse_packet['from'] + ' Message: ' +
                  parse_packet['message_text'])
            tg_sms_send('Bulletin from: ' + parse_packet['from'] +
                        ' Message: ' + parse_packet['message_text'])
            time.sleep(3)
        if 'addresse' in parse_packet:
            if 'message_text' in parse_packet:
                for map_line in map_read:
                    if map_line[0] == parse_packet['addresse']:
                        print('yep')
                        print(map_line[0])
                        print('APRS message: ' + parse_packet['message_text'] +
                              ' From: ' + parse_packet['from'] + 'To: ' +
                              map_line[0])
                        # Begin ACK with APRS call of recipient
                        if 'msgNo' in parse_packet:
                            print('Send ACK')
                            time.sleep(1)
                            print('Connecting to APRS-IS')
                            AIS_send.connect()
                            time.sleep(1)
                            print('Sending...')
                            AIS_send.sendall(map_line[0] + '>APRS,TCPIP*:' +
                                             ':' + parse_packet['from'] +
                                             ' :ack' + parse_packet['msgNo'])
                            print(map_line[0] + '>APRS,TCPIP*:' + ':' +
                                  parse_packet['from'] + ': ack' +
                                  parse_packet['msgNo'])
                        else:
                            print('no ack')
                        ### End Ack
                        time.sleep(2)
                        print(time.strftime('%H:%M:%S - %m/%d/%Y'))
                        #set to send to network or modem in config
                        shark.do_send_sms(
                            '0', map_line[2], map_line[1],
                            aprs_tg_network_reply,
                            'APRS MSG from: ' + parse_packet['from'] + '. ' +
                            parse_packet['message_text'])
                        print(map_line[0] + ' type: ' + map_line[2] +
                              ' dst: ' + map_line[1])
                        print('5 second reset')
                        time.sleep(5)

                if hotspot_callsign == parse_packet['addresse']:
                    print('APRS message: ' + parse_packet['message_text'] +
                          ' From: ' + parse_packet['from'])
                    aprs_ack()
                    # Send message to DMR SMS
                    print(time.strftime('%H:%M:%S - %m/%d/%Y'))
                    # send to network or modem defined in config
                    shark.do_send_sms(
                        '1', '2', '9', aprs_tg_network_reply,
                        'APRS MSG from: ' + parse_packet['from'] + '. ' +
                        parse_packet['message_text'])
                    print('5 second reset')
                    time.sleep(5)
                    #AIS.connect()
                    #dmr_sms_aprs_reply = 'APRS MSG from: ' + parse_packet['from'] + '. ' + parse_packet['message_text']
                    #reply_sms(dmr_sms_aprs_reply)
                    time.sleep(1)

                else:
                    print('...')
            #else:
            #   print('Message from: ' + parse_packet['from'] + ' To: ' + parse_packet['addresse'])

        else:
            print('Packet from: ' + parse_packet['from'] + ' - ' +
                  time.strftime('%H:%M:%S'))
Beispiel #6
0
sms_dest = "9"
sms_modem = "1"

shark.do_checkauth()

# Same codes for Chelan, Douglas, Grant, and Okanogan Counties
nws = WeatherAlerts(samecodes=['053007', '053017', '053025', '053047'])

# Same codes for entire state
#nws = WeatherAlerts(state='WA')

# Filter for Severe alerts
for alert in nws.alerts:
    if "Severe" in alert.severity:
        # 1=Type, Group | 2=Format, UDP/Chinese | 9=Talkgroup | alert.title= message
        shark.do_send_sms(sms_type, sms_format, sms_dest, sms_modem,
                          alert.title)
        print(alert.title)
        print(alert.severity)
        print(alert.urgency)
        print(alert.areadesc)
        print(alert.samecodes)
        print(alert.expiration)
        print("\n")
        time.sleep(1)

# Filter for Moderate alerts
    if "Moderate" in alert.severity:
        shark.do_send_sms(sms_type, sms_format, sms_dest, sms_modem,
                          alert.title)
        print(alert.title)
        print(alert.severity)