MESH v5.0.0 chat_model "Out of segment buffers"

Hello, im trying to create a mesh system with sensors that work like a chat. I tested it on 5 devices and there is a strange behavior. After 120 test messages an error appears : "

i know it has to do with a buffer being full, but i dont know how to empty it. How do i get rid of this error ?

My code + config (the rest is mostly chat example) : 

void main(void)
{
    int err;

    printk("Initializing...\n");

    err = bt_enable(bt_ready);
    if (err) {
        printk("Bluetooth init failed (err %d)\n", err);
    }

    k_timer_start(&my_timer, K_MSEC(100), K_MSEC(1000));
   

}
K_WORK_DEFINE(repeating_timer_work,my_enemy);

void my_fren(struct k_timer *dummy)
{
k_work_submit(&repeating_timer_work);
}

K_TIMER_DEFINE(my_timer, my_fren, NULL);
long long int timestamp = 0;


static void my_enemy(struct k_timer *timer_id){

	if(bt_mesh_is_provisioned()){
	char * test[20];
	timestamp += 1;

    char * str[20];

	sprintf(str, "timestamp-%d",timestamp);
	
	test[0] = str;
	free(str);

	messagueages(test);
	} 
}
int messagueages(char *mes[]){

	int err;
	err = bt_mesh_chat_cli_message_send(&chat, mes[0]);
	if (err){
	LOG_WRN("Failed to send message: %d", err);
	}
	return 0;
	
}
CONFIG
CONFIG_BT_MESH_TX_SEG_MSG_COUNT=64
CONFIG_BT_MESH_RX_SEG_MSG_COUNT=64
CONFIG_BT_MESH_SEG_BUFS=64
CONFIG_BT_MESH_RX_SEG_MAX=10
CONFIG_BT_MESH_TX_SEG_MAX=10
CONFIG_BT_MESH_SEG_ACK_BASE_TIMEOUT=150
CONFIG_BT_MESH_SEG_ACK_PER_HOP_TIMEOUT=50
CONFIG_BT_MESH_SEG_ACK_PER_SEGMENT_TIMEOUT=0
CONFIG_BT_MESH_DEFAULT_TTL=7
CONFIG_BT_MESH_LOOPBACK_BUFS=3
CONFIG_BT_MESH_TX_SEG_RETRANS_COUNT=4
CONFIG_BT_MESH_TX_SEG_RETRANS_TIMEOUT_UNICAST=400
CONFIG_BT_MESH_TX_SEG_RETRANS_TIMEOUT_GROUP=50
CONFIG_BT_MESH_NETWORK_TRANSMIT_COUNT=0
CONFIG_BT_MESH_NETWORK_TRANSMIT_INTERVAL=20
CONFIG_BT_MESH_RELAY=y
CONFIG_BT_MESH_RELAY_ENABLED=y
CONFIG_BT_MESH_RELAY_RETRANSMIT_COUNT=2
CONFIG_BT_MESH_RELAY_RETRANSMIT_INTERVAL=20
CONFIG_BT_MESH_RELAY_BUF_COUNT=32
CONFIG_BT_MESH_BEACON_ENABLED=y
Parents Reply Children
  • v3.12.0 - nrf Connect
    v1.2.4 - Toolchain
    v2.1.2 - nrf Connect SDK

  • Hi Jejpi23,

    My sincerest apology for the long waiting time.

    As you have noted, the buffer is filled. However, it cannot be emptied at will by the application, as it is entirely controlled by the mesh stack. The rate data is "consumed" from this buffer is also controlled by the mesh stack. Therefore, our only approach to this is to reduce the rate the data is added to this buffer.

    Just like you have observed, one factor is how often messages are being sent.

    Another factor is that, how many times each segment is resent.

    As recommended by the Mesh Profile Spec v1.0.1 (applicable to nRF Connect SDK v2.1.2), section 3.5.3.3, each segment is sent multiple times. The number of times is configurable by CONFIG_BT_MESH_TX_SEG_RETRANS_COUNT. In my tests, reducing this to 2 has fixed the issue.


    On the other hand, I would like to recommend you reevaluate the strategy to send sensor data via human readable mesh chat messages. Like we have seen, segmented messages are quite costly to the mesh stack. It is actually quite costly to the network's throughput and the devices' power consumption as well.
    All of those are often scarce resources that needed saving. 

    The Sensor Models are created for the purpose of communicating sensor readings. Perhaps you could give those a try instead?
    You probably already know it, but here are the links to samples that use the Sensor Models:
    Bluetooth: Mesh sensor — nRF Connect SDK 2.1.2 documentation (nordicsemi.com)
    Bluetooth: Mesh sensor observer — nRF Connect SDK 2.1.2 documentation (nordicsemi.com)


    By the way, I don't really understand the motivation behind the implementation in the my_enemy function of your code. Having said that, I think it is just some test code, so it is not very important.

    Once again, I am very sorry for the very long wait.

    Best regards,

    Hieu

Related