Ejemplo n.º 1
0
def sendMessage(path):
    if (path == ""):
        interface = meshtastic.SerialInterface()
    else:
        interface = meshtastic.SerialInterface(path)
    pub.subscribe(onText, "meshtastic.receive.text")
    pub.subscribe(onConnection, "meshtastic.connection.established")
    print("Send Message: ")
    while (True):
        message = input()
        interface.sendText(message)
Ejemplo n.º 2
0
 def __init__(self, ):
     super().__init__()
     import configparser
     self.config = configparser.ConfigParser()
     self.configPath = os.path.dirname(__file__) + '/client.conf'
     print(self.configPath)
     self.config.read(self.configPath)
     print(self.config.sections())
     self.interface = meshtastic.SerialInterface()
     pub.subscribe(self.onReceive, "meshtastic.receive")
     self.jsonTXT = ""
     if "TORINOMETEO" in self.config:
         self.l = task.LoopingCall(self.getMeteoTM)
         self.l.start(float(self.config['TORINOMETEO']['updateTime']))
     if "BEACON" in self.config:
         self.b = task.LoopingCall(self.sendBeacon)
         self.b.start(float(self.config['BEACON']['updateTime']), False)
Ejemplo n.º 3
0
 def __init__(self):
     self.interface = meshtastic.SerialInterface()
     self.jsonTXT = ""
Ejemplo n.º 4
0
import meshtastic
interface = meshtastic.SerialInterface("/dev/ttyUSB0") # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
interface.sendText("hello ya dozy bastard") # or sendData to send binary data, see documentations for other options.
interface.close()

Ejemplo n.º 5
0
# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
# interface = meshtastic.SerialInterface()
# or sendData to send binary data, see documentations for other options.
# interface.debugOut()

# interface = meshtastic.SerialInterface(connectNow=False)
# interface.setOwner("Big Beacon",
#                    short_name='BB')
# interface.connect()
# interface.sendText(text="Test message! Do you hear me????")

beaconcounter = 0
beaconcycles = 10
beaconinterval = 20

interface = meshtastic.SerialInterface()
time.sleep(1)
interface.sendText("Beacon is online")

while beaconcounter <= beaconcycles:
    #pause the cycle
    if beaconinterval >= 60:
        print(f"Sleeping for {beaconinterval}")
    time.sleep(beaconinterval)

    #time stamp
    now = datetime.datetime.now()
    nowstr = now.strftime("%m/%d/%Y-%H:%M:%S")

    msg = f"{beaconcounter:05}|{nowstr}|Beacon Message."
    print(msg)
Ejemplo n.º 6
0
def main():
    window1API, window2, window3 = make_win1API(), make_win2VERSION(
    ), make_win3()

    window2.move(window1API.current_location()[0],
                 window1API.current_location()[1] + 220)

    window3.move(window1API.current_location()[0],
                 window1API.current_location()[1] + 220)

    while True:  # Event Loop
        window, event, values = sg.read_all_windows()

        if window == sg.WIN_CLOSED:  # if all windows were closed
            break

        if event == sg.WIN_CLOSED or event == 'Exit':
            window.close()
            if window == window2:  # if closing win 2, mark as closed
                window2 = None
            elif window == window1API:  # if closing win 1, mark as closed
                window1API = None
            elif window == window3:
                window3 = None

        elif event == 'Reopen2':
            if not window2:
                window2 = make_win2VERSION()
                window2.move(window1API.current_location()[0],
                             window1API.current_location()[1] + 220)

        elif event == 'Reopen3':
            if not window3:
                window3 = make_win3()
                window3.move(window1API.current_location()[0],
                             window1API.current_location()[1] - 220)

        elif event == '-IN-':
            output_window = window3 if window == window1API else window1API
            if output_window:  # if a valid window, then output to it
                output_window['-OUTPUT-'].update(values['-IN-'])
            else:
                window['-OUTPUT-'].update('Other window is closed')

        elif event == 'Connect to Radio':
            output_window = window3

            def onReceive(packet, interface):  # called when a packet arrives
                print(f"Received: {packet}")

            def onConnection(interface,
                             topic=pub.AUTO_TOPIC
                             ):  # called when we (re)connect to the radio
                # defaults to broadcast, specify a destination ID if you wish
                interface.sendText("hello mesh")

            pub.subscribe(onReceive, "meshtastic.receive")
            pub.subscribe(onConnection, "meshtastic.connection.established")
            # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
            interface = meshtastic.SerialInterface()

        elif event == 'Radio Information':  #if user clicks Radio Information
            os.system("meshtastic --info >radioinfo.txt"
                      )  # outout radio information to txt file

        elif event == 'Send Message':  #if user clicks send message take input and send to radio
            os.system("meshtastic --sendtext " + values['-MSGINPUT-'])

        elif event == 'Help':
            os.system("meshtastic -h && pause")

        elif event == 'QR':
            try:
                os.system("meshtastic --qr >QR.png")
            except:
                print('error')

        elif event == 'Set Channel':
            try:
                os.system("meshtastic --setchan spread_factor " +
                          values['-SFINPUT-'] + " --setchan coding_rate " +
                          values['-CRINPUT-'] + " --setchan bandwidth " +
                          values['-BWINPUT-'])
            except:
                os.system("echo ERROR Set Channel Event >>error.log")
        elif event == 'Set URL':
            try:
                os.system("meshtatic --seturl " + values['-URLINPUT-'])
            except:
                os.system("echo ERROR Set URL error >>error.log")

        elif event == 'Set Long Slow':
            os.system("meshtastic --setch-longslow")

        elif event == 'Set Short Fast':
            os.system("meshtastic --setch-shortfast")

        elif event == 'Set Owner':
            os.system("meshtastic --setowner " + values['-OWNERINPUT-'])

        elif event == 'Set Lattitude':
            os.system("meshtastic --setlat " + values['-SETLAT-'])

        elif event == 'Set Longitude':
            os.system("meshtastic --setlon " + values['-SETLON-'])

        elif event == 'Set Altitude':
            os.system("meshtastic --setalt " + values['-SETALT-'])

        elif event == 'Set Router':
            os.system("echo meshtastic --setrouter")

        elif event == 'Unset Router':
            os.system("echo meshtastic --unset-router")

        elif event == 'Download Firmware':
            firmwareID = 'NULL'
            try:
                if event == values['-T-Beam-'] == True:
                    firmwareID = '-tbeam'
                elif event == values['-heltec-'] == True:
                    firmwareID = "-heltec"
                elif event == values['-T-LoRa-'] == True:
                    firmwareID = "-tlora"
                elif event == values['-LoRa Relay-'] == True:
                    firmwareID = "-lora-relay"
                url = 'https://github.com/meshtastic/Meshtastic-device/releases/download/1.1.33/firmware-1.1.33.zip'
                firmwarefile = requests.get(url)
                open('test.zip', 'wb').write(firmwarefile.content)
            except:
                print('error')
        elif event == "Flash Firmware":  # this command requires .sh files be able to be handled by the system, windows can us
            try:
                os.system("sh device-install.sh -f " + values['_FILES_'])
            except:
                os.system("echo ERROR Flash Firmware Event >>error.log")
        elif event == "Update Firmware":  # update firmware while keeping settings in place
            try:
                os.system("sh device-update.sh -f " + values['_FILES_'])
            except:
                os.system("echo ERROR Firmware update Event >>error.log")
Ejemplo n.º 7
0
def onConnection(interface, topic=pub.AUTO_TOPIC):
    # defaults to broadcast to all, specify a destination ID if you wish
    # # interface.sendText("hello mesh")
    # now = datetime.datetime.now()
    # nowstr = now.strftime("%m/%d/%Y, %H:%M:%S")
    
    # # interface.sendText(f"{nowstr}|Connecting to mesh!")
    # interface.sendText(nowstr+"|Connecting to mesh!")
    # # interface.sendText("Lily Go Go, Check for receipt.",
    # #                    destinationId='2988739000')
    # # interface.sendText('Delivery Type Testing',
    # #                    destinationId=2988739000)
    msg = f"{timestamp()}|Connecting to mesh!"
    log.info(msg)
    interface.sendText(msg)


if __name__ == "__main__":
    log.info("Starting Meshtasic recorder")
    pub.subscribe(onReceive, "meshtastic.receive")
    pub.subscribe(onConnection, "meshtastic.connection.established")

    # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
    interface = meshtastic.SerialInterface(connectNow=False)
    interface.setOwner("Logger",
                    short_name='L')
    interface.connect()
    # interface.sendText(f"The current time is: {datetime.datetime.now()}")


 def start_click(self):
     global RUNNING,interface
     if(RUNNING==True):
         return
     interface = meshtastic.SerialInterface()
     RUNNING = True