revert send function

This commit is contained in:
KF7EEL 2022-03-01 19:34:23 -08:00
parent 6e7a61fefd
commit 3d877f6fc5
1 changed files with 73 additions and 31 deletions

View File

@ -1090,38 +1090,80 @@ def send_sms(csbk, to_id, from_id, peer_id, call_type, msg, snd_slot = 1):
if csbk == True: if csbk == True:
use_csbk = True use_csbk = True
snd_seq_lst = create_sms_seq(to_id, from_id, peer_id, int(slot), call_type, create_crc16(gen_header(to_id, from_id, call_type)) + create_crc32(format_sms(str(msg), to_id, from_id)))
send_to_user(to_id, snd_seq_lst, int(slot), call_type = 'unit') # We know where the user is
if bytes.fromhex(to_id) in UNIT_MAP:
print('yay')
## print(CONFIG['SYSTEMS']) #[UNIT_MAP[bytes.fromhex(to_id)][2]]['MODE'])
if CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['BOTH_SLOTS'] == False and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['ENABLED'] == True:
slot = 0
snd_seq_lst = create_sms_seq(to_id, from_id, peer_id, int(slot), call_type, create_crc16(gen_header(to_id, from_id, call_type)) + create_crc32(format_sms(str(msg), to_id, from_id)))
for d in snd_seq_lst:
systems[UNIT_MAP[bytes.fromhex(to_id)][0]].send_system(d)
logger.info('Sending on TS: ' + str(slot + 1))
elif CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['BOTH_SLOTS'] == True or CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['MODE'] != 'OPENBRIDGE' and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['ENABLED'] == True:
snd_seq_lst = create_sms_seq(to_id, from_id, peer_id, int(slot), call_type, create_crc16(gen_header(to_id, from_id, call_type)) + create_crc32(format_sms(str(msg), to_id, from_id)))
for d in snd_seq_lst:
systems[UNIT_MAP[bytes.fromhex(to_id)][0]].send_system(d)
logger.info('Sending on TS: ' + str(slot + 1))
# We don't know where the user is
elif bytes.fromhex(to_id) not in UNIT_MAP:
for s in CONFIG['SYSTEMS']:
if CONFIG['SYSTEMS'][s]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][s]['BOTH_SLOTS'] == False and CONFIG['SYSTEMS'][s]['ENABLED'] == True:
slot = 0
snd_seq_lst = create_sms_seq(to_id, from_id, peer_id, int(slot), call_type, create_crc16(gen_header(to_id, from_id, call_type)) + create_crc32(format_sms(str(msg), to_id, from_id)))
for d in snd_seq_lst:
systems[s].send_system(d)
logger.info('User not in map. Sending on TS: ' + str(slot + 1))
elif CONFIG['SYSTEMS'][s]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][s]['BOTH_SLOTS'] == True and CONFIG['SYSTEMS'][s]['ENABLED'] == True or CONFIG['SYSTEMS'][s]['MODE'] != 'OPENBRIDGE' and CONFIG['SYSTEMS'][s]['ENABLED'] == True:
snd_seq_lst = create_sms_seq(to_id, from_id, peer_id, int(slot), call_type, create_crc16(gen_header(to_id, from_id, call_type)) + create_crc32(format_sms(str(msg), to_id, from_id)))
for d in snd_seq_lst:
systems[s].send_system(d)
logger.info('User not in map. Sending on TS: ' + str(slot + 1))
# Take fully formatted list of sequenced MMDVM packets and send ## if bytes.fromhex(to_id) in UNIT_MAP:
def send_to_user(to_id, seq_lst, slot, call_type = 'unit'): ## logger.debug('User in UNIT map.')
if call_type == 'unit': ## if CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['BOTH_SLOTS'] == False and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['ENABLED'] == True:
# We know where the user is ## slot = 0
if bytes.fromhex(to_id) in UNIT_MAP: ## else:
logger.debug('User in UNIT map.') ## slot = slot
## print(CONFIG['SYSTEMS']) #[UNIT_MAP[bytes.fromhex(to_id)][2]]['MODE']) ## snd_seq_lst = create_sms_seq(to_id, from_id, peer_id, int(slot), call_type, create_crc16(gen_header(to_id, from_id, call_type)) + create_crc32(format_sms(str(msg), to_id, from_id)))
if CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['BOTH_SLOTS'] == False and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['ENABLED'] == True: ## send_to_user(to_id, snd_seq_lst, int(slot), call_type = 'unit')
slot = 0 ##
for d in seq_lst: ## elif bytes.fromhex(to_id) not in UNIT_MAP:
systems[UNIT_MAP[bytes.fromhex(to_id)][0]].send_system(d) ## sms_snt = False
logger.debug('Sending on TS: ' + str(slot + 1)) ## for s in CONFIG['SYSTEMS']:
elif CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['BOTH_SLOTS'] == True or CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['MODE'] != 'OPENBRIDGE' and CONFIG['SYSTEMS'][UNIT_MAP[bytes.fromhex(to_id)][0]]['ENABLED'] == True: ## # Found OBP BOTH_SLOTS = False, format for TS 1 and send. Only need this once if multiple OBP since we don't know where ther user is.
for d in seq_lst: ## if CONFIG['SYSTEMS'][s]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][s]['BOTH_SLOTS'] == False and CONFIG['SYSTEMS'][s]['ENABLED'] == True and sms_snt == False:
systems[UNIT_MAP[bytes.fromhex(to_id)][0]].send_system(d) ## slot = 0
logger.debug('Sending on TS: ' + str(slot + 1)) ## snd_seq_lst = create_sms_seq(to_id, from_id, peer_id, int(slot), call_type, create_crc16(gen_header(to_id, from_id, call_type)) + create_crc32(format_sms(str(msg), to_id, from_id)))
# We don't know where the user is ## send_to_user(to_id, snd_seq_lst, int(slot), call_type = 'unit')
elif bytes.fromhex(to_id) not in UNIT_MAP: ## print(slot)
for s in CONFIG['SYSTEMS']: ## sms_snt = True
if CONFIG['SYSTEMS'][s]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][s]['BOTH_SLOTS'] == False and CONFIG['SYSTEMS'][s]['ENABLED'] == True: ## else:
slot = 0 ## slot = slot
for d in seq_lst: ## snd_seq_lst = create_sms_seq(to_id, from_id, peer_id, int(slot), call_type, create_crc16(gen_header(to_id, from_id, call_type)) + create_crc32(format_sms(str(msg), to_id, from_id)))
systems[s].send_system(d) ## send_to_user(to_id, snd_seq_lst, int(slot), call_type = 'unit')
logger.debug('User not in map. Sending on TS: ' + str(slot + 1)) ##
elif CONFIG['SYSTEMS'][s]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][s]['BOTH_SLOTS'] == True and CONFIG['SYSTEMS'][s]['ENABLED'] == True or CONFIG['SYSTEMS'][s]['MODE'] != 'OPENBRIDGE' and CONFIG['SYSTEMS'][s]['ENABLED'] == True: ### Take fully formatted list of sequenced MMDVM packets and send
for d in seq_lst: ##def send_to_user(to_id, seq_lst, slot, call_type = 'unit'):
systems[s].send_system(d) ## if call_type == 'unit':
logger.debug('User not in map. Sending on TS: ' + str(slot + 1)) ## # We know where the user is
## if bytes.fromhex(to_id) in UNIT_MAP:
## logger.debug('User in UNIT map.')
## ## print(CONFIG['SYSTEMS']) #[UNIT_MAP[bytes.fromhex(to_id)][2]]['MODE'])
## for d in seq_lst:
## systems[UNIT_MAP[bytes.fromhex(to_id)][0]].send_system(d)
## logger.debug('Sending on TS: ' + str(slot + 1))
##
## # We don't know where the user is
## elif bytes.fromhex(to_id) not in UNIT_MAP:
## for s in CONFIG['SYSTEMS']:
## if CONFIG['SYSTEMS'][s]['ENABLED'] == True:
## for d in seq_lst:
## systems[s].send_system(d)
## logger.debug('User not in map. Sending on TS: ' + str(slot + 1))
##
def aprs_process(packet): def aprs_process(packet):
## logger.debug(aprslib.parse(packet)) ## logger.debug(aprslib.parse(packet))