Adding a small interpreted language like TCL?

Having some “edge intelligence” would be pretty useful, for using sensors that aren’t already supported, automating things on a schedule, counting events and sending averages rather than raw data, etc.

Even something like this tiny TCL interpreter(Picol) could easily handle these kinds of applications, with only a few hundred extra lines of code.

Arbitrary telemetry would become a lot more powerful of it gets added, and it would enable a lot of interesting standalone remote control type devices.

I’m imagining something like MIDI, that would let you send and receive events over the mesh, so you could have stuff like motion sensor lights that are synchronized, but know to automatically turn themselves off, can automatically turn off, etc.

1 Like

The serial module is the way to add something like this. Serial Module Configuration | Meshtastic

Ah, as in just adding a second independent MCU to handle everything other than comms?

Seems like it would still be nice to be able to do everything on just one chip, especially when you could also remotely update the interpreted code.

Can’t add every edge case right into the main firmware.

1 Like

Anyone tried to broadcast MIDI protocol over meshtastic yet?
It could be a used to control synthtesers from a master keyboard.

As it can encode note, pitch and velocity over hundreds of values.
We could imagine a lot of other applications :wink:

It exists MIDI to serial python programs like

I could be wrong,
To play with these feature…
it would just need a patch over direct serial communication using mestastic commands that sends data through a private meshtastic channel instead.

response to this question :

To modify the program to use the Meshtastic Python library to send MIDI signals over it, we’ll need to integrate Meshtastic functionality for sending and receiving messages. We’ll replace the serial communication part with Meshtastic, which will handle sending and receiving messages wirelessly. Here’s a modified version of your program:

Make sure you have the Meshtastic Python library installed (pip install meshtastic).

import time
import queue
import rtmidi
import threading
import logging
import PySimpleGUI as sg
from meshtastic import MeshDevice, MeshPacket

bridgeActive = False
logging.basicConfig(level=logging.DEBUG)
myfont = 'Any 12'
midi_ready = False
midiin_message_queue = queue.Queue()
midiout_message_queue = queue.Queue()
mesh_device = None

def popupError(s):
    sg.popup_error(s, font=myfont)

def get_midi_length(message):
    if len(message) == 0:
        return 100
    opcode = message[0]
    if opcode >= 0xf4:
        return 1
    if opcode in [0xf1, 0xf3]:
        return 2
    if opcode == 0xf2:
        return 3
    if opcode == 0xf0:
        if message[-1] == 0xf7:
            return len(message)

    opcode = opcode & 0xf0
    if opcode in [0x80, 0x90, 0xa0, 0xb0, 0xe0]:
        return 3
    if opcode in [0xc0, 0xd0]:
        return 2

    return 100

def midi_watcher():
    global bridgeActive

    while bridgeActive:
        try:
            message = midiout_message_queue.get(timeout=0.4)
        except queue.Empty:
            continue
        midiout.send_message(message)

def startMeshtasticMidiServer(portIn, portOut):
    global mesh_device, midi_ready, bridgeActive
    bridgeActive = True
    mesh_device = MeshDevice()
    mesh_device.start()

    while not mesh_device.is_connected():
        time.sleep(0.1)

    midi_ready = True

    midiin.ignore_types(sysex=False, timing=False, active_sense=False)
    midiin.set_callback(midi_input_handler(portIn))

    s_watcher = threading.Thread(target=mesh_watcher)
    m_watcher = threading.Thread(target=midi_watcher)
    s_watcher.start()
    m_watcher.start()

def stopMeshtasticMidiServer():
    global mesh_device, midi_ready, bridgeActive
    bridgeActive = False
    midi_ready = False
    mesh_device.stop()

class midi_input_handler(object):
    def __init__(self, port):
        self.port = port
        self._wallclock = time.time()

    def __call__(self, event, data=None):
        message, deltatime = event
        self._wallclock += deltatime
        midiin_message_queue.put(message)

def mesh_watcher():
    global midi_ready, bridgeActive

    while bridgeActive:
        try:
            packet = mesh_device.radio.get_packet(timeout=0.4)
        except queue.Empty:
            continue

        if packet is not None and packet.decoded['decoded']['messageType'] == 'DATA':
            midiout_message_queue.put(packet.decoded['decoded']['text'])

setMidiPorts()
# Rest of your GUI code remains the same...

Changes Made:

  • Removed the serial related functions.
  • Added functions for starting and stopping the Meshtastic Mesh device.
  • Added mesh_watcher function to listen for incoming MIDI messages over Meshtastic.
  • Modified startMeshtasticMidiServer to initialize Meshtastic and start the necessary threads.
  • Modified stopMeshtasticMidiServer to stop the Meshtastic device.

This code assumes the Meshtastic device is connected and reachable. You might need to modify it further based on your specific setup with Meshtastic. Also, make sure you have the Meshtastic device and a network to connect to, as this code doesn’t handle the device setup and connection process.