NO_INTERFACE error

Hi everyone. I’ve come across the news of the v2.0 launch - congrats to the team

I decided to upgrade my two tbeams to firmwareVersion “2.0.0.d5e2b70b-d” and wrote the following code to see if have had progress on the multi channel capabilities for the system.

I seem to be able to create new channels, set their psk values, etc. But when I try to message on any other channel than 0 I get no traffic except for this cryptic message

Received: {‘from’: 3304581912, ‘to’: 3304581912, ‘channel’: 1, ‘decoded’: {‘portnum’: ‘ROUTING_APP’, ‘payload’: b’\x18\x04’, ‘requestId’: 1115327080, ‘routing’: {‘errorReason’: ‘NO_INTERFACE’, ‘raw’: error_reason: NO_INTERFACE
}}, ‘id’: 1576636852, ‘priority’: ‘ACK’, ‘raw’: from: 3304581912
to: 3304581912
channel: 1
decoded {
portnum: ROUTING_APP
payload: “\030\004”
request_id: 1115327080
}
id: 1576636852
priority: ACK
, ‘fromId’: ‘!c4f7eb18’, ‘toId’: ‘!c4f7eb18’}

I could not find much info on this so I was wondering if someone could maybe give me a little hand and point me to the right direction? Here’s the code I’ve used to send / receive messages

import meshtastic
import meshtastic.serial_interface
import time
import datetime

from meshtastic import portnums_pb2, channel_pb2, config_pb2

from pubsub import pub

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(“Acordei!”)

# set preset
if interface.localNode.localConfig.lora.modem_preset != config_pb2.Config.LoRaConfig.ModemPreset.LONG_FAST:
    interface.localNode.localConfig.lora.modem_preset = config_pb2.Config.LoRaConfig.ModemPreset.LONG_FAST
    interface.localNode.writeConfig('lora')

ch0_settings = interface.localNode.channels[0].settings
if ch0_settings.name != "channelzero":
    ch0_settings.psk =  b''
    ch0_settings.name = "channelzero"
    interface.localNode.writeChannel(0)
    print("changed settings ch0!!")

ch1_settings = interface.localNode.channels[1].settings
if ch1_settings.name != "channel1":
    ch1_settings.psk =  b'' #meshtastic.util.fromPSK("random")
    ch1_settings.name = "channel1"
    ch1_settings.downlink_enabled = True
    ch1_settings.uplink_enabled = True
    ch1_settings.channel_num = 0
    interface.localNode.writeChannel(1)
    print("changed settings ch1!!")

def onNode(node):
print(f"Node changed: {node}")

pub.subscribe(onReceive, “meshtastic.receive”)
pub.subscribe(onConnection, “meshtastic.connection.established”)
pub.subscribe(onNode, “meshtastic.node”)

interface = meshtastic.serial_interface.SerialInterface(“/dev/ttyUSB0”) # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0

interface.showInfo()

time.sleep(1)

while True:
whattime = str(datetime.datetime.now())
print (whattime)

interface.sendText(whattime, 
            "^all",
             True,
             False,
             None,
             None,
             1)

time.sleep(10);

That is one of the ack errors, your channel settings are probably not right, did you use an old QR code?

Hi Garth - if you take a quick look at the code you will notice the channel settings is set on the onConnection callback. All I did was define a name for each of the channels with simple changes (e.g. channel name and psk password). I did try tweaking settings such as downlink,uplink _enabled but that does not seem to make any difference. Neither did the choice for a channel_num.

If I understand correctly, the QR code is essentially the modem_preset + channel name + psk, no? Can you perhaps spot any red flags with the settings I chose for channel 1?

Appreciate the attention

I would start with the CLI for testing multi channel messaging, you should not be changing settings on each send not really sure what you are trying to do here.

hmm I think you got the wrong impression from the above. I am not changing settings everytime onConnect is called. I do it only when necessary (there’s an if to test if settings have been applied). This is because I have a few test devices here and it makes it easier to ensure they’re all configured appropriately.

This code is based on what the command line client does. So in a way I am following your advice. I’ll check if the QR code generation includes settings I may have missed in my configuration.

Okay - success!

It turns out I forgot to enable the channel. On the example above, Channel1’s role was set to 2 (disabled) even though I had given it a name, psk value, etc

that’s achieved on the channel level via:
interface.localNode.channels[1].role = channel_pb2.Channel.Role.SECONDARY

Hope this helps anybody trying to send/receive messages using only the python interface

That makes sense, I rarely see that error, or really any ack error other than max retransmit