I am trying to transferring 9 16-bit floating point data(acceleratometer, gyro, magnetometer * x, y, z) fetched from icm20948 sensor by BLE Mesh, using nrf54l15dk. I changed the sensor server struct based on the "sample/bluetooth/meth/sensor_server" sample. It gives 5 elements for 5 kinds of sensors, and I changed the bt_mesh_sensor_type "people count", by adding more bt_mesh_sensor_channel channels. Then I built it and flashed it to my nrf54l15dk and tried to fetch data on nrf mesh mobile app, then I got the kernel panic error.
My code:
static const struct bt_mesh_sensor_unit people_count_sensor_unit = {
.name = "people_count_sensor_data",
.symbol = "none",
};
static const struct bt_mesh_sensor_format people_count_sensor_format = {
.size = 2,
.unit = &people_count_sensor_unit,
};
static const struct bt_mesh_sensor_channel people_count_sensor_channels[] = { {
.format = &people_count_sensor_format,
.name = "channel_1",
}, {
.format = &people_count_sensor_format,
.name = "channel_2",
},
};
static const struct bt_mesh_sensor_type people_count_sensor_type_new = {
.id = BT_MESH_PROP_ID_CUSTOM_ICM20948,
.channel_count = 2,
.channels = people_count_sensor_channels,
};
static const struct bt_mesh_sensor_value people_count_sensor_value_new = {
.format = &people_count_sensor_format,
};
// 人数传感器数据获取函数
static int people_count_get(struct bt_mesh_sensor_srv *srv,
struct bt_mesh_sensor *sensor,
struct bt_mesh_msg_ctx *ctx,
struct bt_mesh_sensor_value *rsp)
{
int err;
err = bt_mesh_sensor_value_from_micro(sensor->type->channels[0].format, BASE_UNITS_TO_MICRO(dummy_people_count_value_1), &rsp[0]);
err = bt_mesh_sensor_value_from_micro(sensor->type->channels[1].format, BASE_UNITS_TO_MICRO(dummy_people_count_value_2), &rsp[1]);
// 将虚拟数据dummy(整数)转换为sensor_value结构体
if (err && err != -ERANGE) {
printk("Error encoding people count (%d)", err);
return err;
}
return 0;
};
static struct bt_mesh_sensor people_count_sensor = { // 人数传感器定义
.type = &people_count_sensor_type_new, // 工具包自带人数传感器数据类型
.get = people_count_get,
};
Error occurred:
<err> os: r0/a1: 0x00000004 r1/a2: 0x00000458 r2/a3: 0x20005ac0
[00:02:23.457,039] <err> os: r3/a4: 0x00000004 r12/ip: 0x20000e68 r14/lr: 0x0001c02b
[00:02:23.457,047] <err> os: xpsr: 0x01100000
[00:02:23.457,055] <err> os: s[ 0]: 0x00000000 s[ 1]: 0x00000000 s[ 2]: 0x00000000 s[ 3]: 0x0004000b
[00:02:23.457,064] <err> os: s[ 4]: 0x00000000 s[ 5]: 0x00000000 s[ 6]: 0x0004c2e9 s[ 7]: 0x2000ab74
[00:02:23.457,073] <err> os: s[ 8]: 0x00000000 s[ 9]: 0x0003f3eb s[10]: 0x0004c2e9 s[11]: 0x2000ab74
[00:02:23.457,081] <err> os: s[12]: 0x00000458 s[13]: 0x0001c021 s[14]: 0x0004c2e9 s[15]: 0x0004cca6
[00:02:23.457,087] <err> os: fpscr: 0x00000458
[00:02:23.457,092] <err> os: Faulting instruction address (r15/pc): 0x0003f3d8
[00:02:23.457,124] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
[00:02:23.457,140] <err> os: Current thread: 0x20005ac0 (unknown)
*** Booting Mesh Sensor v2.9.0-687260cfb136 *** system
In the code I shown above I simply add one more channel in bt_mesh_sensor_channel structure. Can I transfer more data using this way? If not, what else method should I use?
Thank you!