mirror of https://github.com/kf7eel/hbnet.git
revert send function again, add group data call
This commit is contained in:
parent
7002b4bf0d
commit
42c7491e86
114
data_gateway.py
114
data_gateway.py
|
|
@ -1057,6 +1057,7 @@ def format_sms(msg, to_id, from_id, use_header = True):
|
||||||
return headers + final
|
return headers + final
|
||||||
|
|
||||||
def gen_header(to_id, from_id, call_type):
|
def gen_header(to_id, from_id, call_type):
|
||||||
|
print(call_type)
|
||||||
if call_type == 1:
|
if call_type == 1:
|
||||||
seq_header = '024A' + to_id + from_id + '9550'
|
seq_header = '024A' + to_id + from_id + '9550'
|
||||||
if call_type == 0:
|
if call_type == 0:
|
||||||
|
|
@ -1092,39 +1093,79 @@ def send_sms(csbk, to_id, from_id, peer_id, call_type, msg, snd_slot = 1):
|
||||||
slot = snd_slot
|
slot = snd_slot
|
||||||
if csbk == True:
|
if csbk == True:
|
||||||
use_csbk = True
|
use_csbk = True
|
||||||
|
if ascii_call_type == 'unit':
|
||||||
|
# We know where the user is
|
||||||
# We know where the user is
|
if bytes.fromhex(to_id) in UNIT_MAP:
|
||||||
if bytes.fromhex(to_id) in UNIT_MAP:
|
## print(CONFIG['SYSTEMS']) #[UNIT_MAP[bytes.fromhex(to_id)][2]]['MODE'])
|
||||||
logger.debug('Found user in UNIT map')
|
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:
|
||||||
## print(CONFIG['SYSTEMS']) #[UNIT_MAP[bytes.fromhex(to_id)][2]]['MODE'])
|
slot = 0
|
||||||
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:
|
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)))
|
||||||
slot = 0
|
for d in snd_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[UNIT_MAP[bytes.fromhex(to_id)][0]].send_system(d)
|
||||||
logger.info('OBP ' + s + ', BOTH_SLOTS = False. Sending on TS: ' + str(slot + 1))
|
logger.info('Sending on TS: ' + str(slot))
|
||||||
for d in snd_seq_lst:
|
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:
|
||||||
systems[UNIT_MAP[bytes.fromhex(to_id)][0]].send_system(d)
|
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:
|
||||||
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:
|
systems[UNIT_MAP[bytes.fromhex(to_id)][0]].send_system(d)
|
||||||
## else:
|
logger.info('Sending on TS: ' + str(slot))
|
||||||
logger.debug('User in UNIT map, using send function')
|
# We don't know where the user is
|
||||||
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)))
|
elif bytes.fromhex(to_id) not in UNIT_MAP:
|
||||||
send_to_user(to_id, snd_seq_lst, slot, call_type)
|
for s in CONFIG['SYSTEMS']:
|
||||||
# We don't know where the user is
|
if CONFIG['SYSTEMS'][s]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][s]['BOTH_SLOTS'] == False and CONFIG['SYSTEMS'][s]['ENABLED'] == True:
|
||||||
elif bytes.fromhex(to_id) not in UNIT_MAP:
|
slot = 0
|
||||||
logger.debug('User not in UNIT map. Flooding SYSTEMS')
|
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))
|
||||||
|
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))
|
||||||
|
if ascii_call_type == 'group':
|
||||||
|
snd_seq_lst = create_sms_seq(to_id, from_id, peer_id, int(slot), 0, create_crc16(gen_header(to_id, from_id, 0)) + create_crc32(format_sms(str(msg), to_id, from_id)))
|
||||||
for s in CONFIG['SYSTEMS']:
|
for s in CONFIG['SYSTEMS']:
|
||||||
if CONFIG['SYSTEMS'][s]['MODE'] == 'OPENBRIDGE' and CONFIG['SYSTEMS'][s]['BOTH_SLOTS'] == False and CONFIG['SYSTEMS'][s]['ENABLED'] == True:
|
for d in snd_seq_lst:
|
||||||
slot = 0
|
systems[s].send_system(d)
|
||||||
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)))
|
|
||||||
logger.debug('OBP ' + s + ', BOTH_SLOTS = False. Sending on TS: ' + str(slot + 1))
|
|
||||||
for d in snd_seq_lst:
|
## if ascii_call_type == 'unit':
|
||||||
systems[s].send_system(d)
|
## # We know where the user is
|
||||||
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:
|
## if bytes.fromhex(to_id) in UNIT_MAP:
|
||||||
## else:
|
## logger.debug('UNIT call. Found user in UNIT map')
|
||||||
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)))
|
## ## print(CONFIG['SYSTEMS']) #[UNIT_MAP[bytes.fromhex(to_id)][2]]['MODE'])
|
||||||
send_to_user(to_id, snd_seq_lst, slot, call_type)
|
## 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:
|
||||||
logger.debug('Using send function.')
|
## 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)))
|
||||||
|
## logger.info('OBP ' + s + ', BOTH_SLOTS = False. Sending on TS: ' + str(slot + 1))
|
||||||
|
## for d in snd_seq_lst:
|
||||||
|
## systems[UNIT_MAP[bytes.fromhex(to_id)][0]].send_system(d)
|
||||||
|
##
|
||||||
|
## 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:
|
||||||
|
## ## else:
|
||||||
|
## logger.debug('User in UNIT map, using send function')
|
||||||
|
## 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, slot, call_type)
|
||||||
|
## # We don't know where the user is
|
||||||
|
## elif bytes.fromhex(to_id) not in UNIT_MAP:
|
||||||
|
## logger.debug('User not in UNIT map. Flooding SYSTEMS')
|
||||||
|
## 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)))
|
||||||
|
## logger.debug('OBP ' + s + ', BOTH_SLOTS = False. Sending on TS: ' + str(slot + 1))
|
||||||
|
## for d in snd_seq_lst:
|
||||||
|
## systems[s].send_system(d)
|
||||||
|
## 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:
|
||||||
|
## ## else:
|
||||||
|
## 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, slot, call_type)
|
||||||
|
## logger.debug('Using send function.')
|
||||||
|
##
|
||||||
|
## if ascii_call_type == 'group':
|
||||||
|
## logger.debug('Sending group call')
|
||||||
|
## 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, slot, ascii_call_type)
|
||||||
|
|
||||||
|
|
||||||
## if bytes.fromhex(to_id) in UNIT_MAP:
|
## if bytes.fromhex(to_id) in UNIT_MAP:
|
||||||
|
|
@ -1171,12 +1212,13 @@ def send_to_user(to_id, seq_lst, slot, call_type = 'unit'):
|
||||||
logger.debug('User not in UNIT map. Sending to all SYSTEMS.')
|
logger.debug('User not in UNIT map. Sending to all SYSTEMS.')
|
||||||
|
|
||||||
elif call_type == 'group':
|
elif call_type == 'group':
|
||||||
|
logger.debug('Group data')
|
||||||
for s in CONFIG['SYSTEMS']:
|
for s in CONFIG['SYSTEMS']:
|
||||||
if CONFIG['SYSTEMS'][s]['ENABLED'] == True:
|
if CONFIG['SYSTEMS'][s]['ENABLED'] == True:
|
||||||
for d in seq_lst:
|
for d in seq_lst:
|
||||||
systems[s].send_system(d)
|
systems[s].send_system(d)
|
||||||
logger.debug('Group data, sending to all systems.')
|
logger.debug('Group data, sending to all systems.')
|
||||||
##
|
|
||||||
|
|
||||||
def aprs_process(packet):
|
def aprs_process(packet):
|
||||||
## logger.debug(aprslib.parse(packet))
|
## logger.debug(aprslib.parse(packet))
|
||||||
|
|
@ -1571,7 +1613,7 @@ def rule_timer_loop():
|
||||||
try:
|
try:
|
||||||
for i in send_que:
|
for i in send_que:
|
||||||
try:
|
try:
|
||||||
send_sms(False, i['rcv_id'], 9, 9, 'unit', i['msg'])
|
send_sms(False, i['rcv_id'], 9, 9, i['call_type'], i['msg'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('Error sending SMS in que to ' + str(i['rcv_id']) + ' - ' + i['msg'])
|
logger.error('Error sending SMS in que to ' + str(i['rcv_id']) + ' - ' + i['msg'])
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
|
@ -1669,7 +1711,7 @@ class HBP(HBSYSTEM):
|
||||||
else:
|
else:
|
||||||
PACKET_MATCH[_rf_src] = [_data, time()]
|
PACKET_MATCH[_rf_src] = [_data, time()]
|
||||||
## try:
|
## try:
|
||||||
if _dtype_vseq in [3,6,7] and _call_type == 'unit' or _call_type == 'group' and _dytpe_vseq == 6 or _call_type == 'vcsbk':
|
if _dtype_vseq in [3,6,7] and _call_type == 'unit' or _call_type == 'group' and _dtype_vseq == 6 or _call_type == 'vcsbk':
|
||||||
data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# UNIT SMS
|
# UNIT SMS
|
||||||
curl --header "Content-Type: application/json" --request POST --data '{"gateway": "Data", "dmr_id": 1234567, "sms": "this is a test"}' http://localhost:8080/api/<your_call>/<your_api_key>
|
curl --header "Content-Type: application/json" --request POST --data '{"gateway": "Data", "dmr_id": 1234567, "type":"unit", "sms": "this is a test"}' http://localhost:8080/api/<your_call>/<your_api_key>
|
||||||
|
|
||||||
#Group SMS
|
#Group SMS
|
||||||
curl --header "Content-Type: application/json" --request POST --data '{"gateway": "Data", "dmr_id": 1234567, "type":"group", "sms": "this is a test"}' http://localhost:8080/api/<your_call>/<your_api_key>
|
curl --header "Content-Type: application/json" --request POST --data '{"gateway": "Data", "dmr_id": 1234567, "type":"group", "sms": "this is a test"}' http://localhost:8080/api/<your_call>/<your_api_key>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue