sdk build tools and app framework updates (#171)

This commit is contained in:
Wang Xin
2020-02-22 10:12:26 +08:00
committed by GitHub
parent a4ac16a1c8
commit 82b0bb44c3
30 changed files with 572 additions and 733 deletions

View File

@ -9,6 +9,7 @@
#include "bh_platform.h"
#include "bi-inc/attr_container.h"
#include "wasm_export.h"
#include "sensor_native_api.h"
struct _sys_sensor;
typedef struct _sys_sensor* sensor_obj_t;
@ -50,20 +51,10 @@ void sensor_cleanup_callback(uint32 module_id);
int check_sensor_timers();
void reschedule_sensor_read();
uint32
wasm_sensor_open(wasm_exec_env_t exec_env,
int32 name_offset, int instance);
void init_sensor_framework();
void start_sensor_framework();
void exit_sensor_framework();
bool
wasm_sensor_config(wasm_exec_env_t exec_env,
uint32 sensor, int interval, int bit_cfg, int delay);
bool
wasm_sensor_config_with_attr_container(wasm_exec_env_t exec_env,
uint32 sensor, int32 buffer_offset,
int len);
bool
wasm_sensor_close(wasm_exec_env_t exec_env, uint32 sensor);
#endif /* LIB_EXTENSION_RUNTIME_SENSOR_H_ */

View File

@ -1,32 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _SENSOR_API_H_
#define _SENSOR_API_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
uint32
wasm_sensor_open(int32 name_offset, int instance);
bool
wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay);
bool
wasm_sensor_config_with_attr_container(uint32 sensor, int32 buffer_offset, int len);
bool
wasm_sensor_close(uint32 sensor);
#ifdef __cplusplus
}
#endif
#endif /* end of _SENSOR_API_H_ */

View File

@ -84,21 +84,6 @@ void app_mgr_sensor_event_callback(module_data *m_data, bh_message_t msg)
}
}
static attr_container_t * read_test_sensor(void * sensor)
{
//luc: for test
attr_container_t *attr_obj = attr_container_create("read test sensor data");
if (attr_obj) {
attr_container_set_string(&attr_obj, "name", "read test sensor");
return attr_obj;
}
return NULL;
}
static bool config_test_sensor(void * s, void * config)
{
return false;
}
static void thread_sensor_check(void * arg)
{
@ -122,13 +107,9 @@ void set_sensor_reshceduler(void (*callback)());
void init_sensor_framework()
{
// init the mutext and conditions
korp_thread tid;
vm_cond_init(&cond);
vm_mutex_init(&mutex);
// add the sys sensor objects
add_sys_sensor("sensor_test", "This is a sensor for test", 0, 1000,
read_test_sensor, config_test_sensor);
set_sensor_reshceduler(cb_wakeup_thread);
@ -137,12 +118,25 @@ void init_sensor_framework()
wasm_register_cleanup_callback(sensor_cleanup_callback);
vm_thread_create(&tid, (void *)thread_sensor_check, NULL,
BH_APPLET_PRESERVED_STACK_SIZE);
}
void start_sensor_framework()
{
korp_thread tid;
vm_thread_create(&tid,
(void *)thread_sensor_check,
NULL,
BH_APPLET_PRESERVED_STACK_SIZE);
}
void exit_sensor_framework()
{
sensor_check_thread_run = false;
reschedule_sensor_read();
//todo: wait the sensor thread termination
}

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _SENSOR_NATIVE_API_H_
#define _SENSOR_NATIVE_API_H_
#include "bh_platform.h"
#include "wasm_export.h"
#ifdef __cplusplus
extern "C" {
#endif
bool
wasm_sensor_config(wasm_exec_env_t exec_env,
uint32 sensor, int interval,
int bit_cfg, int delay);
uint32
wasm_sensor_open(wasm_exec_env_t exec_env,
int32 name_offset, int instance);
bool
wasm_sensor_config_with_attr_container(wasm_exec_env_t exec_env,
uint32 sensor, int32 buffer_offset,
int len);
bool
wasm_sensor_close(wasm_exec_env_t exec_env, uint32 sensor);
#ifdef __cplusplus
}
#endif
#endif /* end of _SENSOR_NATIVE_API_H_ */