0

I want to send 20bytes of data between 2 custom BleMesh models which are configured in a Server and Client node respectively. In the current setup of the firmware, the Server node pings the Client node with 3bytes of data request in a specific opcode blemesh model and the Client node should send 20bytes in response to the same model opcode. This request response should run periodically at an interval of 1s. The Server node receives the 20bytes of information only once and then throws the following error without receiving any further response from the Client Node, although the Client Node receives the requests from the Server Node,

E (84763) NimBLE: bt_mesh_ctl_send: Out of transport buffers

I am using the NrfMesh app to provision the Server and the Client Nodes(both are esp32 dev modules and the Nimble BleMesh stack is used). I am using the below firmware to communicate between the models of the Server and the Client node.

    /*For ServerNode*/
static const struct bt_mesh_model_op vnd_model_op[] = {
    { BT_MESH_MODEL_OP_3(0x03, CID_ESP), 2, vnd_model_recv },
    BT_MESH_MODEL_OP_END,
 };

    static const struct bt_mesh_model_op custom_sensor_op[] = {
        {BT_MESH_MODEL_OP_3(0x00, CID_ESP), 0, custom_sensor_get},  
        {BT_MESH_MODEL_OP_3(0x01, CID_ESP), 0, custom_sensor_set},
        {BT_MESH_MODEL_OP_3(0x02, CID_ESP), 0, custom_sensor_stat},
//      {BT_MESH_MODEL_OP_3(0x03, CID_ESP), 0, vnd_model_recv},
        BT_MESH_MODEL_OP_END,
};

static model_sensor_data_t _server_model_state = {
    .device_name = "esp_s",
    .temperature = 0,
    .pressure = 0,
    .tVOC = 0,
};

static struct bt_mesh_model custom_models[] = {
        BT_MESH_MODEL_VND(CID_ESP, ESP_BLE_MESH_CUSTOM_SENSOR_MODEL_ID_SERVER,
    custom_sensor_op, NULL, &_server_model_state),
    BT_MESH_MODEL_VND(CID_ESP, BT_MESH_MODEL_ID_GEN_ONOFF_SRV, vnd_model_op,
                        &vnd_model_pub, NULL),
};


void ServerDataRequestTask(void *param)
{

    struct bt_mesh_model *model = &custom_models[1];
    struct bt_mesh_msg_ctx ctx = {
            .addr     = ClientAddr,
    };

    while(1)
    {
        struct os_mbuf *msg = NET_BUF_SIMPLE(3);
        bt_mesh_model_msg_init(msg, BT_MESH_MODEL_OP_3(0x03, CID_ESP));
        //  os_mbuf_append(msg, "HelloFromClient", strlen("HelloFromClient"));
        net_buf_simple_add_le32(msg, 0x554d49);
        console_printf("Requesting Data From Client Vendor Model\n");
        if (bt_mesh_model_send(&model, &ctx, msg, NULL, NULL)) {
            console_printf("#vendor-model-recv: send rsp failed\n");
        }

        os_mbuf_free_chain(msg);
        vTaskDelay(1000 * CONFIG_FREERTOS_HZ / 1000);
    }
    vTaskDelete(NULL);
}

/*For Client Node*/
    static const struct bt_mesh_model_op custom_sensor_op[] = {
        {BT_MESH_MODEL_OP_3(0x00, CID_ESP), 0, custom_sensor_g},       
        {BT_MESH_MODEL_OP_3(0x01, CID_ESP), 0, custom_sensor_s},        
        {BT_MESH_MODEL_OP_3(0x02, CID_ESP), 0, custom_sensor_status},   
//      {BT_MESH_MODEL_OP_3(0x03, CID_ESP), 0, vnd_model_recv},         
        BT_MESH_MODEL_OP_END,
};

static const struct bt_mesh_model_op vnd_model_op[] = {
        { BT_MESH_MODEL_OP_3(0x03, CID_ESP), 2, vnd_model_recv },
        BT_MESH_MODEL_OP_END,
};

static struct bt_mesh_model custom_models[] = {
        BT_MESH_MODEL_VND(CID_ESP, ESP_BLE_MESH_CUSTOM_SENSOR_MODEL_ID_CLIENT,
                    custom_sensor_op, NULL, NULL),
    BT_MESH_MODEL_VND(CID_ESP, BT_MESH_MODEL_ID_GEN_ONOFF_SRV, vnd_model_op,
                    &vnd_model_pub, NULL),
};

static void vnd_model_recv(struct bt_mesh_model *model,
        struct bt_mesh_msg_ctx *ctx,
        struct os_mbuf *buf)
{

    console_printf("Command received from server << ");
    console_printf("%s\n", buf->om_data); //bt_hex(buf->om_data, buf->om_len);
    sendResponseToServer = 1;
    ServerAddr           = ctx->addr;
    xQueueSend(ResponseQueue, (void*)&sendResponseToServer, (TickType_t)0);

}

void SendResponseTask(void *param)
{
struct bt_mesh_model *model = &custom_models[1];
uint8_t status;


while(1)
{
    //vTaskDelay(5);
    if(xQueueReceive(ResponseQueue, (void *)&status, (portTickType)1))
    {
        struct bt_mesh_msg_ctx ctx = {
                    .addr     = ServerAddr,
            };

        struct os_mbuf *msg = NET_BUF_SIMPLE(3);
        bt_mesh_model_msg_init(msg, BT_MESH_MODEL_OP_3(0x03, CID_ESP));
        os_mbuf_append(msg, "HelloFromClient", strlen("HelloFromClient"));
        console_printf("Sending reply to server from task\n");
        if (bt_mesh_model_send(&model, &ctx, msg, NULL, NULL)) {
            console_printf("#vendor-model-recv: send rsp failed\n");
        }

        os_mbuf_free_chain(msg);
        console_printf("Message sent successfully\n");
    }

}
  vTaskDelete(NULL);
}

Please let me know if the problem statement is possible to handle using the models that I am currently using and any inputs will be highly appreciated.

0 Answers0