Ejemplo n.º 1
0
def activate_pod():
    verify_auth(request)

    pod = Pod()
    archive_pod()
    pod.radio_address2 = get_next_pod_address()
    pod.Save(POD_FILE + POD_FILE_SUFFIX)

    pdm = get_pdm()
    pdm.activate_pod()
    save_activated_pod_address(pod.radio_address)
    return pod
Ejemplo n.º 2
0
def _get_pod():
    global g_pod
    try:
        if g_pod is None:
            if os.path.exists(DATA_PATH + POD_FILE + POD_FILE_SUFFIX):
                g_pod = Pod.Load(DATA_PATH + POD_FILE + POD_FILE_SUFFIX,
                                 DATA_PATH + POD_FILE + POD_DB_SUFFIX)
            else:
                g_pod = Pod()
                g_pod.path = DATA_PATH + POD_FILE + POD_FILE_SUFFIX
                g_pod.path_db = DATA_PATH + POD_FILE + POD_DB_SUFFIX
                g_pod.Save()
        return g_pod
    except:
        logger.exception("Error while loading pod")
        return None
Ejemplo n.º 3
0
def new_pod():
    verify_auth(request)

    pod = Pod()

    if request.args.get('id_lot') is not None:
        pod.id_lot = int(request.args.get('id_lot'))
    if request.args.get('id_t') is not None:
        pod.id_t = int(request.args.get('id_t'))
    if request.args.get('radio_address') is not None:
        pod.radio_address = int(request.args.get('radio_address'))
        pod.radio_address2 = int(request.args.get('radio_address'))

    archive_pod()
    pod.Save(POD_FILE + POD_FILE_SUFFIX)
    return pod
Ejemplo n.º 4
0
def get_pod():
    path = "data/bbe.json"
    log_path = "data/bbe.log"
    pod = None

    try:
        pod = Pod.Load(path)
    except:
        pass

    if pod is None:
        pod = Pod()
        pod.path = path
        pod.log_file_path = log_path
        pod.id_lot = 44147
        pod.id_t = 1100256
        pod.radio_address = 0x1f0e89f0
        pod.Save()

    return pod
Ejemplo n.º 5
0
def new_pod():
    try:
        verify_auth(request)

        pod = Pod()

        if request.args.get('lot') is not None:
            pod.lot = int(request.args.get('lot'))
        if request.args.get('tid') is not None:
            pod.tid = int(request.args.get('tid'))
        if request.args.get('address') is not None:
            pod.address = int(request.args.get('address'))

        archive_pod()
        pod.Save(POD_FILE + POD_FILE_SUFFIX)
        return respond_ok({})
    except RestApiException as rae:
        return respond_error(str(rae))
    except Exception:
        logger.exception("Error while creating new pod")
        return respond_error("Other error. Please check log files.")
Ejemplo n.º 6
0
path = "data/bbe.json"
log_path = "data/bbe.log"
pod = None
try:
    pod = Pod.Load(path)
except:
    pass

if pod is None:
    pod = Pod()
    pod.path = path
    pod.log_file_path = log_path
    pod.id_lot = 44147
    pod.id_t = 1100256
    pod.radio_address = 0x1f0e89f0
    pod.Save()

mock_radio = MockPacketRadio(send_callback=skip_ack,
                             allow_connect=True,
                             allow_listen=True)
radio = PdmRadio(pod.radio_address,
                 packet_radio=mock_radio,
                 msg_sequence=pod.radio_message_sequence,
                 pkt_sequence=pod.radio_packet_sequence)

request = request_status()
response = radio.send_message_get_message(request)
response_parse(response, pod)

radio.radio_ready.wait()
time.sleep(30)
Ejemplo n.º 7
0
r.init_radio()
print("ready to listen for pdm")

p = None
while True:
    data = r.get_packet(30000)
    if data is not None and len(data) > 2:
        calc = crc8(data[2:-1])
        if data[-1] == calc:
            p = Packet(0, data[2:-1])
            break

r.disconnect()
print("disconnected")

print("Setting address as 0x%08x" % p.address)
pod.address = p.address
pod.Save(sys.argv[3])

print(
    "Now put the pdm away, wait until it's not communicating with the pod or shut it off"
)
input("press enter to continue")

pdm = Pdm(pod)
pdm.updatePodStatus()
print(pod)
pdm.cleanUp()

print("done.")
Ejemplo n.º 8
0
    pass

if pod is None:
    pod = Pod()
    pod.path = "/home/ba/newpod2.json"
    pod.log_file_path = "/home/ba/newpod2.json.log"

req_address = 0x1f000015
radio = PdmRadio(0xffffffff)

msg = request_assign_address(req_address)
rsp = radio.send_message_get_message(msg,
                                     ack_address_override=req_address,
                                     tx_power=TxPower.Lowest)
response_parse(rsp, pod)
pod.Save("/home/ba/newpod1.json")

radio.message_sequence = 1
msg = request_setup_pod(pod.id_lot, pod.id_t, pod.radio_address, 2019, 4, 3,
                        21, 35)
rsp = radio.send_message_get_message(msg,
                                     ack_address_override=pod.radio_address)
response_parse(rsp, pod)
pod.Save()

parse_version_response(
    bytearray.fromhex("02080002080002020000ab0f000e8246931f000011"), pod)
parse_version_response(
    bytearray.fromhex(
        "13881008340a5002080002080002030000ab0f000e82461f000011"), pod)