def __init__(self, transport, configuration, mess_gen=None):
     if mess_gen == None:
         self.mess_gen = ESP32_Message_Generator(transport)
     else:
         self.mess_gen = mess_gen
     self.configuration = configuration
     self.present = {}
     self.present[b"ibeacon"] = False
     self.present[b"wifi"] = False
     self.present[b"mqtt"] = False
     self.present["mac"] = False
     self.data_check = {}
     self.data_check[b"ibeacon"] = False
     self.data_check[b"wifi"] = False
     self.data_check[b"mqtt"] = False
     self.data_check["mac"] = False
     transport.mac_cb = self.mac_call_back
     transport.file_read_cb = self.file_read_callback
Example #2
0

def instanciate_transport():
    length = len(sys.argv)
    print("usage is esp32_monitor_mqtt.py configuration  ")
    if length > 1:

        temp = remote_configuration[sys.argv[1]][b"mqtt"]
        ip = temp[b"HOST"].decode()
        port = temp[b"PORT"]
        username = temp[b"USER_NAME"].decode()
        password = temp[b"PASSWORD"].decode()
        topic = temp[b"BASE_TOPIC"].decode()
        print(ip, port, username, password, topic)
        return MQTT_CLIENT(ip, port, username, password,
                           topic)  #ip,port,username,password,topic
    else:

        exit()


if __name__ == "__main__":
    mqtt_class = instanciate_transport()
    topic = remote_configuration[sys.argv[1]][b"mqtt"][b"BASE_TOPIC"].decode()
    transport = MQTT_TX_TRANSPORT(mqtt_class, topic)
    msg_generator = ESP32_Message_Generator(transport, "BUILT_IN_CMD")
    mqtt_class.start()
    while mqtt_class.is_connected() == False:
        time.sleep(1)
    print("mqtt is connectoed")
Example #3
0
def instanciate_transport(configuration_data):
    length = len(sys.argv)
    print("usage  serial config_name, port")
    assert length > 1
    if sys.argv[1] == "serial":
        assert length > 3
        configuration = configuration_data[sys.argv[2]]
        return configuration, Serial_Port_Manager(sys.argv[3])


if __name__ == "__main__":
    print("starting program")
    configuration, transport = instanciate_transport(remote_configuration)

    msg_generator = ESP32_Message_Generator(transport)
    file_transfer = FILE_TRANSFER(transport, configuration)

    print("starting thread \n")

    while (1):
        time.sleep(1)
        if transport.packet_recieved == True:
            print(
                "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ starting transfoer @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
            )
            msg_generator.request_wifi_mac()
            time.sleep(1)
            if file_transfer.present[
                    "mac"] == False or file_transfer.data_check["mac"] == False:
                transport.stop()
Example #4
0
from threading import Thread


def instanciate_transport(configuration_data):
    print("usage python3 esp32_monitor.py configuration")
    length = len(sys.argv)
    assert length > 1
    configuration = configuration_data[sys.argv[1]]
    return Serial_Port_Manager(configuration["com"])


if __name__ == "__main__":
    print("starting program")

    esp_serial = instanciate_transport(remote_configuration)
    msg_generator = ESP32_Message_Generator(esp_serial)

    while (1):
        time.sleep(1)
        if esp_serial.packet_recieved == True:
            time.sleep(3)
            print(
                "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ starting loop @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
            )
            msg_generator.request_list_commands()

            msg_generator.request_wifi_mac()
            time.sleep(3)
            msg_generator.request_heap_space()
            time.sleep(.3)
            msg_generator.request_list_directory("/spiffs/")