Exemple #1
0
 def send_data(self, data, compress=False):
     try:
         send_data(self.sending_socket, data, compress, includelength=True)
         address = self.socketaddresses[self.sending_socket]
         self.output_(self.sending_socket, self.host, self.port, address)
     except:
         self.remove_socket(self.sending_socket)
Exemple #2
0
    def send_data(self, data, compress=False):

        try:
            send_data(self.socket, data, compress, address=self.lastaddress)
            self.output_(self.socket, self.host, self.port, self.lastaddress)
        except:
            pass  # Client disconnected
Exemple #3
0
        print('Initialise.\n')
        board.led_red()
        master_dict, wakeup_count, data, commands, received_cmd = variables_init(
        )

        # Module initialisation
        while not contact:
            wlan, wifi_param = communication.new_connection()
            print("First connection\n")
            url_send = wifi_param["server"] + suffix_send + wifi_param["uuid"]
            print("URL generated\n")
            print(url_send)

            #Tries to contact server
            try:
                config, received_cmd = communication.send_data(url_send)
            except:
                print("WARNING: Couldn't reach server, will try again.\n")
            else:
                contact = True
                print("New config and command:\n")
                print(received_cmd)
                print(config)
            communication.wifi_disconnect(wlan)

    # Check if Wifi shall be activated, and activates it if needed and possible
    if wakeup_count * config["logging_interval"] >= config["sending_interval"]:
        wlan = communication.wifi_init()
        print("Trying a normal connection.\n")
        co_status = communication.wifi_connect(wifi_param, wlan)
        if co_status:
Exemple #4
0
 def send_data(self, data, compress=False):
     send_data(self.socket, data, compress)
Exemple #5
0
 def send_data(self, data, compress=False):
     send_data(self.socket, data, compress, includelength=True)