From 983209854c31f26c78be7f86c3b71628d4185000 Mon Sep 17 00:00:00 2001 From: Wang Xin Date: Sat, 22 Feb 2020 08:34:03 +0800 Subject: [PATCH] rename the api header files --- .../app-native-shared/native_interface.h | 94 ------------------- .../base/native/base_lib_export.c | 4 +- .../base/native/base_lib_export.h | 13 --- core/app-framework/base/native/req_resp_api.h | 32 ------- .../base/native/req_resp_native_api.h | 36 +++++++ core/app-framework/base/native/timer_api.h | 37 -------- .../base/native/timer_native_api.h | 43 +++++++++ .../app-framework/base/native/timer_wrapper.c | 1 + .../connection/native/connection_api.h | 32 ------- .../connection/native/connection_native_api.h | 41 ++++++++ .../connection/native/connection_wrapper.c | 2 + core/app-framework/sensor/app/sensor.c | 1 + .../sensor/native/runtime_sensor.h | 17 +--- core/app-framework/sensor/native/sensor_api.h | 32 ------- .../sensor/native/sensor_mgr_ref.c | 36 +++---- .../sensor/native/sensor_native_api.h | 37 ++++++++ core/app-framework/wgl/native/gui_api.h | 36 ------- .../app-framework/wgl/native/gui_native_api.h | 46 +++++++++ .../gui/wasm-runtime-wgl/src/ext_lib_export.c | 6 +- .../vgl-wasm-runtime/src/ext_lib_export.c | 4 +- samples/simple/src/ext_lib_export.c | 6 +- samples/simple/src/iwasm_main.c | 42 ++++++++- 22 files changed, 278 insertions(+), 320 deletions(-) delete mode 100644 core/app-framework/base/native/base_lib_export.h delete mode 100644 core/app-framework/base/native/req_resp_api.h create mode 100644 core/app-framework/base/native/req_resp_native_api.h delete mode 100644 core/app-framework/base/native/timer_api.h create mode 100644 core/app-framework/base/native/timer_native_api.h delete mode 100644 core/app-framework/connection/native/connection_api.h create mode 100644 core/app-framework/connection/native/connection_native_api.h delete mode 100644 core/app-framework/sensor/native/sensor_api.h create mode 100644 core/app-framework/sensor/native/sensor_native_api.h delete mode 100644 core/app-framework/wgl/native/gui_api.h create mode 100644 core/app-framework/wgl/native/gui_native_api.h diff --git a/core/app-framework/app-native-shared/native_interface.h b/core/app-framework/app-native-shared/native_interface.h index cb7e7e96..0c094267 100644 --- a/core/app-framework/app-native-shared/native_interface.h +++ b/core/app-framework/app-native-shared/native_interface.h @@ -34,100 +34,6 @@ /*char *wa_strdup(const char *);*/ -/* - * request/response interfaces - */ - -bool -wasm_response_send(wasm_exec_env_t exec_env, - int32 buffer_offset, int size); -void -wasm_register_resource(wasm_exec_env_t exec_env, - int32 url_offset); -void -wasm_post_request(wasm_exec_env_t exec_env, - int32 buffer_offset, int size); -void -wasm_sub_event(wasm_exec_env_t exec_env, - int32 url_offset); - -/* - * sensor interfaces - */ - -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); - -/* - * timer interfaces - */ - -typedef unsigned int timer_id_t; - -timer_id_t -wasm_create_timer(wasm_exec_env_t exec_env, - int interval, bool is_period, bool auto_start); -void -wasm_timer_destroy(wasm_exec_env_t exec_env, timer_id_t timer_id); -void -wasm_timer_cancel(wasm_exec_env_t exec_env, timer_id_t timer_id); -void -wasm_timer_restart(wasm_exec_env_t exec_env, - timer_id_t timer_id, int interval); -uint32 -wasm_get_sys_tick_ms(wasm_exec_env_t exec_env); - -/* - * connection interfaces - */ - -uint32 -wasm_open_connection(wasm_exec_env_t exec_env, - int32 name_offset, int32 args_offset, uint32 len); -void -wasm_close_connection(wasm_exec_env_t exec_env, - uint32 handle); -int -wasm_send_on_connection(wasm_exec_env_t exec_env, - uint32 handle, int32 data_offset, uint32 len); -bool -wasm_config_connection(wasm_exec_env_t exec_env, - uint32 handle, int32 cfg_offset, uint32 len); - -/** - * gui interfaces - */ - -void -wasm_obj_native_call(wasm_exec_env_t exec_env, - int32 func_id, uint32 argv_offset, uint32 argc); - -void -wasm_btn_native_call(wasm_exec_env_t exec_env, - int32 func_id, uint32 argv_offset, uint32 argc); - -void -wasm_label_native_call(wasm_exec_env_t exec_env, - int32 func_id, uint32 argv_offset, uint32 argc); - -void -wasm_cb_native_call(wasm_exec_env_t exec_env, - int32 func_id, uint32 argv_offset, uint32 argc); - -void -wasm_list_native_call(wasm_exec_env_t exec_env, - int32 func_id, uint32 argv_offset, uint32 argc); #endif /* end of _NATIVE_INTERFACE_H */ diff --git a/core/app-framework/base/native/base_lib_export.c b/core/app-framework/base/native/base_lib_export.c index 3c6d1d74..ee90f1da 100644 --- a/core/app-framework/base/native/base_lib_export.c +++ b/core/app-framework/base/native/base_lib_export.c @@ -7,7 +7,9 @@ #include #include #include "lib_export.h" -#include "base_lib_export.h" +#include "req_resp_native_api.h" +#include "timer_native_api.h" + static NativeSymbol extended_native_symbol_defs[] = { /* TODO: use macro EXPORT_WASM_API() or EXPORT_WASM_API2() to diff --git a/core/app-framework/base/native/base_lib_export.h b/core/app-framework/base/native/base_lib_export.h deleted file mode 100644 index d5f9f626..00000000 --- a/core/app-framework/base/native/base_lib_export.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -#ifndef _BASE_LIB_EXPORT_H_ -#define _BASE_LIB_EXPORT_H_ - -#include "bi-inc/attr_container.h" -#include "native_interface.h" - -#endif /* end of _BASE_LIB_EXPORT_H_ */ - diff --git a/core/app-framework/base/native/req_resp_api.h b/core/app-framework/base/native/req_resp_api.h deleted file mode 100644 index fffa5131..00000000 --- a/core/app-framework/base/native/req_resp_api.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -#ifndef _REQ_RESP_API_H_ -#define _REQ_RESP_API_H_ - -#include "bh_platform.h" - -#ifdef __cplusplus -extern "C" { -#endif - -bool -wasm_response_send(int32 buf_offset, int size); - -void -wasm_register_resource(int32 url_offset); - -void -wasm_post_request(int32 buf_offset, int size); - -void -wasm_sub_event(int32 url_offset); - -#ifdef __cplusplus -} -#endif - -#endif /* end of _REQ_RESP_API_H_ */ - diff --git a/core/app-framework/base/native/req_resp_native_api.h b/core/app-framework/base/native/req_resp_native_api.h new file mode 100644 index 00000000..7e8592b8 --- /dev/null +++ b/core/app-framework/base/native/req_resp_native_api.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#ifndef _REQ_RESP_API_H_ +#define _REQ_RESP_API_H_ + +#include "bh_platform.h" +#include "wasm_export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +bool +wasm_response_send(wasm_exec_env_t exec_env, + int32 buffer_offset, int size); +void +wasm_register_resource(wasm_exec_env_t exec_env, + int32 url_offset); +void +wasm_post_request(wasm_exec_env_t exec_env, + int32 buffer_offset, int size); +void +wasm_sub_event(wasm_exec_env_t exec_env, + int32 url_offset); + + + +#ifdef __cplusplus +} +#endif + +#endif /* end of _REQ_RESP_API_H_ */ + diff --git a/core/app-framework/base/native/timer_api.h b/core/app-framework/base/native/timer_api.h deleted file mode 100644 index 0881bab9..00000000 --- a/core/app-framework/base/native/timer_api.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -#ifndef _TIMER_API_H_ -#define _TIMER_API_H_ - -#include "bh_platform.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned int timer_id_t; - -timer_id_t -wasm_create_timer(int interval, bool is_period, bool auto_start); - -void -wasm_timer_destroy(timer_id_t timer_id); - -void -wasm_timer_cancel(timer_id_t timer_id); - -void -wasm_timer_restart(timer_id_t timer_id, int interval); - -uint32 -wasm_get_sys_tick_ms(void); - -#ifdef __cplusplus -} -#endif - -#endif /* end of _TIMER_API_H_ */ - diff --git a/core/app-framework/base/native/timer_native_api.h b/core/app-framework/base/native/timer_native_api.h new file mode 100644 index 00000000..4d1f5878 --- /dev/null +++ b/core/app-framework/base/native/timer_native_api.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#ifndef _TIMER_API_H_ +#define _TIMER_API_H_ + +#include "bh_platform.h" +#include "wasm_export.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned int timer_id_t; + +/* + * timer interfaces + */ + +typedef unsigned int timer_id_t; + +timer_id_t +wasm_create_timer(wasm_exec_env_t exec_env, + int interval, bool is_period, bool auto_start); +void +wasm_timer_destroy(wasm_exec_env_t exec_env, timer_id_t timer_id); +void +wasm_timer_cancel(wasm_exec_env_t exec_env, timer_id_t timer_id); +void +wasm_timer_restart(wasm_exec_env_t exec_env, + timer_id_t timer_id, int interval); +uint32 +wasm_get_sys_tick_ms(wasm_exec_env_t exec_env); + +#ifdef __cplusplus +} +#endif + +#endif /* end of _TIMER_API_H_ */ + diff --git a/core/app-framework/base/native/timer_wrapper.c b/core/app-framework/base/native/timer_wrapper.c index 9ba3628e..ba5db9e8 100644 --- a/core/app-framework/base/native/timer_wrapper.c +++ b/core/app-framework/base/native/timer_wrapper.c @@ -9,6 +9,7 @@ #include "bh_list.h" #include "bh_thread.h" #include "bh_time.h" +#include "timer_native_api.h" static bool timer_thread_run = true; diff --git a/core/app-framework/connection/native/connection_api.h b/core/app-framework/connection/native/connection_api.h deleted file mode 100644 index 7d8ef598..00000000 --- a/core/app-framework/connection/native/connection_api.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -#ifndef CONNECTION_API_H_ -#define CONNECTION_API_H_ - -#include "bh_platform.h" - -#ifdef __cplusplus -extern "C" { -#endif - -uint32 -wasm_open_connection(int32 name_offset, int32 args_buf_offset, uint32 args_buf_len); - -void -wasm_close_connection(uint32 handle); - -int -wasm_send_on_connection(uint32 handle, int32 data_offset, uint32 data_len); - -bool -wasm_config_connection(uint32 handle, int32 cfg_buf_offset, uint32 cfg_buf_len); - -#ifdef __cplusplus -} -#endif - - -#endif /* end of CONNECTION_API_H_ */ diff --git a/core/app-framework/connection/native/connection_native_api.h b/core/app-framework/connection/native/connection_native_api.h new file mode 100644 index 00000000..3b4fcaa5 --- /dev/null +++ b/core/app-framework/connection/native/connection_native_api.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#ifndef CONNECTION_API_H_ +#define CONNECTION_API_H_ + +#include "bh_platform.h" +#include "wasm_export.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * connection interfaces + */ + +uint32 +wasm_open_connection(wasm_exec_env_t exec_env, + int32 name_offset, int32 args_offset, uint32 len); +void +wasm_close_connection(wasm_exec_env_t exec_env, + uint32 handle); +int +wasm_send_on_connection(wasm_exec_env_t exec_env, + uint32 handle, int32 data_offset, uint32 len); +bool +wasm_config_connection(wasm_exec_env_t exec_env, + uint32 handle, int32 cfg_offset, uint32 len); + + + +#ifdef __cplusplus +} +#endif + + +#endif /* end of CONNECTION_API_H_ */ diff --git a/core/app-framework/connection/native/connection_wrapper.c b/core/app-framework/connection/native/connection_wrapper.c index d817bc4f..b60a2498 100644 --- a/core/app-framework/connection/native/connection_wrapper.c +++ b/core/app-framework/connection/native/connection_wrapper.c @@ -6,6 +6,8 @@ #include "connection_lib.h" #include "wasm_export.h" #include "native_interface.h" +#include "connection_native_api.h" + /* Note: * diff --git a/core/app-framework/sensor/app/sensor.c b/core/app-framework/sensor/app/sensor.c index 8427af4e..2af23faf 100644 --- a/core/app-framework/sensor/app/sensor.c +++ b/core/app-framework/sensor/app/sensor.c @@ -4,6 +4,7 @@ */ #include "wa-inc/sensor.h" + #include "sensor_api.h" typedef struct _sensor { diff --git a/core/app-framework/sensor/native/runtime_sensor.h b/core/app-framework/sensor/native/runtime_sensor.h index 03ce65c0..8154d6d9 100644 --- a/core/app-framework/sensor/native/runtime_sensor.h +++ b/core/app-framework/sensor/native/runtime_sensor.h @@ -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_ */ diff --git a/core/app-framework/sensor/native/sensor_api.h b/core/app-framework/sensor/native/sensor_api.h deleted file mode 100644 index 0546ecf4..00000000 --- a/core/app-framework/sensor/native/sensor_api.h +++ /dev/null @@ -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_ */ - diff --git a/core/app-framework/sensor/native/sensor_mgr_ref.c b/core/app-framework/sensor/native/sensor_mgr_ref.c index b31c696b..9166947e 100644 --- a/core/app-framework/sensor/native/sensor_mgr_ref.c +++ b/core/app-framework/sensor/native/sensor_mgr_ref.c @@ -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 } diff --git a/core/app-framework/sensor/native/sensor_native_api.h b/core/app-framework/sensor/native/sensor_native_api.h new file mode 100644 index 00000000..5cc8ad83 --- /dev/null +++ b/core/app-framework/sensor/native/sensor_native_api.h @@ -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_ */ + diff --git a/core/app-framework/wgl/native/gui_api.h b/core/app-framework/wgl/native/gui_api.h deleted file mode 100644 index 65ff587a..00000000 --- a/core/app-framework/wgl/native/gui_api.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -#ifndef _GUI_API_H_ -#define _GUI_API_H_ - -#include "bh_platform.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void -wasm_obj_native_call(int32 func_id, int32 argv_offset, uint32 argc); - -void -wasm_btn_native_call(int32 func_id, int32 argv_offset, uint32 argc); - -void -wasm_label_native_call(int32 func_id, int32 argv_offset, uint32 argc); - -void -wasm_cb_native_call(int32 func_id, int32 argv_offset, uint32 argc); - -void -wasm_list_native_call(int32 func_id, int32 argv_offset, uint32 argc); - - -#ifdef __cplusplus -} -#endif - - -#endif /* end of _GUI_API_H_ */ diff --git a/core/app-framework/wgl/native/gui_native_api.h b/core/app-framework/wgl/native/gui_native_api.h new file mode 100644 index 00000000..57d98710 --- /dev/null +++ b/core/app-framework/wgl/native/gui_native_api.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#ifndef _GUI_API_H_ +#define _GUI_API_H_ + +#include "bh_platform.h" +#include "wasm_export.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * gui interfaces + */ + +void +wasm_obj_native_call(wasm_exec_env_t exec_env, + int32 func_id, uint32 argv_offset, uint32 argc); + +void +wasm_btn_native_call(wasm_exec_env_t exec_env, + int32 func_id, uint32 argv_offset, uint32 argc); + +void +wasm_label_native_call(wasm_exec_env_t exec_env, + int32 func_id, uint32 argv_offset, uint32 argc); + +void +wasm_cb_native_call(wasm_exec_env_t exec_env, + int32 func_id, uint32 argv_offset, uint32 argc); + +void +wasm_list_native_call(wasm_exec_env_t exec_env, + int32 func_id, uint32 argv_offset, uint32 argc); + +#ifdef __cplusplus +} +#endif + + +#endif /* end of _GUI_API_H_ */ diff --git a/samples/gui/wasm-runtime-wgl/src/ext_lib_export.c b/samples/gui/wasm-runtime-wgl/src/ext_lib_export.c index 4f696f0a..0058f990 100644 --- a/samples/gui/wasm-runtime-wgl/src/ext_lib_export.c +++ b/samples/gui/wasm-runtime-wgl/src/ext_lib_export.c @@ -1,7 +1,7 @@ #include "lib_export.h" -#include "sensor_api.h" -#include "connection_api.h" -#include "gui_api.h" +#include "sensor_native_api.h" +#include "connection_native_api.h" +#include "gui_native_api.h" static NativeSymbol extended_native_symbol_defs[] = { #include "runtime_sensor.inl" diff --git a/samples/littlevgl/vgl-wasm-runtime/src/ext_lib_export.c b/samples/littlevgl/vgl-wasm-runtime/src/ext_lib_export.c index 0f68dd86..8262770b 100644 --- a/samples/littlevgl/vgl-wasm-runtime/src/ext_lib_export.c +++ b/samples/littlevgl/vgl-wasm-runtime/src/ext_lib_export.c @@ -1,6 +1,6 @@ #include "lib_export.h" -#include "sensor_api.h" -#include "connection_api.h" +#include "sensor_native_api.h" +#include "connection_native_api.h" #include "display_indev.h" static NativeSymbol extended_native_symbol_defs[] = { diff --git a/samples/simple/src/ext_lib_export.c b/samples/simple/src/ext_lib_export.c index 4a5750b2..b3868bb7 100644 --- a/samples/simple/src/ext_lib_export.c +++ b/samples/simple/src/ext_lib_export.c @@ -1,6 +1,8 @@ #include "lib_export.h" -#include "sensor_api.h" -#include "connection_api.h" +#include "sensor_native_api.h" +#include "timer_native_api.h" +#include "req_resp_native_api.h" +#include "connection_native_api.h" static NativeSymbol extended_native_symbol_defs[] = { #include "runtime_sensor.inl" diff --git a/samples/simple/src/iwasm_main.c b/samples/simple/src/iwasm_main.c index ee808e4c..06c2704c 100644 --- a/samples/simple/src/iwasm_main.c +++ b/samples/simple/src/iwasm_main.c @@ -354,6 +354,25 @@ static host_interface interface = { .send = uart_send, .destroy = uart_destroy } #endif + + +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 char global_heap_buf[1024 * 1024] = { 0 }; static void showUsage() @@ -458,15 +477,34 @@ int iwasm_main(int argc, char *argv[]) goto fail1; } + // + // timer manager + // + init_wasm_timer(); + + + // + // connection framework + // if (!init_connection_framework()) { vm_thread_sys_destroy(); goto fail1; } + // + // sensor framework + // init_sensor_framework(); + // add the sys sensor objects + add_sys_sensor("sensor_test", + "This is a sensor for test", + 0, + 1000, + read_test_sensor, + config_test_sensor); + start_sensor_framework(); + - // timer manager - init_wasm_timer(); #ifndef CONNECTION_UART if (server_mode)