Send all sensor data simultaneously?

I am using BLE mesh in nrf52840. I have modified the sensor server sample and sensor client sample to suit my requirements. I am using toolchain and sdk v2.6.1. It is working properly, but i would like to do a few improvements and I don't know how and would like some help. 

1. The first thing is that it is being used in an environment with lots of interference, so there is data loss. I am using a temperature and humidity sensor. The problem is that I am currently sending temperature and humidity separately. If i loose both temperature and humidity those can be ignored. But sometimes only temperature or only humidity is published. I reduced the get data interval quick (in the sample) to 0 so that i can get both temp and humidity at the same time. But there are times when i get only temperature or only humidity, I want a solution to send both temperature and humidity at the same time. After all it is the same sensor that is reading both these values.

 2. If there are multiple sensor servers connected to one sensor client then even if one sensor server responds 

static void get_data(struct k_work *work)
{
	if (!bt_mesh_is_provisioned()) {
		k_work_schedule(&get_data_work, K_MSEC(GET_DATA_INTERVAL));
		return;
	}

	static uint32_t sensor_idx;
	int err;
	
	/* Only one message can be published at a time. Swap sensor after each timeout. */
	switch (sensor_idx++) {
		case (0): {
			err = bt_mesh_sensor_cli_get(
				&sensor_cli, NULL, &bt_mesh_sensor_precise_present_amb_temp,
				NULL);
			if (err) {
				printk("Error getting Ambient temperature (%d)\n", err);
			}
			break;
		}
		case (1): {
			err = bt_mesh_sensor_cli_get(
				&sensor_cli, NULL, &bt_mesh_sensor_present_amb_rel_humidity,
				NULL);
			if (err) {
				printk("Error getting humidity data (%d)\n", err);
			}
			break;
		}
	}

	if (sensor_idx % 2) {
		k_work_schedule(&get_data_work, K_NO_WAIT);
	} else {
		k_work_schedule(&get_data_work, K_MSEC(GET_DATA_INTERVAL));
		sensor_idx = 0;
	}
}
 

the error message is not printed. How do I make it so that error message is printed if even one node doesn't send data

Parents Reply Children
No Data
Related