This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use Mesh Serial Example?

I have a PCA10040 working with the mesh sdk.v1.0.0 serial example. I can do an Echo via the Python interactive_syaci and get a back a response. I have seen the documentation with the commands and events. However, other than the example showing how to connect /dev/ttyACM0 /dev/ttyACM1 how are the other commands used? More specifically:

Why does send(cmd.BeaconStart(0, "0000000000000000000000000000000")) give a 'Success' message back but there's no advertising in the (Android) nRF Connect app? What's a slot? (The code seems to hardcode to only one slot? Why?)

What commands need to be sent to discover mesh devices in range? I have tried send(cmd.ScanStart()) but it just sends back a 'Success' message.

Given mesh devices in range can be determined, what commands provision them? (the example just shows provisioning physically UART connected devices).

The code seems to provide for PB-Remote via serial (infocenter.nordicsemi.com/.../group__SERIAL__PB__REMOTE__CLIENT.html. How is this accessed using the serial example?

Thanks

Simon

  • Hi Simon,

    Unfortunately it looks like you've hit an bug caused by a change in our advertiser API. For the beacon to be sent, its advertiser instance has to be enabled. To fix this, apply the following diff to mesh/serial/src/serial_handler_device.c:

    @@ -156,6 +156,16 @@ static void handle_cmd_device_beacon_start(const serial_packet_t * p_cmd)
         }
         else
         {
    +        if (m_beacons[p_cmd->payload.cmd.device.beacon_stop.beacon_slot].state != BEACON_STATE_RUNNING)
    +        {
    +            advertiser_enable(&m_beacons[p_cmd->payload.cmd.device.beacon_start.beacon_slot].advertiser);
    +        }
    +        else
    +        {
    +            /* Clear the previous beacon. */
    +            advertiser_flush(&m_beacons[p_cmd->payload.cmd.device.beacon_start.beacon_slot].advertiser);
    +        }
    +
             uint32_t data_length = p_cmd->length -
                 SERIAL_PACKET_LENGTH_OVERHEAD -
                 BEACON_START_CMD_DATA_OVERHEAD;
    @@ -195,6 +205,7 @@ static void handle_cmd_device_beacon_stop(const serial_packet_t * p_cmd)
         }
         else
         {
    +        advertiser_flush(&m_beacons[p_cmd->payload.cmd.device.beacon_start.beacon_slot].advertiser);
             advertiser_disable(&m_beacons[p_cmd->payload.cmd.device.beacon_stop.beacon_slot].advertiser);
             m_beacons[p_cmd->payload.cmd.device.beacon_stop.beacon_slot].state = BEACON_STATE_UNUSED;
         }
    

    cmd.ScanStart() should start scanning for nearby unprovisioned beacons. The example actually provisions the connected devices over BLE, the UART is just to control them. You can, e.g., program the light switch server on a separate device and use the serial interface to provision it.

    The PB-remote serial interface is unfortunately not very well supported at this point. It is not a part of the example in the current Mesh SDK version.

    Edit: The beacon slot is a configurable parameter that allows you to run multiple beacon instances. The number of slots is defined in mesh/serial/api/nrf_mesh_config_serial.h in the NRF_MESH_SERIAL_BEACON_SLOTS define. It defaults to 1.

    Edit 2: Attached pre-compiled serial example for nrf52832 with s132 v5.0. Compiled on Ubuntu/Linux with arm-none-eabi-gcc:

    serial_nrf52832_xxAA_s132_5.0.0.hex

    Running this:

    python interactive_pyaci.py -d /dev/ttyACM1 --no-logfile    
    
    To control your device, use d[x], where x is the device index.
    Devices are indexed based on the order of the COM ports specified by the -d option.
    The first device, d[0], can also be accessed using device.
    
    Type d[x]. and hit tab to see the available methods.
    
    Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: device.send(cmd.BeaconStart(0, [0x01 + len("test"), 0x09] + list(map(ord, "test"))))
    
    2018-01-09 12:32:28,999 - INFO - ttyACM1: Success
    

    Gives:

    nRF Connect output

    Hope this helps,
    Thomas

  • Thomas

    Thanks for the fix but the BeaconStart still doesn't work. Breakpoint shows it gets to advertiser_enable() but there's still no advertising. p_adv->p_packet is null in advertiser_enable().

    Simon

  • I tested this on my desk, so that's a bit weird :/ It's no problem that the advertiser is enabled with no packets in its queue. It will start sending the advertisements as soon as there is a packet ready. I've updated my answer with my testing. Are you able to send an echo command to the device?

  • I have the BeacoNStart working now thanks. It was the data I was sending to BeaconStart that was preventing it working.

Related