- new log format is applied.
Change-Id: I5009031a8d3de8d8a51cc1c9cc2e2fe7ac47e5ae
Signed-off-by: Jinhyung Choi <jinhyung2.choi@samsung.com>
MSG_ACT_LIGHT = 113,
MSG_ACT_PROXI = 114,
MSG_ACT_MOTION = 115,
+ MSG_ACT_PRESSURE = 116,
+ MSG_ACT_UV = 117,
+ MSG_ACT_HRM = 118,
MSG_ACT_LOCATION = 120
};
level_geo = 5,
level_battery = 8,
level_tilt = 12,
- level_magnetic = 13
+ level_magnetic = 13,
+ level_pressure = 20,
+ level_uv = 21,
+ level_hrm = 22,
};
#define MAX_CATEGORY_LEN 10
#include <stdbool.h>
#include <glib.h>
-#ifdef CONFIG_LINUX
-#include <sys/epoll.h>
-#endif
-
#include "hw/qdev.h"
#include "net/net.h"
#include "net/slirp.h"
#include "qemu/queue.h"
#include "sysemu/char.h"
#include "qemu/main-loop.h"
+
+#ifdef CONFIG_LINUX
+#include <sys/epoll.h>
+#endif
+
+#ifndef CONFIG_WIN32
+#include <arpa/inet.h>
+#endif
+
#include "qemu-common.h"
-#include "util/sdb.h"
#include "ecs-json-streamer.h"
#include "qmp-commands.h"
ECS__Master master = ECS__MASTER__INIT;
ECS__DeviceAns ans = ECS__DEVICE_ANS__INIT;
- TRACE("device ans - category : %s, succed : %d\n", category, succeed);
+ LOG_TRACE("device ans - category : %s, succed : %d\n", category, succeed);
catlen = strlen(category);
ans.category = (char*) g_malloc0(catlen + 1);
ans.data.data = g_malloc(ans.length);
ans.data.len = ans.length;
memcpy(ans.data.data, data, ans.length);
- TRACE("data = %s, length = %hu\n", data, ans.length);
+ LOG_TRACE("data = %s, length = %hu\n", data, ans.length);
}
}
ans.data.len = length;
memcpy(ans.data.data, tizen_target_img_path, length);
- TRACE("data = %s, length = %hu\n", tizen_target_img_path, length);
+ LOG_TRACE("data = %s, length = %hu\n", tizen_target_img_path, length);
}
master.type = ECS__MASTER__TYPE__DEVICE_ANS;
get_sensor_light();
} else if (action == MSG_ACT_PROXI) {
get_sensor_proxi();
+ } else if (action == MSG_ACT_PRESSURE) {
+ get_sensor_pressure();
+ } else if (action == MSG_ACT_UV) {
+ get_sensor_uv();
+ } else if (action == MSG_ACT_HRM) {
+ get_sensor_hrm();
}
} else {
if (data != NULL) {
set_injector_data(data);
} else {
- ERR("sensor set data is null\n");
+ LOG_SEVERE("sensor set data is null\n");
}
}
msgproc_device_ans(ccli, cmd, true, NULL);
}
if (data != NULL) {
- TRACE(">>> Network msg: '%s'\n", data);
+ LOG_TRACE(">>> Network msg: '%s'\n", data);
if(net_slirp_redir(data) < 0) {
- ERR( "redirect [%s] fail\n", data);
+ LOG_SEVERE( "redirect [%s] fail\n", data);
} else {
- TRACE("redirect [%s] success\n", data);
+ LOG_TRACE("redirect [%s] success\n", data);
}
} else {
- ERR("Network redirection data is null.\n");
+ LOG_SEVERE("Network redirection data is null.\n");
}
if (data) {
#endif
if (data == NULL) {
- ERR("touch gesture data is NULL\n");
+ LOG_SEVERE("touch gesture data is NULL\n");
return;
}
- TRACE("%s\n", data);
+ LOG_TRACE("%s\n", data);
char token[] = "#";
}
// cli input
- TRACE("receive input message [%s]\n", data);
+ LOG_TRACE("receive input message [%s]\n", data);
if (group == 0) {
- TRACE("input keycode data : [%s]\n", data);
+ LOG_TRACE("input keycode data : [%s]\n", data);
char token[] = " ";
char *section = strtok(data, token);
do_hw_key_event(KEY_RELEASED, keycode);
} else {
- ERR("unknown action : [%d]\n", (int)action);
+ LOG_SEVERE("unknown action : [%d]\n", (int)action);
}
} else if (group == 1) {
//spec out
- TRACE("input category's group 1 is spec out\n");
+ LOG_TRACE("input category's group 1 is spec out\n");
} else {
- ERR("unknown group [%d]\n", (int)group);
+ LOG_SEVERE("unknown group [%d]\n", (int)group);
}
msgproc_device_ans(ccli, cmd, true, NULL);
if (data != NULL) {
send_to_nfc(ccli->client_id, ccli->client_type, data, msg->data.len);
} else {
- ERR("nfc data is null\n");
+ LOG_SEVERE("nfc data is null\n");
}
}
memcpy(data, msg->data.data, msg->data.len);
}
- INFO("hds group: %d, action : %d\n", group, action);
+ LOG_INFO("hds group: %d, action : %d\n", group, action);
if (group == MSG_GROUP_STATUS) {
char hds_data_send[PATH_MAX + 3];
if (is_hds_attached()) {
}
make_send_device_ntf(cmd, group, 99, hds_data_send);
} else if (group == 100 && action == 1) {
- INFO("try attach with is_hds_attached : %d\n", is_hds_attached());
+ LOG_INFO("try attach with is_hds_attached : %d\n", is_hds_attached());
if (data != NULL && !is_hds_attached()) {
LOG_INFO("do attach : %s\n", hds_path);
memset(hds_path, 0, sizeof(hds_path));
memcpy(hds_path, data, sizeof(hds_path) - 1);
do_hotplug(ATTACH_HDS, hds_path, strlen(hds_path) + 1);
- INFO("send emuld to mount.\n");
+ LOG_INFO("send emuld to mount.\n");
send_msg_to_guest(ccli, cmd, group, action, data, strlen(data));
} else {
make_send_device_ntf(cmd, 100, 2, NULL);
}
} else if (group == 100 && action == 2) {
- INFO("try detach with is_hds_attached : %d\n", is_hds_attached());
+ LOG_INFO("try detach with is_hds_attached : %d\n", is_hds_attached());
if (is_hds_attached()) {
- INFO("send emuld to umount.\n");
+ LOG_INFO("send emuld to umount.\n");
send_msg_to_guest(ccli, cmd, group, action, NULL, 0);
} else {
- INFO("hds is not attached. do not try detach it.\n");
+ LOG_INFO("hds is not attached. do not try detach it.\n");
}
} else {
- ERR("hds unknown command: group %d action %d\n", group, action);
+ LOG_SEVERE("hds unknown command: group %d action %d\n", group, action);
}
if (data) {
memset(cmd, 0, 10);
strcpy(cmd, msg->category);
- TRACE(">> device_req: header = cmd = %s, length = %d, action=%d, group=%d\n",
+ LOG_TRACE(">> device_req: header = cmd = %s, length = %d, action=%d, group=%d\n",
cmd, msg->length, msg->action, msg->group);
if (!strcmp(cmd, MSG_TYPE_SENSOR)) {
msgproc_device_req_tgesture(ccli, msg);
} else if (!strcmp(cmd, "info")) {
// check to emulator target image path
- TRACE("receive info message %s\n", tizen_target_img_path);
+ LOG_TRACE("receive info message %s\n", tizen_target_img_path);
send_target_image_information(ccli);
} else if (!strcmp(cmd, "hds")) {
msgproc_device_req_hds(ccli, msg, cmd);
} else if (!strcmp(cmd, "nfc")) {
msgproc_device_req_nfc(ccli, msg);
} else {
- ERR("unknown cmd [%s]\n", cmd);
+ LOG_SEVERE("unknown cmd [%s]\n", cmd);
}
return true;
const char* ijdata = (data + catsize + 2 + 1 + 1);
- TRACE("<< header cat = %s, length = %d, action=%d, group=%d\n", cat, length,action, group);
+ LOG_TRACE("<< header cat = %s, length = %d, action=%d, group=%d\n", cat, length,action, group);
ECS__Master master = ECS__MASTER__INIT;
ECS__DeviceNtf ntf = ECS__DEVICE_NTF__INIT;
ntf.data.len = length;
memcpy(ntf.data.data, ijdata, length);
- TRACE("data = %s, length = %hu\n", ijdata, length);
+ LOG_TRACE("data = %s, length = %hu\n", ijdata, length);
}
master.type = ECS__MASTER__TYPE__DEVICE_NTF;
#include "hw/virtio/maru_virtio_power.h"
#include "hw/virtio/maru_virtio_jack.h"
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(qemu, ecs);
+
#define TEMP_BUF_SIZE 255
#define MAX_VAL_LENGTH 40
{
int index = 0;
- memset(tmp, 0, sizeof(TEMP_BUF_SIZE));
+ memset(tmp, 0, strlen(tmp));
index = parse_val(buf, 0x0a, tmp);
tmp[index - 1] = 0;
len += get_parse_val(data + len, tmp);
z = _accel_min_max(tmp);
- memset(tmp, 0, TEMP_BUF_SIZE);
+ memset(tmp, 0, sizeof(tmp));
- sprintf(tmp, "%d, %d, %d", x, y, z);
+ sprintf(tmp, "%d,%d,%d", x, y, z);
set_sensor_accel(tmp, strlen(tmp));
}
}
}
+static void _req_set_sensor_pressure(int len, const char* data)
+{
+ char tmp[TEMP_BUF_SIZE];
+ int pressure, temperature;
+
+ // get sensor level
+ len += get_parse_val(data + len, tmp);
+
+ // pressure
+ len += get_parse_val(data + len, tmp);
+ pressure = atoi(tmp);
+
+ // temperature
+ len += get_parse_val(data + len, tmp);
+ temperature = atoi(tmp);
+
+ memset(tmp, 0, sizeof(tmp));
+
+ sprintf(tmp, "%d, %d", pressure, temperature);
+
+ set_sensor_pressure(tmp, strlen(tmp));
+}
+
+static void _req_set_sensor_uv(int len, const char* data)
+{
+ char tmp[TEMP_BUF_SIZE];
+
+ // get sensor level
+ len += get_parse_val(data + len, tmp);
+
+ // value
+ len += get_parse_val(data + len, tmp);
+
+ set_sensor_uv(tmp, strlen(tmp));
+}
+
+static void _req_set_sensor_hrm(int len, const char* data)
+{
+ char tmp[TEMP_BUF_SIZE];
+ int hrm, rri, index;
+
+ // get sensor level
+ len += get_parse_val(data + len, tmp);
+
+ // get index
+ len += get_parse_val(data + len, tmp);
+ index = atoi(tmp);
+
+ if (index == 1 || index == 0) {
+ // heart rate
+ len += get_parse_val(data + len, tmp);
+ hrm = atoi(tmp);
+ }
+
+ if (index == 2 || index == 0) {
+ // RRI
+ len += get_parse_val(data + len, tmp);
+ rri = atoi(tmp);
+ }
+
+ memset(tmp, 0, sizeof(tmp));
+
+ if (index == 0) {
+ sprintf(tmp, "%d, %d", hrm, rri);
+ set_sensor_hrm(tmp, strlen(tmp));
+ } else if (index == 1) {
+ sprintf(tmp, "%d", hrm);
+ set_sensor_hrm_heart(tmp, strlen(tmp));
+ } else if (index == 2) {
+ sprintf(tmp, "%d", rri);
+ set_sensor_hrm_rri(tmp, strlen(tmp));
+ } else {
+ LOG_SEVERE("unknown index with data '%s' & index '%d'\n", data, index);
+ }
+}
+
static void _req_set_sensor_gyro(int len, const char* data)
{
char tmp[TEMP_BUF_SIZE];
len += get_parse_val(data + len, tmp);
z = (int)atoi(tmp);
- memset(tmp, 0, TEMP_BUF_SIZE);
+ memset(tmp, 0, sizeof(tmp));
sprintf(tmp, "%d %d %d", x, y, z);
len += get_parse_val(data + len, tmp);
accuracy = atoi(tmp);
- memset(tmp, 0, TEMP_BUF_SIZE);
+ memset(tmp, 0, sizeof(tmp));
sprintf(tmp, "%d %d %d %d", x, y, z, accuracy);
len += get_parse_val(data + len, tmp);
t_vertical = atoi(tmp);
- memset(tmp, 0, TEMP_BUF_SIZE);
+ memset(tmp, 0, sizeof(tmp));
sprintf(tmp, "%d %d %d", t_north, t_east, t_vertical);
len += get_parse_val(data + len, tmp);
z = atoi(tmp);
- memset(tmp, 0, TEMP_BUF_SIZE);
+ memset(tmp, 0, sizeof(tmp));
sprintf(tmp, "%d %d %d %d", x, y, z, accuracy);
len += get_parse_val(data + len, tmp);
z = atoi(tmp);
- memset(tmp, 0, TEMP_BUF_SIZE);
+ memset(tmp, 0, sizeof(tmp));
sprintf(tmp, "%d %d %d", x, y, z);
case level_magnetic:
_req_set_sensor_mag(len, data);
break;
+ case level_pressure:
+ _req_set_sensor_pressure(len, data);
+ break;
+ case level_uv:
+ _req_set_sensor_uv(len, data);
+ break;
+ case level_hrm:
+ _req_set_sensor_hrm(len, data);
+ break;
default:
break;
}
static QemuMutex light_mutex;
static QemuMutex proxi_mutex;
static QemuMutex rot_mutex;
+static QemuMutex pressure_mutex;
+static QemuMutex uv_mutex;
+static QemuMutex hrm_mutex;
static char accel_xyz [__MAX_BUF_SENSOR] = {'1','0','0',',','9','8','0','6','6','5',',','1','0','0'};
static int accel_enable = 0;
static int rot_enable = 0;
static int rot_delay = 200000000;
+static char pressure_data [__MAX_BUF_SENSOR] = {'7','6','0',',',' ','4','2','5', 0};
+static int pressure_enable = 0;
+static int pressure_delay = 200000000;
+
+static int uv_level = 0;
+static int uv_enable = 0;
+static int uv_delay = 200000000;
+
+static int hrm_heart = 1000;
+static int hrm_rri = 600;
+static int hrm_enable = 0;
+static int hrm_delay = 200000000;
+
VirtIOSENSOR* vsensor;
static int sensor_capability = 0;
case sensor_type_rotation_vector:
action = ACTION_ROTATION;
break;
+ case sensor_type_pressure:
+ action = ACTION_PRESSURE;
+ break;
+ case sensor_type_uv:
+ action = ACTION_UV;
+ break;
+ case sensor_type_hrm:
+ action = ACTION_HRM;
+ break;
default:
break;
}
memcpy(ecs_message + 13, &action, sizeof(unsigned char));
memcpy(ecs_message + 14, data, buf_len);
- TRACE("ntf_to_injector- len: %d, group: %d, action: %d, data: %s\n", length, group, action, data);
+ LOG_TRACE("ntf_to_injector- len: %d, group: %d, action: %d, data: %s\n", length, group, action, data);
send_device_ntf(ecs_message, message_len);
static void __set_sensor_data (enum sensor_types type, char* data, int len)
{
if (len < 0 || len > __MAX_BUF_SENSOR) {
- ERR("sensor data size is wrong.\n");
+ LOG_SEVERE("sensor data size is wrong.\n");
return;
}
if (data == NULL) {
- ERR("sensor data is NULL.\n");
+ LOG_SEVERE("sensor data is NULL.\n");
return;
}
- TRACE("set_sensor_data with type '%d' with data '%s'", type, data);
+ LOG_TRACE("set_sensor_data with type '%d' with data '%s'", type, data);
switch (type) {
case sensor_type_accel:
sscanf(data, "%d", &geo_delay);
qemu_mutex_unlock(&geo_mutex);
break;
+ case sensor_type_pressure:
+ qemu_mutex_lock(&pressure_mutex);
+ strcpy(pressure_data, data);
+ qemu_mutex_unlock(&pressure_mutex);
+ break;
+ case sensor_type_pressure_enable:
+ qemu_mutex_lock(&pressure_mutex);
+ sscanf(data, "%d", &pressure_enable);
+ qemu_mutex_unlock(&pressure_mutex);
+ break;
+ case sensor_type_pressure_delay:
+ qemu_mutex_lock(&pressure_mutex);
+ sscanf(data, "%d", &pressure_delay);
+ qemu_mutex_unlock(&pressure_mutex);
+ break;
+ case sensor_type_uv:
+ qemu_mutex_lock(&uv_mutex);
+ sscanf(data, "%d", &uv_level);
+ qemu_mutex_unlock(&uv_mutex);
+ break;
+ case sensor_type_uv_enable:
+ qemu_mutex_lock(&uv_mutex);
+ sscanf(data, "%d", &uv_enable);
+ qemu_mutex_unlock(&uv_mutex);
+ break;
+ case sensor_type_uv_delay:
+ qemu_mutex_lock(&uv_mutex);
+ sscanf(data, "%d", &uv_delay);
+ qemu_mutex_unlock(&uv_mutex);
+ break;
+ case sensor_type_hrm:
+ qemu_mutex_lock(&hrm_mutex);
+ sscanf(data, "%d, %d", &hrm_heart, &hrm_rri);
+ qemu_mutex_unlock(&hrm_mutex);
+ break;
+ case sensor_type_hrm_heart:
+ qemu_mutex_lock(&hrm_mutex);
+ sscanf(data, "%d", &hrm_heart);
+ qemu_mutex_unlock(&hrm_mutex);
+ break;
+ case sensor_type_hrm_rri:
+ qemu_mutex_lock(&hrm_mutex);
+ sscanf(data, "%d", &hrm_rri);
+ qemu_mutex_unlock(&hrm_mutex);
+ break;
+ case sensor_type_hrm_enable:
+ qemu_mutex_lock(&hrm_mutex);
+ sscanf(data, "%d", &hrm_enable);
+ qemu_mutex_unlock(&hrm_mutex);
+ break;
+ case sensor_type_hrm_delay:
+ qemu_mutex_lock(&hrm_mutex);
+ sscanf(data, "%d", &hrm_delay);
+ qemu_mutex_unlock(&hrm_mutex);
+ break;
default:
return;
}
sprintf(msg_info, "%d", rot_delay);
qemu_mutex_unlock(&rot_mutex);
break;
+ case sensor_type_pressure:
+ qemu_mutex_lock(&pressure_mutex);
+ strcpy(msg_info, pressure_data);
+ qemu_mutex_unlock(&pressure_mutex);
+ break;
+ case sensor_type_pressure_enable:
+ qemu_mutex_lock(&pressure_mutex);
+ sprintf(msg_info, "%d", pressure_enable);
+ qemu_mutex_unlock(&pressure_mutex);
+ break;
+ case sensor_type_pressure_delay:
+ qemu_mutex_lock(&pressure_mutex);
+ sprintf(msg_info, "%d", pressure_delay);
+ qemu_mutex_unlock(&pressure_mutex);
+ break;
+ case sensor_type_uv:
+ qemu_mutex_lock(&uv_mutex);
+ sprintf(msg_info, "%d", uv_level);
+ qemu_mutex_unlock(&uv_mutex);
+ break;
+ case sensor_type_uv_enable:
+ qemu_mutex_lock(&uv_mutex);
+ sprintf(msg_info, "%d", uv_enable);
+ qemu_mutex_unlock(&uv_mutex);
+ break;
+ case sensor_type_uv_delay:
+ qemu_mutex_lock(&uv_mutex);
+ sprintf(msg_info, "%d", uv_delay);
+ qemu_mutex_unlock(&uv_mutex);
+ break;
+ case sensor_type_hrm:
+ qemu_mutex_lock(&hrm_mutex);
+ sprintf(msg_info, "%d, %d", hrm_heart, hrm_rri);
+ qemu_mutex_unlock(&hrm_mutex);
+ break;
+ case sensor_type_hrm_enable:
+ qemu_mutex_lock(&hrm_mutex);
+ sprintf(msg_info, "%d", hrm_enable);
+ qemu_mutex_unlock(&hrm_mutex);
+ break;
+ case sensor_type_hrm_delay:
+ qemu_mutex_lock(&hrm_mutex);
+ sprintf(msg_info, "%d", hrm_delay);
+ qemu_mutex_unlock(&hrm_mutex);
+ break;
default:
return;
}
void req_sensor_data (enum sensor_types type, enum request_cmd req, char* data, int len)
{
char msg_info [__MAX_BUF_SENSOR];
- memset(msg_info, 0, __MAX_BUF_SENSOR);
+ memset(msg_info, 0, sizeof(msg_info));
if (type >= sensor_type_max || (req != request_get && req != request_set)) {
- ERR("unavailable sensor type request.\n");
+ LOG_SEVERE("unavailable sensor type request.\n");
return;
}
{
msg_info* msginfo = (msg_info*) malloc(sizeof(msg_info));
if (!msginfo) {
- ERR("msginfo is NULL!\n");
+ LOG_SEVERE("msginfo is NULL!\n");
return;
}
msginfo->type = type;
__get_sensor_data(type, msginfo->buf);
- TRACE("sending message: %s, type: %d, req: %d\n", msginfo->buf, msginfo->type, msginfo->req);
+ LOG_TRACE("sending message: %s, type: %d, req: %d\n", msginfo->buf, msginfo->type, msginfo->req);
memset(elem->in_sg[0].iov_base, 0, elem->in_sg[0].iov_len);
memcpy(elem->in_sg[0].iov_base, msginfo, sizeof(struct msg_info));
unsigned int len = 0;
if (msg == NULL) {
- ERR("msg info structure is NULL.\n");
+ LOG_SEVERE("msg info structure is NULL.\n");
return;
}
int index = 0;
if (vsensor->vq == NULL) {
- ERR("virt queue is not ready.\n");
+ LOG_SEVERE("virt queue is not ready.\n");
return;
}
if (!virtio_queue_ready(vsensor->vq)) {
- ERR("virtqueue is not ready.");
+ LOG_SEVERE("virtqueue is not ready.");
return;
}
if (virtio_queue_empty(vsensor->vq)) {
- ERR("<< virtqueue is empty.\n");
+ LOG_SEVERE("<< virtqueue is empty.\n");
return;
}
memset(&msg, 0x00, sizeof(msg));
memcpy(&msg, elem.out_sg[0].iov_base, elem.out_sg[0].iov_len);
- TRACE("handling msg from driver: %s, len: %d, type: %d, req: %d, index: %d\n", msg.buf, strlen(msg.buf), msg.type, msg.req, index);
+ LOG_TRACE("handling msg from driver: %s, len: %d, type: %d, req: %d, index: %d\n", msg.buf, strlen(msg.buf), msg.type, msg.req, index);
handle_msg(&msg, &elem);
}
return sensor_cap_rotation_vector;
} else if (!strncmp(sensor, SENSOR_NAME_HAPTIC, 6)) {
return sensor_cap_haptic;
+ } else if (!strncmp(sensor, SENSOR_NAME_PRESSURE, 5)) {
+ return sensor_cap_pressure;
+ } else if (!strncmp(sensor, SENSOR_NAME_UV, 2)) {
+ return sensor_cap_uv;
+ } else if (!strncmp(sensor, SENSOR_NAME_HRM, 3)) {
+ return sensor_cap_hrm;
} else {
- ERR("unknown sensor request: %s", sensor);
+ LOG_SEVERE("unknown sensor request: %s", sensor);
}
return 0;
}
}
- INFO("sensor device capabilty enabled with %02x\n", sensor_capability);
+ LOG_INFO("sensor device capabilty enabled with %02x\n", sensor_capability);
}
static void virtio_sensor_realize(DeviceState *dev, Error **errp)
{
- INFO("initialize virtio-sensor device\n");
+ LOG_INFO("initialize virtio-sensor device\n");
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
vsensor = VIRTIO_SENSOR(vdev);
virtio_init(vdev, SENSOR_DEVICE_NAME, VIRTIO_ID_SENSOR, 0);
if (vsensor == NULL) {
- ERR("failed to initialize sensor device\n");
+ LOG_SEVERE("failed to initialize sensor device\n");
error_set(errp, QERR_DEVICE_INIT_FAILED, SENSOR_DEVICE_NAME);
return;
}
qemu_mutex_init(&light_mutex);
qemu_mutex_init(&proxi_mutex);
qemu_mutex_init(&rot_mutex);
+ qemu_mutex_init(&pressure_mutex);
+ qemu_mutex_init(&uv_mutex);
+ qemu_mutex_init(&hrm_mutex);
vsensor->vq = virtio_add_queue(&vsensor->vdev, 64, virtio_sensor_vq);
- INFO("initialized sensor type: %s\n", vsensor->sensors);
+ LOG_INFO("initialized sensor type: %s\n", vsensor->sensors);
if (vsensor->sensors) {
parse_sensor_capability(vsensor->sensors);
static void virtio_sensor_unrealize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
- INFO("destroy sensor device\n");
+ LOG_INFO("destroy sensor device\n");
qemu_mutex_destroy(&accel_mutex);
qemu_mutex_destroy(&gyro_mutex);
qemu_mutex_destroy(&light_mutex);
qemu_mutex_destroy(&proxi_mutex);
qemu_mutex_destroy(&rot_mutex);
+ qemu_mutex_destroy(&pressure_mutex);
+ qemu_mutex_destroy(&uv_mutex);
+ qemu_mutex_destroy(&hrm_mutex);
virtio_cleanup(vdev);
}
static void virtio_sensor_reset(VirtIODevice *vdev)
{
- TRACE("virtio_sensor_reset.\n");
+ LOG_TRACE("virtio_sensor_reset.\n");
}
static uint32_t virtio_sensor_get_features(VirtIODevice *vdev,
uint32_t request_feature)
{
- TRACE("virtio_sensor_get_features.\n");
+ LOG_TRACE("virtio_sensor_get_features.\n");
return 0;
}
sensor_type_rotation_vector_delay,
sensor_type_mag,
sensor_type_tilt,
+ sensor_type_pressure,
+ sensor_type_pressure_enable,
+ sensor_type_pressure_delay,
+ sensor_type_uv,
+ sensor_type_uv_enable,
+ sensor_type_uv_delay,
+ sensor_type_hrm,
+ sensor_type_hrm_heart,
+ sensor_type_hrm_rri,
+ sensor_type_hrm_enable,
+ sensor_type_hrm_delay,
sensor_type_max
};
enum sensor_capabilities {
- sensor_cap_accel = 0x01,
- sensor_cap_geo = 0x02,
- sensor_cap_gyro = 0x04,
- sensor_cap_light = 0x08,
- sensor_cap_proxi = 0x10,
- sensor_cap_rotation_vector = 0x20,
- sensor_cap_haptic = 0x40
+ sensor_cap_accel = 0x0001,
+ sensor_cap_geo = 0x0002,
+ sensor_cap_gyro = 0x0004,
+ sensor_cap_light = 0x0008,
+ sensor_cap_proxi = 0x0010,
+ sensor_cap_rotation_vector = 0x0020,
+ sensor_cap_haptic = 0x0040,
+ sensor_cap_pressure = 0x0080,
+ sensor_cap_uv = 0x0100,
+ sensor_cap_hrm = 0x0200
};
#define MESSAGE_TYPE_SENSOR "sensor"
#define ACTION_LIGHT 113
#define ACTION_PROXI 114
#define ACTION_ROTATION 115
+#define ACTION_PRESSURE 116
+#define ACTION_UV 117
+#define ACTION_HRM 118
#define ATTRIBUTE_NAME_SENSORS "sensors"
-#define SENSOR_NAME_ACCEL "accel"
-#define SENSOR_NAME_GYRO "gyro"
-#define SENSOR_NAME_GEO "geo"
-#define SENSOR_NAME_LIGHT "light"
-#define SENSOR_NAME_PROXI "proxi"
-#define SENSOR_NAME_ROT "rot"
-#define SENSOR_NAME_HAPTIC "haptic"
+#define SENSOR_NAME_ACCEL "accel"
+#define SENSOR_NAME_GYRO "gyro"
+#define SENSOR_NAME_GEO "geo"
+#define SENSOR_NAME_LIGHT "light"
+#define SENSOR_NAME_PROXI "proxi"
+#define SENSOR_NAME_ROT "rot"
+#define SENSOR_NAME_HAPTIC "haptic"
+#define SENSOR_NAME_PRESSURE "press"
+#define SENSOR_NAME_UV "uv"
+#define SENSOR_NAME_HRM "hrm"
#define SENSOR_CAP_TOKEN "&"
#define set_sensor_rotation_vector(data, len) \
req_sensor_data(sensor_type_rotation_vector, request_set, data, len);
+// Pressure
+#define get_sensor_pressure() \
+ req_sensor_data(sensor_type_pressure, request_get, NULL, 0);
+
+#define set_sensor_pressure(data, len) \
+ req_sensor_data(sensor_type_pressure, request_set, data, len);
+
+// UV
+#define get_sensor_uv() \
+ req_sensor_data(sensor_type_uv, request_get, NULL, 0);
+
+#define set_sensor_uv(data, len) \
+ req_sensor_data(sensor_type_uv, request_set, data, len);
+
+// HRM
+#define get_sensor_hrm() \
+ req_sensor_data(sensor_type_hrm, request_get, NULL, 0);
+
+#define set_sensor_hrm(data, len) \
+ req_sensor_data(sensor_type_hrm, request_set, data, len);
+
+#define set_sensor_hrm_heart(data, len) \
+ req_sensor_data(sensor_type_hrm_heart, request_set, data, len);
+
+#define set_sensor_hrm_rri(data, len) \
+ req_sensor_data(sensor_type_hrm_rri, request_set, data, len);
+
+
#ifdef __cplusplus
}
#endif