change SMS command syntax
This commit is contained in:
parent
1540b3e806
commit
eb06c9c268
12
access_systems.txt
Normal file
12
access_systems.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
'XYZ':{
|
||||||
|
'mode':'msg_xfer',
|
||||||
|
'user':'test_name',
|
||||||
|
'password':'passw0rd'
|
||||||
|
},
|
||||||
|
'APP':{
|
||||||
|
'mode':'app',
|
||||||
|
'user':'test_name',
|
||||||
|
'password':'passw0rd'
|
||||||
|
}
|
||||||
|
}
|
7
authorized_users.txt
Normal file
7
authorized_users.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
'ABC':{
|
||||||
|
'mode':'msg_xfer',
|
||||||
|
'user':'test_name',
|
||||||
|
'password':'passw0rd'
|
||||||
|
}
|
||||||
|
}
|
@ -172,6 +172,8 @@ def build_config(_config_file):
|
|||||||
'USER_SETTINGS_FILE': config.get(section, 'USER_SETTINGS_FILE'),
|
'USER_SETTINGS_FILE': config.get(section, 'USER_SETTINGS_FILE'),
|
||||||
'USE_API': config.getboolean(section, 'USE_API'),
|
'USE_API': config.getboolean(section, 'USE_API'),
|
||||||
'AUTHORIZED_TOKENS_FILE': config.get(section, 'AUTHORIZED_TOKENS_FILE'),
|
'AUTHORIZED_TOKENS_FILE': config.get(section, 'AUTHORIZED_TOKENS_FILE'),
|
||||||
|
'AUTHORIZED_USERS_FILE': config.get(section, 'AUTHORIZED_USERS_FILE'),
|
||||||
|
'ACCESS_SYSTEMS_FILE': config.get(section, 'ACCESS_SYSTEMS_FILE'),
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -173,6 +173,8 @@ USER_SETTINGS_FILE: /path/to/user_settings.txt
|
|||||||
USE_API: True
|
USE_API: True
|
||||||
AUTHORIZED_APPS_FILE: /path/to/authorized_apps.py
|
AUTHORIZED_APPS_FILE: /path/to/authorized_apps.py
|
||||||
AUTHORIZED_TOKENS_FILE: /tmp/hblink_auth_tokens.txt
|
AUTHORIZED_TOKENS_FILE: /tmp/hblink_auth_tokens.txt
|
||||||
|
AUTHORIZED_USERS_FILE: /path/to/authorized_users.txt
|
||||||
|
ACCESS_SYSTEMS_FILE: /path/to/access_systems.txt
|
||||||
|
|
||||||
# The following options are used for the dashboard. The dashboard is optional.
|
# The following options are used for the dashboard. The dashboard is optional.
|
||||||
# Title of the Dashboard
|
# Title of the Dashboard
|
||||||
|
@ -304,19 +304,21 @@ def user_setting_write(dmr_id, setting, value):
|
|||||||
# Process SMS, do something bases on message
|
# Process SMS, do something bases on message
|
||||||
|
|
||||||
def process_sms(_rf_src, sms):
|
def process_sms(_rf_src, sms):
|
||||||
if sms == 'ID':
|
parse_sms = sms.split(' ')
|
||||||
|
logger.info(parse_sms)
|
||||||
|
if parse_sms[0] == 'ID':
|
||||||
logger.info(str(get_alias(int_id(_rf_src), subscriber_ids)) + ' - ' + str(int_id(_rf_src)))
|
logger.info(str(get_alias(int_id(_rf_src), subscriber_ids)) + ' - ' + str(int_id(_rf_src)))
|
||||||
send_sms(False, int_id(_rf_src), data_id, 0000, 'unit', 'Your DMR ID: ' + str(int_id(_rf_src)) + ' - ' + str(get_alias(int_id(_rf_src), subscriber_ids)))
|
send_sms(False, int_id(_rf_src), data_id, 0000, 'unit', 'Your DMR ID: ' + str(int_id(_rf_src)) + ' - ' + str(get_alias(int_id(_rf_src), subscriber_ids)))
|
||||||
elif sms == 'TEST':
|
elif parse_sms[0] == 'TEST':
|
||||||
logger.info('It works!')
|
logger.info('It works!')
|
||||||
send_sms(False, int_id(_rf_src), data_id, 0000, 'unit', 'It works')
|
send_sms(False, int_id(_rf_src), data_id, 0000, 'unit', 'It works')
|
||||||
elif '@ICON' in sms:
|
elif '@ICON' in parse_sms[0]:
|
||||||
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@ICON| ','',sms))
|
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@ICON| ','',sms))
|
||||||
elif '@SSID' in sms:
|
elif '@SSID' in parse_sms[0]:
|
||||||
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@SSID| ','',sms))
|
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@SSID| ','',sms))
|
||||||
elif '@COM' in sms:
|
elif '@COM' in parse_sms[0]:
|
||||||
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@COM |@COM','',sms))
|
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@COM |@COM','',sms))
|
||||||
elif '@PIN' in sms:
|
elif '@PIN' in parse_sms[0]:
|
||||||
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), int(re.sub('@PIN |@PIN','',sms)))
|
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), int(re.sub('@PIN |@PIN','',sms)))
|
||||||
# Write blank entry to cause APRS receive to look for packets for this station.
|
# Write blank entry to cause APRS receive to look for packets for this station.
|
||||||
elif '@APRS ON' in sms or '@APRS on' in sms:
|
elif '@APRS ON' in sms or '@APRS on' in sms:
|
||||||
@ -325,9 +327,10 @@ def process_sms(_rf_src, sms):
|
|||||||
user_setting_write(int_id(_rf_src), 'APRS OFF', False)
|
user_setting_write(int_id(_rf_src), 'APRS OFF', False)
|
||||||
elif '@BB' in sms:
|
elif '@BB' in sms:
|
||||||
dashboard_bb_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time(), re.sub('@BB|@BB ','',sms))
|
dashboard_bb_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time(), re.sub('@BB|@BB ','',sms))
|
||||||
elif '@' and ' E-' in sms:
|
elif '@' in parse_sms[0][1:] and '.' in parse_sms[0]: # and ' E-' in sms:
|
||||||
email_message = str(re.sub('.*@|.* E-', '', sms))
|
s = ' '
|
||||||
to_email = str(re.sub(' E-.*', '', sms))
|
email_message = s.join(parse_sms[1:])#str(re.sub('.*@|.* E-', '', sms))
|
||||||
|
to_email = parse_sms[0]#str(re.sub(' E-.*', '', sms))
|
||||||
email_subject = 'New message from ' + str(get_alias(int_id(_rf_src), subscriber_ids))
|
email_subject = 'New message from ' + str(get_alias(int_id(_rf_src), subscriber_ids))
|
||||||
logger.info('Email to: ' + to_email)
|
logger.info('Email to: ' + to_email)
|
||||||
logger.info('Message: ' + email_message)
|
logger.info('Message: ' + email_message)
|
||||||
@ -343,13 +346,13 @@ def process_sms(_rf_src, sms):
|
|||||||
elif '@REM SOS' == sms:
|
elif '@REM SOS' == sms:
|
||||||
os.remove(emergency_sos_file)
|
os.remove(emergency_sos_file)
|
||||||
logger.info('Removing SOS or Notice')
|
logger.info('Removing SOS or Notice')
|
||||||
elif '@' and 'M-' in sms:
|
elif '@' in parse_sms[0][0:1] and 'M-' in parse_sms[1][0:2]:
|
||||||
message = re.sub('^@|.* M-|','',sms)
|
message = re.sub('^@|.* M-|','',sms)
|
||||||
recipient = re.sub('@| M-.*','',sms)
|
recipient = re.sub('@| M-.*','',sms)
|
||||||
mailbox_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time(), message, str(recipient).upper())
|
mailbox_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time(), message, str(recipient).upper())
|
||||||
elif '@REM MAIL' == sms:
|
elif '@REM MAIL' == sms:
|
||||||
mailbox_delete(_rf_src)
|
mailbox_delete(_rf_src)
|
||||||
elif '@MH' in sms:
|
elif '@MH' in parse_sms[0]:
|
||||||
grid_square = re.sub('@MH ', '', sms)
|
grid_square = re.sub('@MH ', '', sms)
|
||||||
if len(grid_square) < 6:
|
if len(grid_square) < 6:
|
||||||
pass
|
pass
|
||||||
@ -410,16 +413,19 @@ def process_sms(_rf_src, sms):
|
|||||||
packet_assembly = ''
|
packet_assembly = ''
|
||||||
|
|
||||||
|
|
||||||
elif 'A-' in sms and '@' in sms:
|
elif '@' in parse_sms[0][0:1] and 'M-' not in parse_sms[1][0:2] or '@' not in parse_sms[0][1:]:
|
||||||
#Example SMS text: @ARMDS A-This is a test.
|
#Example SMS text: @ARMDS A-This is a test.
|
||||||
aprs_dest = re.sub('@| A-.*','',sms)
|
s = ' '
|
||||||
aprs_msg = re.sub('^@|.* A-|','',sms)
|
aprs_dest = re.sub('@', '', parse_sms[0])#re.sub('@| A-.*','',sms)
|
||||||
|
aprs_msg = s.join(parse_sms[1:])#re.sub('^@|.* A-|','',sms)
|
||||||
|
logger.info(aprs_msg)
|
||||||
logger.info('APRS message to ' + aprs_dest.upper() + '. Message: ' + aprs_msg)
|
logger.info('APRS message to ' + aprs_dest.upper() + '. Message: ' + aprs_msg)
|
||||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||||
if int_id(_rf_src) in user_settings and user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
if int_id(_rf_src) in user_settings and user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
||||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||||
else:
|
else:
|
||||||
ssid = user_ssid
|
ssid = user_ssid
|
||||||
|
try:
|
||||||
if user_settings[int_id(_rf_src)][5]['APRS'] == True:
|
if user_settings[int_id(_rf_src)][5]['APRS'] == True:
|
||||||
aprs_msg_pkt = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + str(ssid) + '>APHBL3,TCPIP*::' + str(aprs_dest).ljust(9).upper() + ':' + aprs_msg[0:73]
|
aprs_msg_pkt = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + str(ssid) + '>APHBL3,TCPIP*::' + str(aprs_dest).ljust(9).upper() + ':' + aprs_msg[0:73]
|
||||||
logger.info(aprs_msg_pkt)
|
logger.info(aprs_msg_pkt)
|
||||||
@ -432,7 +438,9 @@ def process_sms(_rf_src, sms):
|
|||||||
logger.info(error_exception)
|
logger.info(error_exception)
|
||||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||||
else:
|
else:
|
||||||
send_sms(False, int_id(_rf_src), data_id, 0000, 'unit', 'APRS Messaging must be enabled. Send command "@APRS ON" to enable.')
|
send_sms(False, int_id(_rf_src), data_id, 0000, 'unit', 'APRS Messaging must be enabled. Send command "@APRS ON" or use dashboard to enable.')
|
||||||
|
except Exception as e:
|
||||||
|
send_sms(False, int_id(_rf_src), data_id, 0000, 'unit', 'APRS Messaging must be enabled. Send command "@APRS ON" or use dashboard to enable.')
|
||||||
try:
|
try:
|
||||||
if sms in cmd_list:
|
if sms in cmd_list:
|
||||||
logger.info('Executing command/script.')
|
logger.info('Executing command/script.')
|
||||||
@ -2165,8 +2173,6 @@ if __name__ == '__main__':
|
|||||||
# User APRS settings
|
# User APRS settings
|
||||||
user_settings_file = CONFIG['GPS_DATA']['USER_SETTINGS_FILE']
|
user_settings_file = CONFIG['GPS_DATA']['USER_SETTINGS_FILE']
|
||||||
|
|
||||||
#API variables
|
|
||||||
auth_token_file = CONFIG['GPS_DATA']['AUTHORIZED_TOKENS_FILE']
|
|
||||||
use_api = CONFIG['GPS_DATA']['USE_API']
|
use_api = CONFIG['GPS_DATA']['USE_API']
|
||||||
|
|
||||||
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
||||||
@ -2194,6 +2200,12 @@ if __name__ == '__main__':
|
|||||||
user_bb_file.close()
|
user_bb_file.close()
|
||||||
#Only create if API enabled
|
#Only create if API enabled
|
||||||
if use_api == True:
|
if use_api == True:
|
||||||
|
logger.info('Dashboard API enabled')
|
||||||
|
#API variables
|
||||||
|
auth_token_file = CONFIG['GPS_DATA']['AUTHORIZED_TOKENS_FILE']
|
||||||
|
use_api = CONFIG['GPS_DATA']['USE_API']
|
||||||
|
access_systems_file = CONFIG['GPS_DATA']['ACCESS_SYSTEMS_FILE']
|
||||||
|
authorized_users_file = CONFIG['GPS_DATA']['AUTHORIZED_USERS_FILE']
|
||||||
if Path(auth_token_file).is_file():
|
if Path(auth_token_file).is_file():
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -51,7 +51,7 @@ BRIDGES = {
|
|||||||
list the names of each system that should bridge unit to unit (individual) calls.
|
list the names of each system that should bridge unit to unit (individual) calls.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
UNIT = ['MASTER-1', 'CHANGE_ME']
|
UNIT = ['MASTER-1', 'PEER-1']
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Unit Call flood timeout:
|
Unit Call flood timeout:
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
#global authorized_users, other_systems
|
|
||||||
# The following info will allow others to SMS into your system.
|
|
||||||
authorized_users = {
|
|
||||||
'ABC':{
|
|
||||||
'mode':'msg_xfer',
|
|
||||||
'user':'test_name',
|
|
||||||
'password':'passw0rd'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# The following info will allow users to access other systems.
|
|
||||||
access_systems = {
|
|
||||||
'XYZ':{
|
|
||||||
'mode':'msg_xfer',
|
|
||||||
'user':'test_name',
|
|
||||||
'password':'passw0rd'
|
|
||||||
},
|
|
||||||
'APP':{
|
|
||||||
'mode':'app',
|
|
||||||
'user':'test_name',
|
|
||||||
'password':'passw0rd'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -728,6 +728,8 @@ def api(api_mode=None):
|
|||||||
api_content = '<h3 style="text-align: center;"><strong>API Enabled: ' + str(use_api) + '</strong></h3>'
|
api_content = '<h3 style="text-align: center;"><strong>API Enabled: ' + str(use_api) + '</strong></h3>'
|
||||||
return render_template('generic.html', title = dashboard_title, content = Markup(api_content))
|
return render_template('generic.html', title = dashboard_title, content = Markup(api_content))
|
||||||
if use_api == 'True' or use_api == "true":
|
if use_api == 'True' or use_api == "true":
|
||||||
|
access_systems = ast.literal_eval(os.popen('cat ' + access_systems_file).read())
|
||||||
|
authorized_users = ast.literal_eval(os.popen('cat ' + authorized_users_file).read())
|
||||||
api_data = request.json
|
api_data = request.json
|
||||||
# Find out mode of JSON
|
# Find out mode of JSON
|
||||||
## try:
|
## try:
|
||||||
@ -868,6 +870,8 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
auth_token_file = parser.get('GPS_DATA', 'AUTHORIZED_TOKENS_FILE')
|
auth_token_file = parser.get('GPS_DATA', 'AUTHORIZED_TOKENS_FILE')
|
||||||
use_api = parser.get('GPS_DATA', 'USE_API')
|
use_api = parser.get('GPS_DATA', 'USE_API')
|
||||||
|
access_systems_file = parser.get('GPS_DATA', 'ACCESS_SYSTEMS_FILE')
|
||||||
|
authorized_users_file = parser.get('GPS_DATA', 'AUTHORIZED_USERS_FILE')
|
||||||
|
|
||||||
#Only create if API enabled
|
#Only create if API enabled
|
||||||
if use_api == True:
|
if use_api == True:
|
||||||
@ -878,21 +882,24 @@ if __name__ == '__main__':
|
|||||||
with open(auth_token_file, 'w') as auth_token:
|
with open(auth_token_file, 'w') as auth_token:
|
||||||
auth_token.write("[]")
|
auth_token.write("[]")
|
||||||
auth_token.close()
|
auth_token.close()
|
||||||
|
|
||||||
# API settings
|
|
||||||
#authorized_apps_file = parser.get('GPS_DATA', 'AUTHORIZED_APPS_FILE')
|
|
||||||
# Default SMS TS for unit calls
|
|
||||||
unit_sms_ts = parser.get('GPS_DATA', 'UNIT_SMS_TS')
|
|
||||||
if unit_sms_ts == 2:
|
if unit_sms_ts == 2:
|
||||||
unit_sms_ts = 1
|
unit_sms_ts = 1
|
||||||
if unit_sms_ts == 1:
|
if unit_sms_ts == 1:
|
||||||
unit_sms_ts = 0
|
unit_sms_ts = 0
|
||||||
try:
|
try:
|
||||||
global authorized_users, other_systems
|
#global authorized_users, other_systems
|
||||||
from authorized_apps import authorized_users, access_systems
|
#from authorized_apps import authorized_users, access_systems
|
||||||
|
access_systems = ast.literal_eval(os.popen('cat ' + access_systems_file).read())
|
||||||
|
authorized_users = ast.literal_eval(os.popen('cat ' + authorized_users_file).read())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
# API settings
|
||||||
|
#authorized_apps_file = parser.get('GPS_DATA', 'AUTHORIZED_APPS_FILE')
|
||||||
|
# Default SMS TS for unit calls
|
||||||
|
unit_sms_ts = parser.get('GPS_DATA', 'UNIT_SMS_TS')
|
||||||
|
|
||||||
|
|
||||||
########################
|
########################
|
||||||
|
|
||||||
app.run(debug = True, port=dash_port, host=dash_host)
|
app.run(debug = True, port=dash_port, host=dash_host)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user