fix excessive generation in send que, zero source ID
This commit is contained in:
parent
12169a1065
commit
906ada085a
|
@ -360,15 +360,15 @@ def user_setting_write(dmr_id, setting, value):
|
||||||
user_comment = user_dict[dmr_id][3]['comment'] = value[0:35]
|
user_comment = user_dict[dmr_id][3]['comment'] = value[0:35]
|
||||||
if setting.upper() == 'APRS ON':
|
if setting.upper() == 'APRS ON':
|
||||||
user_dict[dmr_id][5] = {'APRS': True}
|
user_dict[dmr_id][5] = {'APRS': True}
|
||||||
send_sms(False, dmr_id, data_id, 0000, 'unit', 'APRS MSG TX/RX Enabled')
|
send_sms(False, dmr_id, 0000, 0000, 'unit', 'APRS MSG TX/RX Enabled')
|
||||||
if setting.upper() == 'APRS OFF':
|
if setting.upper() == 'APRS OFF':
|
||||||
user_dict[dmr_id][5] = {'APRS': False}
|
user_dict[dmr_id][5] = {'APRS': False}
|
||||||
send_sms(False, dmr_id, data_id, 0000, 'unit', 'APRS MSG TX/RX Disabled')
|
send_sms(False, dmr_id, 0000, 0000, 'unit', 'APRS MSG TX/RX Disabled')
|
||||||
if setting.upper() == 'PIN':
|
if setting.upper() == 'PIN':
|
||||||
#try:
|
#try:
|
||||||
#if user_dict[dmr_id]:
|
#if user_dict[dmr_id]:
|
||||||
user_dict[dmr_id][4]['pin'] = value
|
user_dict[dmr_id][4]['pin'] = value
|
||||||
send_sms(False, dmr_id, data_id, 0000, 'unit', 'You can now use your pin on the dashboard.')
|
send_sms(False, dmr_id, 0000, 0000, 'unit', 'You can now use your pin on the dashboard.')
|
||||||
#if not user_dict[dmr_id]:
|
#if not user_dict[dmr_id]:
|
||||||
# user_dict[dmr_id] = [{'call': str(get_alias((dmr_id), subscriber_ids))}, {'ssid': ''}, {'icon': ''}, {'comment': ''}, {'pin': pin}]
|
# user_dict[dmr_id] = [{'call': str(get_alias((dmr_id), subscriber_ids))}, {'ssid': ''}, {'icon': ''}, {'comment': ''}, {'pin': pin}]
|
||||||
#except:
|
#except:
|
||||||
|
@ -390,10 +390,10 @@ def process_sms(_rf_src, sms):
|
||||||
logger.info(parse_sms)
|
logger.info(parse_sms)
|
||||||
if parse_sms[0] == 'ID':
|
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), 0000, 0000, 'unit', 'Your DMR ID: ' + str(int_id(_rf_src)) + ' - ' + str(get_alias(int_id(_rf_src), subscriber_ids)))
|
||||||
elif parse_sms[0] == '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), 0000, 0000, 'unit', 'It works')
|
||||||
elif '@ICON' in parse_sms[0]:
|
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 parse_sms[0]:
|
elif '@SSID' in parse_sms[0]:
|
||||||
|
@ -519,7 +519,7 @@ def process_sms(_rf_src, sms):
|
||||||
|
|
||||||
|
|
||||||
if use_api == False:
|
if use_api == False:
|
||||||
send_sms(False, int_id(_rf_src), data_id, 0000, 'unit', 'API not enabled. Contact server admin.')
|
send_sms(False, int_id(_rf_src), 0000, 0000, 'unit', 'API not enabled. Contact server admin.')
|
||||||
elif '@' in parse_sms[0][0:1] and 'M-' not in parse_sms[1][0:2] or '@' not in parse_sms[0][1:]:
|
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.
|
||||||
s = ' '
|
s = ' '
|
||||||
|
@ -545,9 +545,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" or use dashboard to enable.')
|
send_sms(False, int_id(_rf_src), 0000, 0000, 'unit', 'APRS Messaging must be enabled. Send command "@APRS ON" or use dashboard to enable.')
|
||||||
except Exception as e:
|
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.')
|
send_sms(False, int_id(_rf_src), 0000, 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.')
|
||||||
|
@ -724,8 +724,8 @@ def create_sms_seq(dst_id, src_id, peer_id, _slot, _call_type, dmr_string):
|
||||||
the_mmdvm_pkt = mmdvm_encapsulate(dst_id, src_id, peer_id, cap_in, _slot, _call_type, 7, rand_seq, i)#(bytes.fromhex(re.sub("b'|'", '', str(orig_cap[cap_in][20:-4])))))
|
the_mmdvm_pkt = mmdvm_encapsulate(dst_id, src_id, peer_id, cap_in, _slot, _call_type, 7, rand_seq, i)#(bytes.fromhex(re.sub("b'|'", '', str(orig_cap[cap_in][20:-4])))))
|
||||||
mmdvm_send_seq.append(ahex(the_mmdvm_pkt))
|
mmdvm_send_seq.append(ahex(the_mmdvm_pkt))
|
||||||
cap_in = cap_in + 1
|
cap_in = cap_in + 1
|
||||||
with open('/tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/' + str(random.randint(1000, 9999)) + '.mmdvm_seq', "w") as packet_write_file:
|
with open('/tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/' + str(random.randint(1000, 9999)) + '.mmdvm_seq', "w") as packet_write_file:
|
||||||
packet_write_file.write(str(mmdvm_send_seq))
|
packet_write_file.write(str(mmdvm_send_seq))
|
||||||
|
|
||||||
return mmdvm_send_seq
|
return mmdvm_send_seq
|
||||||
|
|
||||||
|
@ -828,9 +828,8 @@ def data_que_send():
|
||||||
try:
|
try:
|
||||||
#logger.info(UNIT_MAP)
|
#logger.info(UNIT_MAP)
|
||||||
for packet_file in os.listdir('/tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/'):
|
for packet_file in os.listdir('/tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/'):
|
||||||
|
logger.info('Sending SMS')
|
||||||
snd_seq = ast.literal_eval(os.popen('cat /tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/' + packet_file).read())
|
snd_seq = ast.literal_eval(os.popen('cat /tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/' + packet_file).read())
|
||||||
|
|
||||||
for data in snd_seq:
|
for data in snd_seq:
|
||||||
# Get dest id
|
# Get dest id
|
||||||
dst_id = bytes.fromhex(str(data[10:16])[2:-1])
|
dst_id = bytes.fromhex(str(data[10:16])[2:-1])
|
||||||
|
@ -881,7 +880,7 @@ def aprs_process(packet):
|
||||||
ssid = user_ssid
|
ssid = user_ssid
|
||||||
if recipient in i[1][0]['call'] and i[1][5]['APRS'] == True and recipient_ssid in ssid:
|
if recipient in i[1][0]['call'] and i[1][5]['APRS'] == True and recipient_ssid in ssid:
|
||||||
mailbox_write(re.sub('-.*','', aprslib.parse(packet)['addresse']), aprslib.parse(packet)['from'], time(), aprslib.parse(packet)['message_text'], recipient)
|
mailbox_write(re.sub('-.*','', aprslib.parse(packet)['addresse']), aprslib.parse(packet)['from'], time(), aprslib.parse(packet)['message_text'], recipient)
|
||||||
send_sms(False, sms_id, data_id, 0000, 'unit', str('APRS / ' + str(aprslib.parse(packet)['from']) + ': ' + aprslib.parse(packet)['message_text']))
|
send_sms(False, sms_id, 0000, 0000, 'unit', str('APRS / ' + str(aprslib.parse(packet)['from']) + ': ' + aprslib.parse(packet)['message_text']))
|
||||||
try:
|
try:
|
||||||
if 'msgNo' in aprslib.parse(packet):
|
if 'msgNo' in aprslib.parse(packet):
|
||||||
#sleep(1)
|
#sleep(1)
|
||||||
|
|
|
@ -209,32 +209,20 @@ def generate_apps():
|
||||||
mod.loader.exec_module(rules)
|
mod.loader.exec_module(rules)
|
||||||
local_apps = rules.local_apps
|
local_apps = rules.local_apps
|
||||||
authorized_users = rules.authorized_users
|
authorized_users = rules.authorized_users
|
||||||
|
print(authorized_users)
|
||||||
|
|
||||||
#rules_data = ast.literal_eval(os.popen('cat ' + parser.get('GPS_DATA', 'RULES_PATH')).read())
|
|
||||||
#rules_data
|
|
||||||
public_systems_file = requests.get(parser.get('GPS_DATA', 'PUBLIC_APPS_LIST'))
|
public_systems_file = requests.get(parser.get('GPS_DATA', 'PUBLIC_APPS_LIST'))
|
||||||
public_apps = ast.literal_eval(public_systems_file.text)
|
public_apps = ast.literal_eval(public_systems_file.text)
|
||||||
access_systems = {}
|
access_systems = {}
|
||||||
#combined = public_apps.items() + local_acess_systems.items()
|
|
||||||
print(type(parser.get('GPS_DATA', 'USE_PUBLIC_APPS')))
|
print(type(parser.get('GPS_DATA', 'USE_PUBLIC_APPS')))
|
||||||
if parser.get('GPS_DATA', 'USE_PUBLIC_APPS') == 'True':
|
if parser.get('GPS_DATA', 'USE_PUBLIC_APPS') == 'True':
|
||||||
for i in public_apps.items():
|
for i in public_apps.items():
|
||||||
key = str(i[0])
|
key = str(i[0])
|
||||||
access_systems[key] = i[1]
|
access_systems[key] = i[1]
|
||||||
for i in local_apps.items():
|
for i in local_apps.items():
|
||||||
key = str(i[0])
|
key = str(i[0])
|
||||||
access_systems[key] = i[1]
|
access_systems[key] = i[1]
|
||||||
print(access_systems)
|
|
||||||
print(authorized_users)
|
|
||||||
print(local_apps)
|
|
||||||
#print(rules_data)
|
|
||||||
|
|
||||||
#print(type(public_apps))
|
|
||||||
#print(type(local_acess_systems))
|
|
||||||
#print()
|
|
||||||
#print(combined)
|
|
||||||
#print(local_acess_systems.update(public_apps))
|
|
||||||
#return access_systems
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
|
@ -1018,9 +1006,11 @@ if __name__ == '__main__':
|
||||||
#authorized_users_file = parser.get('GPS_DATA', 'AUTHORIZED_USERS_FILE')
|
#authorized_users_file = parser.get('GPS_DATA', 'AUTHORIZED_USERS_FILE')
|
||||||
|
|
||||||
que_dir = '/tmp/.hblink_data_que_' + str(parser.get('GPS_DATA', 'APRS_LOGIN_CALL').upper()) + '/'
|
que_dir = '/tmp/.hblink_data_que_' + str(parser.get('GPS_DATA', 'APRS_LOGIN_CALL').upper()) + '/'
|
||||||
generate_apps()
|
|
||||||
#Only create if API enabled
|
#Only create if API enabled
|
||||||
if use_api == True:
|
print(type(use_api))
|
||||||
|
unit_sms_ts = parser.get('GPS_DATA', 'UNIT_SMS_TS')
|
||||||
|
if use_api == 'True':
|
||||||
|
generate_apps()
|
||||||
if Path(auth_token_file).is_file():
|
if Path(auth_token_file).is_file():
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -1032,19 +1022,19 @@ if __name__ == '__main__':
|
||||||
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())
|
#access_systems = ast.literal_eval(os.popen('cat ' + access_systems_file).read())
|
||||||
#authorized_users = ast.literal_eval(os.popen('cat ' + authorized_users_file).read())
|
#authorized_users = ast.literal_eval(os.popen('cat ' + authorized_users_file).read())
|
||||||
print('generaty')
|
|
||||||
except Exception as e:
|
## except Exception as e:
|
||||||
print(e)
|
## print(e)
|
||||||
|
|
||||||
# API settings
|
# API settings
|
||||||
#authorized_apps_file = parser.get('GPS_DATA', 'AUTHORIZED_APPS_FILE')
|
#authorized_apps_file = parser.get('GPS_DATA', 'AUTHORIZED_APPS_FILE')
|
||||||
# Default SMS TS for unit calls
|
# Default SMS TS for unit calls
|
||||||
unit_sms_ts = parser.get('GPS_DATA', 'UNIT_SMS_TS')
|
|
||||||
|
|
||||||
|
|
||||||
########################
|
########################
|
||||||
|
|
Loading…
Reference in New Issue