Hello I tried to flash a MQTT pipeline in my device. and it flashed successfully but I didn't received any payload in my broker.

But if I run the pipeline using host device, it's good.

Here's the sample of the code I run to make it standalone:

https://github.com/luxonis/depthai-experiments/tree/master/gen2-poe-mqtt

I just change this part of the main.py

with dai.Device(pipeline) as device:
    print('Connected to OAK')
    while not device.isClosed():
        time.sleep(1)

to

(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
bootloader = dai.DeviceBootloader(bl)
progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
bootloader.flash(progress, pipeline, compress=True)

Do you by any chance have the EMMC memory onboard?

#!/usr/bin/env python3

import depthai as dai

# Create pipeline
pipeline = dai.Pipeline()

cfg = dai.BoardConfig()
cfg.emmc = True
cfg.logPath = '/media/mmcsd-0-0/depthai_log_file.txt'
config = dai.Device.Config()
config.board = cfg
pipeline.setBoardConfig(cfg)

# Define source and output
camRgb = pipeline.create(dai.node.ColorCamera)
jpegEncoder = pipeline.create(dai.node.VideoEncoder)
scriptSave = pipeline.create(dai.node.Script)
scriptServer = pipeline.create(dai.node.Script)

# Properties
camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_4_K)
jpegEncoder.setDefaultProfilePreset(1, dai.VideoEncoderProperties.Profile.MJPEG)

# Note: all scripts accessing the media storage must run on LEON_CSS
scriptSave.setProcessor(dai.ProcessorType.LEON_CSS)
scriptSave.setScript("""
import os
index = 1000
import time
while True:
    # Find an unused file name first
    while True:
        path = '/media/mmcsd-0-0/' + str(index) + '.jpg'
        if not os.path.exists(path):
            break
        index += 1
    frame = node.io['jpeg'].get()
    node.warn(f'Saving to SDcard: {path}')
    with open(path, 'wb') as f:
        f.write(frame.getData())
    index += 1
    time.sleep(3)
""")

scriptServer.setProcessor(dai.ProcessorType.LEON_CSS)
scriptServer.setScript("""
import http.server
import socketserver
import socket
import fcntl
import struct
import os
import time
def get_ip_address(ifname):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    return socket.inet_ntoa(fcntl.ioctl(
        s.fileno(),
        -1071617759,  # SIOCGIFADDR
        struct.pack('256s', ifname[:15].encode())
    )[20:24])
# Note: `chdir` here will prevent unmount, this should be improved!
time.sleep(1)
os.chdir('/')
PORT = 80
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
    ip = get_ip_address('re0')
    node.warn(f'===== HTTP file server accessible at: http://{ip}')
    httpd.serve_forever()
""")

# Linking
camRgb.video.link(jpegEncoder.input)
jpegEncoder.bitstream.link(scriptSave.inputs['jpeg'])
scriptSave.inputs['jpeg'].setBlocking(False)


(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
bootloader = dai.DeviceBootloader(bl)
progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
(r, errmsg) = bootloader.flash(progress, pipeline, memory=dai.DeviceBootloader.Memory.EMMC)
if r: print("Flash OK")
else: print("Flash ERROR:", errmsg)

Perhaps you can try logging to the emmc storage like the above example to see what might be the issue.

Thanks,
Jaka

Hello Jakka,

Thanks for the response.
I tried logging but I've tried and I encountered error such as

Error Exist: [Errno 8] getaddrinfo failed

and

[1970-01-01 00:00:06.998] [Script(5)] [critical] ModuleNotFoundError: No module named 'urlparse'

At:
  /usr/lib/python3.9/importlib/_bootstrap.py(984): _find_and_load_unlocked
  /usr/lib/python3.9/importlib/_bootstrap.py(1007): _find_and_load
  <script>(55): <module>

for other device.

Do you know have any idea with this errors?

    Hi Justnothing
    What broker are you using. It looks like a DNS resolution problem.
    The second error comes from logs when device is in standalone? What about the first one - also script node?

    Thanks,
    Jaka

      Hi jakaskerl

      The first one is also a script node. I tried to use the public broker broker.emqx.io

      for the second error, yes the logs comes when the device is standalone.

        Hi Justnothing
        That is weird and you are not the first one to experience the issue. I've got no clue as to why that happens, but you can try a few things.

        1. Since this is first and foremost a connectivity issue, try changing the broker, perhaps to the one in the original experiment if you can.
        2. If the issue persists, my idea is that this could be a bootloader issue. The original experiment was done when depthai was on version 2.19.1 (requirements). There might have been a change in bootloader, which caused the standalone mode to break (DNS related maybe?). So, could you try installing depthai==2.19.1.0 and flashing the bootloader that was latest at that time (0.0.21 it think). Then try flashing your app.

        Thanks,
        Jaka