mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2026-07-04 09:55:38 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
459
Living_SDK/framework/uData/abs_data_model/abs_data_model.c
Normal file
459
Living_SDK/framework/uData/abs_data_model/abs_data_model.c
Normal file
|
|
@ -0,0 +1,459 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*
|
||||
*
|
||||
* abstract(abs) data model
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "abs_data_model.h"
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <fcntl.h>
|
||||
#include <aos/yloop.h>
|
||||
|
||||
typedef sensor_list_t abs_data_list_t;
|
||||
#define DEFAULT_TIMER_INTERVAL 1000 /* 1000ms */
|
||||
static bool is_timer_work = false;
|
||||
static int cur_interval = 0;
|
||||
static uint32_t abs_data_cnt = 0;
|
||||
static abs_data_pkg_t* g_abs_data_db[ABS_DATA_MAX_CNT];
|
||||
static aos_timer_t g_abs_data_timer;
|
||||
static abs_data_list_t g_abs_data_table;
|
||||
|
||||
/* NOTE: please follow the sensor order of the "sensor_tag_e"
|
||||
which is defined the the sensor.h file */
|
||||
sensor_node_t g_sensor_node[] = {
|
||||
{ TAG_DEV_ACC, dev_acc_path, 0},
|
||||
{ TAG_DEV_MAG, dev_mag_path, 0},
|
||||
{ TAG_DEV_GYRO, dev_gyro_path, 0},
|
||||
{ TAG_DEV_ALS, dev_als_path, 0},
|
||||
{ TAG_DEV_PS, dev_ps_path, 0},
|
||||
{ TAG_DEV_BARO, dev_baro_path, 0},
|
||||
{ TAG_DEV_TEMP, dev_temp_path, 0},
|
||||
{ TAG_DEV_UV, dev_uv_path, 0},
|
||||
{ TAG_DEV_HUMI, dev_humi_path, 0},
|
||||
{ TAG_DEV_HALL, dev_hall_path, 0},
|
||||
{ TAG_DEV_HR, dev_hr_path, 0},
|
||||
{ TAG_DEV_GPS, dev_gps_path, 0},
|
||||
};
|
||||
|
||||
static bool abs_data_get_timer_status(void)
|
||||
{
|
||||
return is_timer_work;
|
||||
}
|
||||
|
||||
static void abs_data_set_timer_status(bool status)
|
||||
{
|
||||
is_timer_work = status;
|
||||
}
|
||||
|
||||
static int abs_data_create_obj_ctx(int arg, void* pdata)
|
||||
{
|
||||
g_abs_data_db[abs_data_cnt] = (abs_data_pkg_t*)aos_malloc(sizeof(abs_data_pkg_t));
|
||||
if((pdata == NULL)||(g_abs_data_db[abs_data_cnt] == NULL)){
|
||||
return -1;
|
||||
}
|
||||
memset(g_abs_data_db[abs_data_cnt], 0, (sizeof(abs_data_pkg_t)));
|
||||
|
||||
uData_service_t* service = pdata;
|
||||
g_abs_data_db[abs_data_cnt]->tag = service->tag;
|
||||
g_abs_data_db[abs_data_cnt]->interval = arg;
|
||||
g_abs_data_db[abs_data_cnt]->poweron = true;
|
||||
g_abs_data_db[abs_data_cnt]->cur_timestamp = aos_now_ms();
|
||||
g_abs_data_db[abs_data_cnt]->full_info.config.odr = service->config.odr;
|
||||
g_abs_data_db[abs_data_cnt]->full_info.config.range = service->config.range;
|
||||
g_abs_data_db[abs_data_cnt]->calibrated_algo_process_cb = NULL;
|
||||
g_abs_data_db[abs_data_cnt]->srv_cnt++;
|
||||
abs_data_cnt++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int abs_data_get_obj_index(sensor_tag_e tag){
|
||||
int i = 0;
|
||||
for(i = 0; i< abs_data_cnt; i++){
|
||||
if(g_abs_data_db[i]->tag == tag){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void abs_data_post_timer_expried_dev(uint64_t timestamp)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
for(i = 0; i < abs_data_cnt; i++){
|
||||
if((timestamp - g_abs_data_db[i]->cur_timestamp) >= (g_abs_data_db[i]->interval)){
|
||||
aos_post_event(EV_UDATA, CODE_UDATA_DEV_READ, (g_abs_data_db[i]->tag));
|
||||
/* update the timestamp of triggered sensor here for the next timer hadler */
|
||||
g_abs_data_db[i]->cur_timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int abs_data_dev_enable(sensor_tag_e tag)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
||||
if(abs_data_get_timer_status()){
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = aos_timer_start(&g_abs_data_timer);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int abs_data_dev_disable(sensor_tag_e tag)
|
||||
{
|
||||
int ret = 0;
|
||||
if(!abs_data_get_timer_status()){
|
||||
return 0;
|
||||
}
|
||||
ret = aos_timer_stop(&g_abs_data_timer);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int abs_data_biuld_dev_tree(void* buf)
|
||||
{
|
||||
abs_data_list_t* table = buf;
|
||||
if(table == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_abs_data_table.cnt = table->cnt;
|
||||
for(int i = 0; i < g_abs_data_table.cnt; i++){
|
||||
g_abs_data_table.list[i] = table->list[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int abs_data_collect_dev_list(void* buf)
|
||||
{
|
||||
int fd = 0;
|
||||
int ret = 0;
|
||||
if(buf == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef AOS_SENSOR
|
||||
fd = aos_open(sensor_node_path, O_RDWR);
|
||||
if(fd < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = aos_ioctl(fd, SENSOR_IOCTL_GET_SENSOR_LIST, buf);
|
||||
if(ret < 0){
|
||||
return -1;
|
||||
}
|
||||
ret = aos_close(fd);
|
||||
if(ret < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef AOS_GPS
|
||||
fd = aos_open(gps_node_path, O_RDWR);
|
||||
if(fd < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = aos_ioctl(fd, SENSOR_IOCTL_GET_SENSOR_LIST, buf);
|
||||
if(ret < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = aos_close(fd);
|
||||
if(ret < 0){
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool abs_data_check_dev_tree(sensor_tag_e tag)
|
||||
{
|
||||
for(int i = 0; i < g_abs_data_table.cnt; i++){
|
||||
if(g_abs_data_table.list[i] == tag){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int abs_data_timer_update(sensor_tag_e tag, int interval)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if(interval <= 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* no need change the interval in this case here */
|
||||
if(interval > cur_interval){
|
||||
return 0;
|
||||
}
|
||||
/* fill the timer info inot the interval lists of timer from sensor service side,
|
||||
set the timer of abs sensor model by the min interval */
|
||||
|
||||
ret = aos_timer_stop(&g_abs_data_timer);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
ret = aos_timer_change(&g_abs_data_timer, interval);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = aos_timer_start(&g_abs_data_timer);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
abs_data_set_timer_status(true);
|
||||
cur_interval = interval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int abs_data_open(uData_service_t *service)
|
||||
{
|
||||
int ret = 0;
|
||||
int interval = 0;
|
||||
int fd = 0;
|
||||
int index = 0;
|
||||
|
||||
if(service == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check the target in the dev tree */
|
||||
if(!(abs_data_check_dev_tree(service->tag))){
|
||||
return -1;
|
||||
}
|
||||
|
||||
interval = HZ_2_INTERVAL(service->config.odr);
|
||||
ret = abs_data_timer_update(service->tag, interval);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* chekc the device if it already exists here */
|
||||
index = abs_data_get_obj_index(service->tag);
|
||||
if(index >= 0){
|
||||
/* no operation if the device is already open and power on */
|
||||
if((g_abs_data_db[index]->poweron == 1)){
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
/* just power on the device if the device is already open but power off */
|
||||
ret = aos_ioctl(g_sensor_node[service->tag].fd, SENSOR_IOCTL_SET_POWER, true);
|
||||
if(ret <= 0){
|
||||
return -1;
|
||||
}
|
||||
g_abs_data_db[index]->poweron = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
fd = aos_open((g_sensor_node[service->tag].path), O_RDWR);
|
||||
if(fd <= 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_sensor_node[service->tag].fd = fd;
|
||||
|
||||
/* set the configuration para from the service algo */
|
||||
if((service->config.id & SENSOR_IOCTL_ODR_SET) != 0){
|
||||
ret = aos_ioctl(fd,service->config.id, service->config.odr);
|
||||
if(ret < 0){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if((service->config.id & SENSOR_IOCTL_RANGE_SET) != 0){
|
||||
ret = aos_ioctl(fd,service->config.id, service->config.range);
|
||||
if(ret < 0){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ret = abs_data_create_obj_ctx(interval, service);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
LOG("%s %s successfully\n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int abs_data_close(sensor_tag_e tag)
|
||||
{
|
||||
int ret = 0;
|
||||
uint32_t index = 0;
|
||||
if(g_sensor_node[tag].fd <= 0){
|
||||
return -1;
|
||||
}
|
||||
ret = aos_ioctl(g_sensor_node[tag].fd, SENSOR_IOCTL_SET_POWER, false);
|
||||
if(ret < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
ret = aos_close(g_sensor_node[tag].fd);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
index = abs_data_get_obj_index(tag);
|
||||
g_abs_data_db[index]->poweron = false;
|
||||
for(index = 0; index < abs_data_cnt; index++){
|
||||
if(g_abs_data_db[index]->poweron == true){
|
||||
break;
|
||||
}
|
||||
if(abs_data_get_timer_status() != false){
|
||||
aos_timer_stop(&g_abs_data_timer);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int abs_data_read(sensor_tag_e tag, void* pdata, uint32_t nbyte)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t size = 0;
|
||||
int index = 0;
|
||||
/* read the physical sensor data by posix way */
|
||||
size = aos_read(g_sensor_node[tag].fd, pdata, nbyte);
|
||||
if(size <= 0){
|
||||
LOG("%s %s %s %d\n", uDATA_STR, __func__, ERROR_LINE, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check if calibrated aglo registed base on this sensor.
|
||||
yes for invoking the callback here */
|
||||
index = abs_data_get_obj_index(tag);
|
||||
if((g_abs_data_db[index] != NULL)&&(g_abs_data_db[index]->calibrated_algo_process_cb != NULL)){
|
||||
g_abs_data_db[index]->calibrated_algo_process_cb(pdata);
|
||||
}
|
||||
|
||||
ret = aos_post_event(EV_UDATA, CODE_UDATA_SERVICE_PROCESS, tag);
|
||||
if(ret < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG("%s %s successfully \n", uDATA_STR, __func__);
|
||||
return (int)size;
|
||||
}
|
||||
|
||||
int abs_data_ioctl(sensor_tag_e tag, void* config)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned long arg = 0;
|
||||
dev_sensor_full_info_t* sensor_config = config;
|
||||
|
||||
if(sensor_config->config.id == SENSOR_IOCTL_ODR_SET){
|
||||
arg = sensor_config->config.odr;
|
||||
}
|
||||
else if(sensor_config->config.id == SENSOR_IOCTL_RANGE_SET){
|
||||
arg = sensor_config->config.range;
|
||||
}
|
||||
else if(sensor_config->config.id == SENSOR_IOCTL_GET_INFO){
|
||||
/* fill the dev info addr, then get back after filling by the phy sensor */
|
||||
arg = &sensor_config->info;
|
||||
}
|
||||
else if(sensor_config->config.id == SENSOR_IOCTL_GET_SENSOR_LIST){
|
||||
/* should open the sensor hale node to get all the senor list */
|
||||
//ret = abs_data_get_dev_list(&(sensor_config->info.list));
|
||||
//if(unlikely(ret)){
|
||||
//LOG("%s %s %s %d\n", uDATA_STR, __func__, ERROR_LINE, __LINE__);
|
||||
// return -1;
|
||||
//}
|
||||
//return 0;
|
||||
}
|
||||
|
||||
ret = aos_ioctl(g_sensor_node[tag].fd, sensor_config->config.id, arg);
|
||||
if(ret <= 0){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int abs_cali_data_register(sensor_tag_e tag, void* cb)
|
||||
{
|
||||
int ret = 0;
|
||||
int index = 0;
|
||||
|
||||
if(cb == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* also can copy the data struct here */
|
||||
index = abs_data_get_obj_index(tag);
|
||||
if(g_abs_data_db[index] == NULL){
|
||||
return -1;
|
||||
}
|
||||
g_abs_data_db[index]->calibrated_algo_process_cb = cb;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int abs_cali_data_unregister(udata_type_e type)
|
||||
{
|
||||
// TODO;
|
||||
}
|
||||
|
||||
static void abs_data_timer_process(void* arg)
|
||||
{
|
||||
abs_data_post_timer_expried_dev(aos_now_ms());
|
||||
}
|
||||
|
||||
int abs_data_cali_init(void){
|
||||
int ret = 0;
|
||||
ret = cali_example_example_init();
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG("%s %s successfully \n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int abs_data_model_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = aos_timer_new_ext(&g_abs_data_timer, abs_data_timer_process, NULL, DEFAULT_TIMER_INTERVAL, 0, 0);
|
||||
|
||||
/* must stop the timer here, since the timer is triggered after be created */
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
abs_data_set_timer_status(false);
|
||||
cur_interval = DEFAULT_TIMER_INTERVAL;
|
||||
|
||||
memset(&g_abs_data_table, 0, sizeof(g_abs_data_table));
|
||||
ret = abs_data_collect_dev_list(&g_abs_data_table);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
ret = abs_data_biuld_dev_tree(&g_abs_data_table);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
LOG("%s %s successfully \n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "abs_data_model.h"
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <fcntl.h>
|
||||
#include <aos/yloop.h>
|
||||
|
||||
int cali_example_process_cb(void* pdata)
|
||||
{
|
||||
/* just a simple example here
|
||||
show how to register inot the abs model */
|
||||
|
||||
LOG("%s %s successfully \n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int cali_example_example_init(void){
|
||||
int ret = 0;
|
||||
ret = abs_cali_data_register(TAG_DEV_ACC, cali_example_process_cb);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG("%s %s successfully \n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
25
Living_SDK/framework/uData/include/abs_data_model.h
Normal file
25
Living_SDK/framework/uData/include/abs_data_model.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
/**
|
||||
* @abstract data model
|
||||
* @brief abstract data api
|
||||
* @version since 0.0.1
|
||||
*/
|
||||
|
||||
#ifndef ABS_SENSOR_MODEL_H
|
||||
#define ABS_SENSOR_MODEL_H
|
||||
|
||||
#include "uData_com_desc.h"
|
||||
|
||||
int abs_data_model_init(void);
|
||||
int abs_data_open(uData_service_t *service);
|
||||
int abs_data_close(sensor_tag_e tag);
|
||||
int abs_data_read(sensor_tag_e tag, void* pdata, uint32_t nbyte);
|
||||
int abs_data_ioctl(sensor_tag_e tag, void* config);
|
||||
int abs_cali_data_register(sensor_tag_e tag, void* cb);
|
||||
int abs_cali_data_unregister(udata_type_e type);
|
||||
|
||||
#endif /*ABS_SENSOR_MODEL_H*/
|
||||
|
||||
12
Living_SDK/framework/uData/include/service_algo.h
Normal file
12
Living_SDK/framework/uData/include/service_algo.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef SERVICE_ALGO_H
|
||||
#define SERVICE_ALGO_H
|
||||
|
||||
extern int service_example_init(void);
|
||||
|
||||
|
||||
#endif /* SERVICE_ALGO_H */
|
||||
|
||||
22
Living_SDK/framework/uData/include/service_mgr.h
Normal file
22
Living_SDK/framework/uData/include/service_mgr.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
/**
|
||||
* @uData service manager
|
||||
* @brief serive manager API
|
||||
* @version since 0.0.1
|
||||
*/
|
||||
|
||||
#ifndef SERVICE_MANAGER_H
|
||||
#define SERVICE_MANAGER_H
|
||||
|
||||
#include "uData_com_desc.h"
|
||||
|
||||
|
||||
int uData_service_mgr_init(void);
|
||||
int uData_service_register(uData_service_t *service);
|
||||
int uData_service_unregister(udata_type_e type);
|
||||
|
||||
#endif /*SERVICE_MANAGER_H*/
|
||||
|
||||
123
Living_SDK/framework/uData/include/uData_com_desc.h
Normal file
123
Living_SDK/framework/uData/include/uData_com_desc.h
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
/**
|
||||
* @uData
|
||||
* @brief uData object desc
|
||||
* @version since 0.0.1
|
||||
*/
|
||||
|
||||
#ifndef UDATA_OBJ_DESC_H
|
||||
#define UDATA_OBJ_DESC_H
|
||||
|
||||
#include <aos/kernel.h>
|
||||
#include "hal/sensor.h"
|
||||
#include "aos/log.h"
|
||||
|
||||
|
||||
#define DO_FOREVER
|
||||
|
||||
#define uDATA_STR "uData: " /* uData debug header */
|
||||
|
||||
#define TIMESTAMP_2_MS(t) ((t) / 1000)
|
||||
#define MS_2_TIMESTAMP(ms) ((ms) * 1000)
|
||||
|
||||
#define INTERVAL_2_MS(i) TIMESTAMP_2_MS(i)
|
||||
#define MS_TO_INTERVAL(ms) MS_2_TIMESTAMP(ms)
|
||||
|
||||
#define HZ_2_INTERVAL(hz) ((hz) ? ((1000) / (hz)) : 0)
|
||||
#define INTERVAL_2_HZ(i) ((i) == 0 ? 0 : ((i) > MS_2_TIMESTAMP(1000) ? 1 : (MS_2_TIMESTAMP(1000) / (i))))
|
||||
|
||||
#define HZ_2_TIMESTAMP(hz) HZ_2_INTERVAL(hz)
|
||||
#define TIMESTAMP_2_HZ(t) INTERVAL_2_HZ(t)
|
||||
|
||||
typedef bool b_subscribed;
|
||||
typedef bool b_enbled;
|
||||
typedef int (*fn_cb)(void* pData); /* callback for calibrated algo */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UDATA_SERVICE_ACC = 0, /* Accelerometer */
|
||||
UDATA_SERVICE_MAG, /* Magnetometer */
|
||||
UDATA_SERVICE_GYRO, /* Gyroscope */
|
||||
UDATA_SERVICE_ALS, /* Ambient light sensor */
|
||||
UDATA_SERVICE_PS, /* Proximity */
|
||||
UDATA_SERVICE_BARO, /* Barometer */
|
||||
UDATA_SERVICE_TEMP, /* Temperature */
|
||||
UDATA_SERVICE_UV, /* Ultraviolet */
|
||||
UDATA_SERVICE_HUMI, /* Humidity */
|
||||
UDATA_SERVICE_HALL, /* HALL sensor */
|
||||
UDATA_SERVICE_HR, /* Heart Rate sensor */
|
||||
UDATA_SERVICE_PEDOMETER,
|
||||
UDATA_SERVICE_PDR,
|
||||
UDATA_SERVICE_VDR,
|
||||
UDATA_SERVICE_GPS,
|
||||
|
||||
UDATA_MAX_CNT,
|
||||
}udata_type_e;
|
||||
|
||||
/* the max size of the dat buf */
|
||||
#define DATA_SIZE 64
|
||||
#define ABS_DATA_MAX_CNT TAG_DEV_SENSOR_NUM_MAX
|
||||
|
||||
struct _abs_cali_cb_t {
|
||||
sensor_tag_e tag;
|
||||
int (*calibrated_algo_process_cb)(sensor_tag_e tag, void* pData); /* callback for calibrated algo */
|
||||
};
|
||||
typedef struct _abs_cali_cb_t abs_cali_cb_t;
|
||||
|
||||
struct _abs_data_pkg_t {
|
||||
sensor_tag_e tag;
|
||||
uint8_t srv_cnt; /* count of the registed service base on this sensor */
|
||||
bool poweron; /* the power status of the registed service base on this sensor */
|
||||
uint32_t interval;/* the report data interval of the sensor*/
|
||||
uint64_t cur_timestamp; /* the current timestamp for every sensor, the unit is ms */
|
||||
int (*calibrated_algo_process_cb)(void* pData); /* callback for calibrated algo */
|
||||
dev_sensor_full_info_t full_info;
|
||||
};
|
||||
typedef struct _abs_data_pkg_t abs_data_pkg_t;
|
||||
|
||||
/* sensor service manager layer*/
|
||||
struct _uData_service_t {
|
||||
udata_type_e type;
|
||||
sensor_tag_e tag;
|
||||
b_subscribed subscribe; /* subscribe only from aliyun side */
|
||||
b_enbled running;
|
||||
dev_sensor_config_t config;
|
||||
uint8_t payload[DATA_SIZE];
|
||||
size_t(*service_process_cb)(sensor_tag_e tag, void* pdata); /* process callback for udata service handle */
|
||||
int(*service_ioctl_cb)(udata_type_e type, sensor_tag_e tag); /* ioclt callback for udata service handle */
|
||||
};
|
||||
typedef struct _uData_service_t uData_service_t;
|
||||
|
||||
struct _sensor_msg_pkg_t {
|
||||
sensor_tag_e tag;
|
||||
uint8_t cmd;
|
||||
dev_sensor_config_t config;
|
||||
};
|
||||
typedef struct _sensor_msg_pkg_t sensor_msg_pkg_t;
|
||||
|
||||
/* define the udata serivce struct here, please aline with aliyun side
|
||||
for the physical sensor, should be same as the dev sensor struct */
|
||||
typedef struct _dev_barometer_data_t service_barometer_t;
|
||||
|
||||
typedef struct _service_pedometer_t{
|
||||
udata_type_e type;
|
||||
uint32_t step;
|
||||
} service_pedometer_t;
|
||||
|
||||
typedef struct _udata_t{
|
||||
udata_type_e type;
|
||||
uint16_t value;
|
||||
} udata_t;
|
||||
|
||||
typedef struct _udata_pkg_t{
|
||||
bool valid;
|
||||
udata_type_e type;
|
||||
__attribute__((aligned(4))) char payload[DATA_SIZE];
|
||||
}udata_pkg_t;
|
||||
|
||||
#endif /*UDATA_OBJ_DESC_H*/
|
||||
|
||||
55
Living_SDK/framework/uData/service_algo/udata_baro_service.c
Normal file
55
Living_SDK/framework/uData/service_algo/udata_baro_service.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*
|
||||
*
|
||||
* uData service example
|
||||
*/
|
||||
|
||||
#include "service_mgr.h"
|
||||
|
||||
int udata_baro_service_ioctl_cb(udata_type_e type, sensor_tag_e tag)
|
||||
{
|
||||
|
||||
tag = TAG_DEV_BARO;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t udata_baro_service_process_cb(sensor_tag_e tag, void* pdata)
|
||||
{
|
||||
barometer_data_t * baro = (barometer_data_t *)pdata;
|
||||
size_t len = sizeof(barometer_data_t);
|
||||
|
||||
LOG("%s udata_baro_service_cb = (%d), (%d), (%d)\n",uDATA_STR, tag, baro->p, baro->timestamp);
|
||||
return len;
|
||||
}
|
||||
|
||||
int udata_baro_service_result(void* pdata){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int udata_baro_service_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
uData_service_t * baro;
|
||||
baro = (uData_service_t *)malloc(sizeof(uData_service_t));
|
||||
if(baro == NULL){
|
||||
return -1;
|
||||
}
|
||||
baro->type = UDATA_SERVICE_BARO;
|
||||
baro->tag = TAG_DEV_BARO;
|
||||
baro->config.id = SENSOR_IOCTL_ODR_SET;
|
||||
baro->config.odr = 2; /* 2Hz */
|
||||
baro->config.range = 0; /* no need here, set by the default value in the driver layer */
|
||||
baro->service_process_cb = udata_baro_service_process_cb;
|
||||
baro->service_ioctl_cb = udata_baro_service_ioctl_cb;
|
||||
ret = uData_service_register(baro);
|
||||
if(unlikely(ret)){
|
||||
free(baro);
|
||||
LOG("%s %s %s %d\n", uDATA_STR, __func__, ERROR_LINE, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
free(baro);
|
||||
LOG("%s %s successfully\n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
66
Living_SDK/framework/uData/service_algo/udata_gps_service.c
Normal file
66
Living_SDK/framework/uData/service_algo/udata_gps_service.c
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*
|
||||
*
|
||||
* uData service example
|
||||
*/
|
||||
|
||||
#include "service_mgr.h"
|
||||
|
||||
/*read 4 times beforce report once */
|
||||
#define SERVICE_GPS_REORT_FREQ_REDUCE 4
|
||||
static int g_gpsreportfreq = 0;
|
||||
|
||||
int udata_gps_service_ioctl_cb(udata_type_e type, sensor_tag_e tag)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t udata_gps_service_process_cb(sensor_tag_e tag, void* pdata)
|
||||
{
|
||||
gps_data_t * gps = (gps_data_t *)pdata;
|
||||
size_t len = sizeof(gps_data_t);
|
||||
|
||||
LOG("%s udata_gps_service_process_cb = (%d), (%f), (%f)\n",uDATA_STR, tag, gps->lon, gps->lat);
|
||||
|
||||
if(0 == ((g_gpsreportfreq++)%SERVICE_GPS_REORT_FREQ_REDUCE))
|
||||
{
|
||||
return len;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int udata_gps_service_result(void* pdata)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int udata_gps_service_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
uData_service_t * gps;
|
||||
gps = (uData_service_t *)malloc(sizeof(uData_service_t));
|
||||
if(gps == NULL){
|
||||
return -1;
|
||||
}
|
||||
gps->type = UDATA_SERVICE_GPS;
|
||||
gps->tag = TAG_DEV_GPS;
|
||||
gps->config.id = SENSOR_IOCTL_ODR_SET;
|
||||
gps->config.odr = 1; /* 1Hz */
|
||||
gps->config.range = 0; /* no need here, set by the default value in the driver layer */
|
||||
gps->service_process_cb = udata_gps_service_process_cb;
|
||||
gps->service_ioctl_cb = udata_gps_service_ioctl_cb;
|
||||
ret = uData_service_register(gps);
|
||||
if(unlikely(ret)){
|
||||
free(gps);
|
||||
LOG("%s %s %s %d\n", uDATA_STR, __func__, ERROR_LINE, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
free(gps);
|
||||
LOG("%s %s successfully\n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
346
Living_SDK/framework/uData/service_mgr/service_mgr.c
Normal file
346
Living_SDK/framework/uData/service_mgr/service_mgr.c
Normal file
|
|
@ -0,0 +1,346 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*
|
||||
*
|
||||
* uData service manager part
|
||||
*/
|
||||
|
||||
#include "service_mgr.h"
|
||||
#include <stdio.h>
|
||||
#include <aos/aos.h>
|
||||
#include <aos/yloop.h>
|
||||
#include "service_algo.h"
|
||||
|
||||
static uData_service_t* g_service_db[UDATA_MAX_CNT];
|
||||
static uint32_t g_service_cnt = 0;
|
||||
static udata_pkg_t g_pkg_buf[UDATA_MAX_CNT];
|
||||
|
||||
static uData_service_t* uData_get_service_obj(sensor_tag_e tag)
|
||||
{
|
||||
int index = 0;
|
||||
for(index = 0; index < g_service_cnt; index++){
|
||||
if(g_service_db[index]->tag == tag){
|
||||
return g_service_db[index];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int uData_find_service(udata_type_e type)
|
||||
{
|
||||
int index = 0;
|
||||
for(index = 0; index < g_service_cnt; index++){
|
||||
if(g_service_db[index]->type == type){
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int uData_dev_enable(sensor_tag_e tag)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = abs_data_dev_enable(tag);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int uData_get_report_pkg(void* buf,int index)
|
||||
{
|
||||
if(buf == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(index >= UDATA_MAX_CNT){
|
||||
return -1;
|
||||
}
|
||||
memcpy(buf, &g_pkg_buf[index], sizeof(udata_pkg_t));
|
||||
return 0;
|
||||
}
|
||||
static int uData_install_report_pkg(int index, void* pdata, size_t len)
|
||||
{
|
||||
if(pdata == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(index >= UDATA_MAX_CNT){
|
||||
return -1;
|
||||
}
|
||||
/* intall the report data package here */
|
||||
memset(&g_pkg_buf[index], 0, sizeof(udata_pkg_t));
|
||||
g_pkg_buf[index].valid = true;
|
||||
g_pkg_buf[index].type = g_service_db[index]->type;
|
||||
if(sizeof(g_pkg_buf[index].payload) < len){
|
||||
return -1;
|
||||
}
|
||||
memcpy(g_pkg_buf[index].payload, pdata, len);
|
||||
|
||||
aos_post_event(EV_UDATA, CODE_UDATA_REPORT_PUBLISH, index);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uData_get_dev_list(void* pdata)
|
||||
{
|
||||
dev_sensor_full_info_t* sensor;
|
||||
sensor = aos_malloc(sizeof(dev_sensor_full_info_t));
|
||||
if(sensor == NULL){
|
||||
return -1;
|
||||
}
|
||||
sensor->config.id = SENSOR_IOCTL_GET_SENSOR_LIST;
|
||||
int ret = abs_data_ioctl(NULL, sensor);
|
||||
if(unlikely(ret)){
|
||||
aos_free(sensor);
|
||||
return -1;
|
||||
}
|
||||
aos_free(sensor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uData_service_subscribe(udata_type_e type)
|
||||
{
|
||||
int ret = 0;
|
||||
int index = 0;
|
||||
|
||||
index = uData_find_service(type);
|
||||
if(index < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(g_service_db[index]->type == type){
|
||||
if(g_service_db[index]->running != true){
|
||||
ret = abs_data_open(g_service_db[index]);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
g_service_db[index]->subscribe = true;
|
||||
g_service_db[index]->running = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uData_service_unsubscribe(udata_type_e type)
|
||||
{
|
||||
int ret = 0;
|
||||
int index = 0;
|
||||
|
||||
index = uData_find_service(type);
|
||||
if(index < 0)
|
||||
return -1;
|
||||
|
||||
if(g_service_db[index]->type == type){
|
||||
if(g_service_db[index]->running != false){
|
||||
ret = abs_data_close(g_service_db[index]->tag);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
g_service_db[index]->subscribe = false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uData_service_register(uData_service_t* service)
|
||||
{
|
||||
|
||||
int ret = 0;
|
||||
if(service == NULL){
|
||||
return -1;
|
||||
}
|
||||
g_service_db[g_service_cnt] = (uData_service_t*)aos_malloc(sizeof(uData_service_t));
|
||||
if(g_service_db[g_service_cnt] == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(g_service_db[g_service_cnt], 0, sizeof(uData_service_t));
|
||||
|
||||
/* also can copy the data struct by memcpy here */
|
||||
g_service_db[g_service_cnt]->type = service->type;
|
||||
g_service_db[g_service_cnt]->tag = service->tag;
|
||||
g_service_db[g_service_cnt]->config.odr = service->config.odr;
|
||||
g_service_db[g_service_cnt]->config.range = service->config.range;
|
||||
g_service_db[g_service_cnt]->service_process_cb = service->service_process_cb;
|
||||
g_service_db[g_service_cnt]->service_ioctl_cb = service->service_ioctl_cb;
|
||||
|
||||
ret = abs_data_open(g_service_db[g_service_cnt]);
|
||||
if(unlikely(ret)){
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* set the defaul status and no subsrcribed from aliyun side */
|
||||
g_service_db[g_service_cnt]->running = true;
|
||||
g_service_db[g_service_cnt]->subscribe = false;
|
||||
g_service_cnt++;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
aos_free(g_service_db[g_service_cnt]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int uData_service_unregister(udata_type_e type)
|
||||
{
|
||||
|
||||
int index = 0;
|
||||
int ret = 0;
|
||||
/* find the matched service, then del it from the list here */
|
||||
for(index = 0; index < g_service_cnt; index++){
|
||||
if(g_service_db[index]->type == type){
|
||||
ret = abs_data_close(g_service_db[index]->tag);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
memset(g_service_db[index], 0, sizeof(uData_service_t));
|
||||
if(g_service_cnt > 0){
|
||||
g_service_cnt--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int uData_service_process(sensor_tag_e tag, void* pdata)
|
||||
{
|
||||
|
||||
int ret = 0;
|
||||
int index = 0;
|
||||
size_t len = 0;
|
||||
if(pdata == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* find the matched service, then run the registered callback here */
|
||||
for(index = 0; index < g_service_cnt; index++){
|
||||
if((g_service_db[index]->tag == tag) && (g_service_db[index]->service_process_cb != NULL)){
|
||||
len = g_service_db[index]->service_process_cb(tag, pdata);
|
||||
if((len != 0) && (g_service_db[index]->subscribe == true)){
|
||||
ret = uData_install_report_pkg(index, pdata, len);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uData_service_ioctl(udata_type_e type, void* parm)
|
||||
{
|
||||
int index = 0;
|
||||
int ret = 0;
|
||||
sensor_tag_e tag;
|
||||
dev_sensor_full_info_t * sensor_config = parm;
|
||||
if(parm == NULL)
|
||||
return -1;
|
||||
|
||||
/* find the matched service, then run the registered ioctl callback here */
|
||||
for(index = 0; index < g_service_cnt; index++){
|
||||
if((g_service_db[index]->type == type) && (g_service_db[index]->service_ioctl_cb != NULL)){
|
||||
g_service_db[index]->service_ioctl_cb(type, tag);
|
||||
/* if get the dev info, then run here */
|
||||
ret = abs_data_ioctl(tag, sensor_config);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG("%s %s successfully \n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void uData_service_dispatcher(input_event_t *event, void *priv_data)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* all the cmd of sensorhub will be sent to be handled here;
|
||||
the dispatcher will asign the new sub task to the fitted model */
|
||||
if ((event == NULL)||(event->type != EV_UDATA)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uData_service_t* service = uData_get_service_obj(event->value);
|
||||
if(service == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(event->code){
|
||||
case CODE_UDATA_DEV_READ:{
|
||||
memset(service->payload, 0, DATA_SIZE);
|
||||
ret = abs_data_read(event->value, service->payload, DATA_SIZE);
|
||||
if(ret <= 0){
|
||||
LOG("%s %s fail line:%d \n", uDATA_STR, __func__,__LINE__);
|
||||
return;
|
||||
}
|
||||
}break;
|
||||
|
||||
case CODE_UDATA_SERVICE_PROCESS:{
|
||||
uData_service_process(event->value, service->payload);
|
||||
}break;
|
||||
|
||||
case CODE_UDATA_DEV_IOCTL:{
|
||||
abs_data_ioctl(event->value, service->payload);
|
||||
}break;
|
||||
|
||||
case CODE_UDATA_DEV_OPEN:{
|
||||
abs_data_open(priv_data);
|
||||
}break;
|
||||
|
||||
case CODE_UDATA_DEV_ENABLE:{
|
||||
uData_dev_enable(event->value);
|
||||
}break;
|
||||
|
||||
case CODE_UDATA_DEV_DISABLE:{
|
||||
}break;
|
||||
|
||||
case CODE_UDATA_SERVICE_SUBSRIBE:{
|
||||
uData_service_subscribe(event->value);
|
||||
}break;
|
||||
|
||||
case CODE_UDATA_SERVICE_UNSUBSRIBE:{
|
||||
uData_service_unsubscribe(event->value);
|
||||
}break;
|
||||
|
||||
case CODE_UDATA_DEV_CLOSE:{
|
||||
abs_data_close(event->value);
|
||||
}break;
|
||||
|
||||
default:break;
|
||||
}
|
||||
}
|
||||
|
||||
int uData_service_init(void)
|
||||
{
|
||||
#ifdef AOS_UDATA_SERVICE_BARO
|
||||
udata_baro_service_init();
|
||||
#endif /* UDATA_SERVICE_BARO */
|
||||
|
||||
#ifdef AOS_UDATA_SERVICE_GPS
|
||||
udata_gps_service_init();
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uData_service_mgr_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
g_service_cnt = 0;
|
||||
|
||||
ret = aos_register_event_filter(EV_UDATA, uData_service_dispatcher, NULL);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG("%s %s successfully \n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
32
Living_SDK/framework/uData/uData.mk
Normal file
32
Living_SDK/framework/uData/uData.mk
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
NAME := uData
|
||||
|
||||
$(NAME)_SOURCES += \
|
||||
uData_main.c \
|
||||
uData_interface.c \
|
||||
service_mgr/service_mgr.c \
|
||||
cali_data/calibrated_example_algo.c \
|
||||
abs_data_model/abs_data_model.c \
|
||||
service_algo/udata_baro_service.c \
|
||||
service_algo/udata_gps_service.c
|
||||
|
||||
|
||||
$(NAME)_INCLUDES := \
|
||||
./include \
|
||||
../../include/aos \
|
||||
../../include/hal \
|
||||
|
||||
GLOBAL_INCLUDES += .
|
||||
|
||||
$(NAME)_TYPE := framework
|
||||
|
||||
GLOBAL_DEFINES += AOS_UDATA
|
||||
|
||||
GLOBAL_DEFINES += AOS_UDATA_SERVICE_BARO
|
||||
#GLOBAL_DEFINES += AOS_UDATA_SERVICE_ALS
|
||||
#GLOBAL_DEFINES += AOS_UDATA_SERVICE_TEMP
|
||||
#GLOBAL_DEFINES += AOS_UDATA_SERVICE_HUMI
|
||||
#GLOBAL_DEFINES += UDATA_SERVICE_PROXIMITY
|
||||
#GLOBAL_DEFINES += AOS_UDATA_SERVICE_GPS
|
||||
|
||||
|
||||
|
||||
60
Living_SDK/framework/uData/uData_interface.c
Normal file
60
Living_SDK/framework/uData/uData_interface.c
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*
|
||||
*
|
||||
* uData api for external part
|
||||
*/
|
||||
|
||||
#include <aos/aos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <fcntl.h>
|
||||
#include <aos/yloop.h>
|
||||
#include "uData_com_desc.h"
|
||||
|
||||
int uData_report_publish(input_event_t *event,void *pdata)
|
||||
{
|
||||
if(event == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(pdata == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(event->value >= UDATA_MAX_CNT){
|
||||
return -1;
|
||||
}
|
||||
|
||||
return uData_get_report_pkg(pdata,event->value);
|
||||
}
|
||||
|
||||
int uData_dev_ioctl(udata_t* pkg, uint8_t cmd, void* parm)
|
||||
{
|
||||
/* set the udata_type and related info here */
|
||||
//will be supported later
|
||||
}
|
||||
|
||||
int uData_subscribe(udata_type_e type)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = uData_service_subscribe(type);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG("%s %s successfully\n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uData_unsubscribe(udata_type_e type)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = uData_service_unsubscribe(type);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG("%s %s successfully\n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
41
Living_SDK/framework/uData/uData_main.c
Normal file
41
Living_SDK/framework/uData/uData_main.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*
|
||||
*
|
||||
* uData main
|
||||
*/
|
||||
|
||||
#include "abs_data_model.h"
|
||||
#include "service_mgr.h"
|
||||
|
||||
|
||||
int uData_main(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* NOTE:
|
||||
* please run the abs data init firstly, then run udata service init */
|
||||
|
||||
ret = abs_data_model_init();
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = uData_service_mgr_init();
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = uData_service_init();
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = abs_data_cali_init();
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
LOG("%s %s successfully\n", uDATA_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
34
Living_SDK/framework/uData/ucube.py
Normal file
34
Living_SDK/framework/uData/ucube.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
src =Split('''
|
||||
uData_main.c
|
||||
uData_interface.c
|
||||
service_mgr/service_mgr.c
|
||||
cali_data/calibrated_example_algo.c
|
||||
abs_data_model/abs_data_model.c
|
||||
service_algo/udata_baro_service.c
|
||||
service_algo/udata_gps_service.c
|
||||
''')
|
||||
component =aos_component('uData', src)
|
||||
|
||||
|
||||
global_includes =Split('''
|
||||
.
|
||||
''')
|
||||
for i in global_includes:
|
||||
component.add_global_includes(i)
|
||||
|
||||
global_macros =Split('''
|
||||
AOS_UDATA
|
||||
AOS_UDATA_SERVICE_BARO
|
||||
''')
|
||||
for i in global_macros:
|
||||
component.add_global_macros(i)
|
||||
|
||||
includes =Split('''
|
||||
./include
|
||||
../../include/aos
|
||||
../../include/hal
|
||||
''')
|
||||
for i in includes:
|
||||
component.add_includes(i)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue