#endif
typedef void (*sensor_cb_t)(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data);
-typedef void (*sensor_events_cb_t)(sensor_t sensor, unsigned int event_type, sensor_data_t* events[], int events_count, void *user_data);
+typedef void (*sensor_events_cb_t)(sensor_t sensor, unsigned int event_type, sensor_data_t events[], int events_count, void *user_data);
typedef void (*sensorhub_cb_t)(sensor_t sensor, unsigned int event_type, sensorhub_data_t *data, void *user_data);
typedef void (*sensor_accuracy_changed_cb_t) (sensor_t sensor, unsigned long long timestamp, int accuracy, void *user_data);
typedef void (*sensor_attribute_int_changed_cb_t)(sensor_t sensor, int attribute, int value, void *user_data);
if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
size_t element_size = sizeof(sensor_data_t);
size_t count = info->data_size / element_size;
- sensor_data_t *events[count];
- char* p = (char*)info->data;
- for (size_t i = 0 ; i < count; ++i) {
- events[i] = (sensor_data_t *)(p + i * element_size);
- }
- ((sensor_events_cb_t)info->cb)(info->sensor, event_type, events, count, info->user_data);
+ ((sensor_events_cb_t)info->cb)(info->sensor, event_type, (sensor_data_t*)info->data, count, info->user_data);
}
delete [] info->data;
_I("[%llu] %f %f %f\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
}
-static void events_cb(sensor_t sensor, unsigned int event_type, sensor_data_t* datas[], int events_count, void *user_data)
+static void events_cb(sensor_t sensor, unsigned int event_type, sensor_data_t datas[], int events_count, void *user_data)
{
for (int i = 0 ; i < events_count; i++) {
- _I("[%llu]", datas[i]->timestamp);
- for (int j = 0; j < datas[i]->value_count; j++)
- _I(" %f", datas[i]->values[j]);
+ _I("[%llu]", datas[i].timestamp);
+ for (int j = 0; j < datas[i].value_count; j++)
+ _I(" %f", datas[i].values[j]);
_I("\n");
}
}
_N("\n");
}
-static void test_events_cb(sensor_t sensor, unsigned int event_type, sensor_data_t* datas[], int events_count, void *user_data)
+static void test_events_cb(sensor_t sensor, unsigned int event_type, sensor_data_t datas[], int events_count, void *user_data)
{
for (int i = 0 ; i < events_count; i++) {
- _N("%llu ", datas[i]->timestamp);
- for (int j = 0; j < datas[i]->value_count; j++)
- _N(" %10f", datas[i]->values[j]);
+ _N("%llu ", datas[i].timestamp);
+ for (int j = 0; j < datas[i].value_count; j++)
+ _N(" %10f", datas[i].values[j]);
_N("\n");
}
}