mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2026-07-06 10:45:39 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
88
Living_SDK/test/testcase/framework/alink_test/alink_test.c
Normal file
88
Living_SDK/test/testcase/framework/alink_test/alink_test.c
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <aos/types.h>
|
||||
#include <yunit.h>
|
||||
#include <yts.h>
|
||||
#include "alink_export.h"
|
||||
|
||||
static void callback_cloud_disconnected(void)
|
||||
{
|
||||
printf("alink wsf server disconnected.\n");
|
||||
}
|
||||
|
||||
static void callback_cloud_connected(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
printf("alink wsf server connected.\n");
|
||||
|
||||
ret = alink_end();
|
||||
YUNIT_ASSERT(0 == ret);
|
||||
}
|
||||
|
||||
static void test_alink_sandbox(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = alink_enable_sandbox_mode();
|
||||
YUNIT_ASSERT(0 == ret);
|
||||
|
||||
alink_register_callback(ALINK_CLOUD_CONNECTED,callback_cloud_connected);
|
||||
alink_register_callback(ALINK_CLOUD_DISCONNECTED,callback_cloud_disconnected);
|
||||
|
||||
ret = alink_start();
|
||||
YUNIT_ASSERT(0 == ret);
|
||||
}
|
||||
|
||||
static void test_alink_daily(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = alink_enable_daily_mode(NULL,0);
|
||||
YUNIT_ASSERT(0 == ret);
|
||||
|
||||
ret = alink_start();
|
||||
YUNIT_ASSERT(0 == ret);
|
||||
}
|
||||
|
||||
static int init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cleanup(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void teardown(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static yunit_test_case_t aos_alink_testcases[] = {
|
||||
{ "daily", test_alink_daily},
|
||||
{ "sandbox",test_alink_sandbox},
|
||||
YUNIT_TEST_CASE_NULL
|
||||
};
|
||||
|
||||
static yunit_test_suite_t suites[] = {
|
||||
{ "alink", init, cleanup, setup, teardown, aos_alink_testcases },
|
||||
YUNIT_TEST_SUITE_NULL
|
||||
};
|
||||
|
||||
void test_alink(void)
|
||||
{
|
||||
yunit_add_test_suites(suites);
|
||||
}
|
||||
AOS_TESTCASE(test_alink);
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
NAME := alink_test
|
||||
|
||||
$(NAME)_COMPONENTS += protocol.alink ywss
|
||||
|
||||
$(NAME)_SOURCES += alink_test.c
|
||||
|
||||
$(NAME)_CFLAGS += -Wall -Werror
|
||||
|
||||
11
Living_SDK/test/testcase/framework/alink_test/ucube.py
Normal file
11
Living_SDK/test/testcase/framework/alink_test/ucube.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
src = Split('''
|
||||
alink_test.c
|
||||
''')
|
||||
|
||||
component = aos_component('alink_test', src)
|
||||
|
||||
component.add_comp_deps('framework/protocol/alink')
|
||||
component.add_comp_deps('framework/ywss')
|
||||
|
||||
component.add_cflags('-Wall')
|
||||
component.add_cflags('-Werror')
|
||||
82
Living_SDK/test/testcase/framework/fota_test/fota_test.c
Normal file
82
Living_SDK/test/testcase/framework/fota_test/fota_test.c
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <aos/kernel.h>
|
||||
#include <aos/aos.h>
|
||||
|
||||
#include <yunit.h>
|
||||
#include <yts.h>
|
||||
#include "ota_transport.h"
|
||||
extern void ota_service_event(input_event_t *event, void *priv_data);
|
||||
extern void ota_check_update(const char *buf, int len);
|
||||
extern void ota_service_init(void);
|
||||
extern void do_update(int len, const char *buf);
|
||||
extern void http_gethost_info(char* src, char* web, char* file, int* port);
|
||||
extern int ota_socket_connect(int port, char *host_addr);
|
||||
extern void ota_download_start(void * buf);
|
||||
extern int8_t platform_ota_parse_requset(const char* request, int *buf_len, ota_request_params * request_parmas);
|
||||
extern int8_t platform_ota_parse_response(const char* response, int buf_len, ota_response_params * response_parmas);
|
||||
|
||||
const char *ota_info = "{\"md5\":\"6B21342306D0F619AF97006B7025D18A\",\"resourceUrl\":\"http://otalink.alicdn.com/ALINKTEST_LIVING_LIGHT_ALINK_TEST/v2.0.0.1/uthash-master.zip\",\"size\":\"265694 \",\"uuid\":\"5B7CFD5C6B1D6A231F5FB6B7DB2B71FD\",\"version\":\"v2.0.0.1\",\"zip\":\"0\"}";
|
||||
|
||||
static void test_fota_case(void)
|
||||
{
|
||||
int ret = 0;
|
||||
input_event_t event;
|
||||
event.type = EV_SYS;
|
||||
event.code = CODE_SYS_ON_START_FOTA;
|
||||
event.value= NULL;
|
||||
ota_service_event(&event, NULL);
|
||||
ota_check_update("",1);
|
||||
ota_download_start(NULL);
|
||||
do_update(0, NULL);
|
||||
do_update(0, ota_info);
|
||||
|
||||
http_gethost_info(NULL, NULL, NULL, NULL);
|
||||
ret = ota_socket_connect(0, NULL);
|
||||
YUNIT_ASSERT(ret == -1);
|
||||
ret = platform_ota_parse_requset(NULL, NULL, NULL);
|
||||
YUNIT_ASSERT(ret == 0);
|
||||
ret = platform_ota_parse_response(NULL, 0, NULL);
|
||||
YUNIT_ASSERT(ret == -1)
|
||||
}
|
||||
|
||||
static int init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cleanup(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void teardown(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static yunit_test_case_t aos_fota_testcases[] = {
|
||||
{ "fota", test_fota_case },
|
||||
YUNIT_TEST_CASE_NULL
|
||||
};
|
||||
|
||||
static yunit_test_suite_t suites[] = {
|
||||
{ "fota", init, cleanup, setup, teardown, aos_fota_testcases },
|
||||
YUNIT_TEST_SUITE_NULL
|
||||
};
|
||||
|
||||
void test_fota(void)
|
||||
{
|
||||
yunit_add_test_suites(suites);
|
||||
}
|
||||
AOS_TESTCASE(test_fota);
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
NAME := fota_test
|
||||
|
||||
$(NAME)_COMPONENTS += fota
|
||||
|
||||
$(NAME)_SOURCES += fota_test.c
|
||||
|
||||
7
Living_SDK/test/testcase/framework/fota_test/ucube.py
Normal file
7
Living_SDK/test/testcase/framework/fota_test/ucube.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
src = Split('''
|
||||
fota_test.c
|
||||
''')
|
||||
|
||||
component = aos_component('fota_test', src)
|
||||
|
||||
component.add_comp_deps('framework/fota')
|
||||
154
Living_SDK/test/testcase/framework/netmgr_test/netmgr_test.c
Normal file
154
Living_SDK/test/testcase/framework/netmgr_test/netmgr_test.c
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#include <aos/kernel.h>
|
||||
#include <aos/aos.h>
|
||||
#include <hal/base.h>
|
||||
#include <hal/wifi.h>
|
||||
#include <yunit.h>
|
||||
#include <yts.h>
|
||||
|
||||
#include "netmgr.h"
|
||||
|
||||
enum
|
||||
{
|
||||
SMART_CONFIG_FLAG = 1 << 0,
|
||||
SAVED_CONFIG_FLAG = 1 << 1,
|
||||
DONE_FLAGS = SMART_CONFIG_FLAG | SAVED_CONFIG_FLAG,
|
||||
};
|
||||
|
||||
static uint8_t done_flag = 0;
|
||||
static void smart_config_test(void *arg);
|
||||
static void saved_config_test(void *arg);
|
||||
|
||||
static int events_executor(input_event_t *eventinfo, void *cb_para, int flag)
|
||||
{
|
||||
char ips[16];
|
||||
|
||||
printf("Type:%d Code:%d Flag:%d\n", eventinfo->type, eventinfo->code, flag);
|
||||
if (eventinfo->type != EV_WIFI)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((done_flag == SMART_CONFIG_FLAG) && (flag == SAVED_CONFIG_FLAG))
|
||||
{
|
||||
done_flag = DONE_FLAGS;
|
||||
}
|
||||
|
||||
switch (eventinfo->code)
|
||||
{
|
||||
case CODE_WIFI_ON_GOT_IP:
|
||||
done_flag |= flag;
|
||||
printf("done_flag:%d\n", done_flag);
|
||||
netmgr_deinit();
|
||||
wifi_get_ip(ips);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void saved_config_event_executor(input_event_t *eventinfo, void *cb_para)
|
||||
{
|
||||
events_executor(eventinfo, cb_para, SAVED_CONFIG_FLAG);
|
||||
}
|
||||
|
||||
static void smart_config_event_executor(input_event_t *eventinfo, void *cb_para)
|
||||
{
|
||||
if (events_executor(eventinfo, cb_para, SMART_CONFIG_FLAG) == 0)
|
||||
{
|
||||
aos_schedule_call(saved_config_test, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void smart_config_test(void *arg)
|
||||
{
|
||||
int ret;
|
||||
aos_unregister_event_filter(EV_WIFI, saved_config_event_executor, NULL);
|
||||
aos_register_event_filter(EV_WIFI, smart_config_event_executor, NULL);
|
||||
netmgr_init();
|
||||
ret = netmgr_start(true);
|
||||
#ifdef CONFIG_AOS_NETMGRYTS_NOSMARTCONFIG
|
||||
/* do not wait for WIFI event if no valid AP. */
|
||||
if (ret != 0)
|
||||
done_flag = DONE_FLAGS;
|
||||
#else
|
||||
(void)ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void saved_config_test(void *arg)
|
||||
{
|
||||
int ret;
|
||||
aos_unregister_event_filter(EV_WIFI, smart_config_event_executor, NULL);
|
||||
aos_register_event_filter(EV_WIFI, saved_config_event_executor, NULL);
|
||||
netmgr_init();
|
||||
ret = netmgr_start(true);
|
||||
#ifdef CONFIG_AOS_NETMGRYTS_NOSMARTCONFIG
|
||||
/* do not wait for WIFI event if no valid AP. */
|
||||
if (ret != 0)
|
||||
done_flag = DONE_FLAGS;
|
||||
#else
|
||||
(void)ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test_netmgr_cases(void *arg)
|
||||
{
|
||||
aos_schedule_call(smart_config_test, NULL);
|
||||
}
|
||||
|
||||
static void netmgr_test_entry(void *arg)
|
||||
{
|
||||
aos_post_delayed_action(1000, test_netmgr_cases, NULL);
|
||||
aos_loop_run();
|
||||
}
|
||||
|
||||
static void netmgr_test_exit(void *arg)
|
||||
{
|
||||
aos_loop_exit();
|
||||
}
|
||||
|
||||
static void test_netmgr_connect_case(void)
|
||||
{
|
||||
aos_task_new("netmgr_test_main", netmgr_test_entry, NULL, 8192);
|
||||
|
||||
/* Set max 60s wait here, since wifi connect needs time to finish. */
|
||||
check_cond_wait(done_flag == DONE_FLAGS, 60);
|
||||
aos_schedule_call(netmgr_test_exit, NULL);
|
||||
aos_unregister_event_filter(EV_WIFI, smart_config_event_executor, NULL);
|
||||
aos_unregister_event_filter(EV_WIFI, saved_config_event_executor, NULL);
|
||||
}
|
||||
|
||||
static int init(void)
|
||||
{
|
||||
done_flag = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cleanup(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void teardown(void)
|
||||
{
|
||||
}
|
||||
|
||||
static yunit_test_case_t aos_netmgr_testcases[] = {
|
||||
{"netmgr_connect", test_netmgr_connect_case},
|
||||
YUNIT_TEST_CASE_NULL};
|
||||
|
||||
static yunit_test_suite_t suites[] = {
|
||||
{"netmgr", init, cleanup, setup, teardown, aos_netmgr_testcases},
|
||||
YUNIT_TEST_SUITE_NULL};
|
||||
|
||||
void test_netmgr(void)
|
||||
{
|
||||
yunit_add_test_suites(suites);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
NAME := netmgr_test
|
||||
|
||||
$(NAME)_COMPONENTS +=
|
||||
|
||||
$(NAME)_SOURCES += netmgr_test.c
|
||||
|
||||
$(NAME)_CFLAGS += -Wall -Werror
|
||||
|
||||
ifeq (,$(findstring linux, $(BUILD_STRING)))
|
||||
GLOBAL_DEFINES += CONFIG_AOS_NETMGRYTS_NOSMARTCONFIG
|
||||
endif
|
||||
8
Living_SDK/test/testcase/framework/netmgr_test/ucube.py
Normal file
8
Living_SDK/test/testcase/framework/netmgr_test/ucube.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
src = Split('''
|
||||
netmgr_test.c
|
||||
''')
|
||||
|
||||
component = aos_component('netmgr_test', src)
|
||||
|
||||
if aos_global_config.board == 'linuxhost':
|
||||
component.add_global_macros('CONFIG_AOS_NETMGRYTS_NOSMARTCONFIG')
|
||||
362
Living_SDK/test/testcase/framework/uData_test/uData_test.c
Normal file
362
Living_SDK/test/testcase/framework/uData_test/uData_test.c
Normal file
|
|
@ -0,0 +1,362 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <vfs_conf.h>
|
||||
#include <vfs_err.h>
|
||||
#include <vfs_register.h>
|
||||
|
||||
#include <aos/kernel.h>
|
||||
#include <aos/aos.h>
|
||||
#include <aos/uData.h>
|
||||
|
||||
#include "yunit.h"
|
||||
|
||||
#include "hal/soc/soc.h"
|
||||
|
||||
#define UDATA_SUCCES 0
|
||||
|
||||
static int uData_sensor_open(inode_t *node, file_t *file);
|
||||
static int uData_sensor_close(file_t *file);
|
||||
static ssize_t uData_sensor_read(file_t *f, void *buf, size_t len);
|
||||
static ssize_t uData_sensor_write(file_t *f, const void *buf, size_t len);
|
||||
static int uData_sensor_ioctl(file_t *f, int cmd, unsigned long arg);
|
||||
|
||||
file_ops_t uData_sensor_fops = {
|
||||
.open = uData_sensor_open,
|
||||
.close = uData_sensor_close,
|
||||
.read = uData_sensor_read,
|
||||
.write = uData_sensor_write,
|
||||
.ioctl = uData_sensor_ioctl,
|
||||
};
|
||||
|
||||
static sensor_obj_t *g_sensor_obj[TAG_DEV_SENSOR_NUM_MAX];
|
||||
static uint32_t g_sensor_cnt = 0;
|
||||
|
||||
static int drv_virtual_sensor_open(void)
|
||||
{
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static int drv_virtual_sensor_close(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int drv_virtual_sensor_read(void *buf, size_t len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int drv_virtual_sensor_ioctl(int cmd, unsigned long arg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_virtual_sensor_init(void){
|
||||
int ret = 0;
|
||||
sensor_obj_t sensor;
|
||||
|
||||
/* fill the sensor obj parameters here */
|
||||
sensor.tag = TAG_DEV_BARO;
|
||||
sensor.path = dev_baro_path;
|
||||
sensor.io_port = I2C_PORT;
|
||||
sensor.open = drv_virtual_sensor_open;
|
||||
sensor.close = drv_virtual_sensor_close;
|
||||
sensor.read = drv_virtual_sensor_read;
|
||||
sensor.write = NULL;
|
||||
sensor.ioctl = drv_virtual_sensor_ioctl;
|
||||
sensor.irq_handle = NULL;
|
||||
|
||||
ret = uData_sensor_create_obj(&sensor);
|
||||
if(unlikely(ret)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG("%s %s successfully \n", SENSOR_STR, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int uData_find_selected_sensor(char* path )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if(path == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i = 0; i < g_sensor_cnt; i++){
|
||||
if(strncmp(g_sensor_obj[i]->path, path, strlen(path)) == 0){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
static int uData_load_sensor_config(int index )
|
||||
{
|
||||
int ret = 0;
|
||||
g_sensor_obj[index] = (sensor_obj_t*)aos_malloc(sizeof(sensor_obj_t));
|
||||
if(g_sensor_obj[index] == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uData_sensor_obj_register(int index )
|
||||
{
|
||||
int ret = 0;
|
||||
ret = aos_register_driver(g_sensor_obj[index]->path, &uData_sensor_fops, NULL);
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uData_sensor_create_obj(sensor_obj_t* sensor)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
g_sensor_obj[g_sensor_cnt] = (sensor_obj_t*)aos_malloc(sizeof(sensor_obj_t));
|
||||
if(g_sensor_obj[g_sensor_cnt] == NULL){
|
||||
return -1;
|
||||
}
|
||||
memset(g_sensor_obj[g_sensor_cnt], 0, sizeof(sensor_obj_t));
|
||||
|
||||
/* install the phy sensor info into the sensor object datebase here */
|
||||
g_sensor_obj[g_sensor_cnt]->io_port = sensor->io_port;
|
||||
g_sensor_obj[g_sensor_cnt]->path = sensor->path;
|
||||
g_sensor_obj[g_sensor_cnt]->tag = sensor->tag;
|
||||
g_sensor_obj[g_sensor_cnt]->open = sensor->open;
|
||||
g_sensor_obj[g_sensor_cnt]->close = sensor->close;
|
||||
g_sensor_obj[g_sensor_cnt]->ioctl = sensor->ioctl;
|
||||
g_sensor_obj[g_sensor_cnt]->read = sensor->read;
|
||||
g_sensor_obj[g_sensor_cnt]->write = sensor->write;
|
||||
g_sensor_obj[g_sensor_cnt]->irq_handle = sensor->irq_handle;
|
||||
g_sensor_obj[g_sensor_cnt]->mode = sensor->mode;
|
||||
g_sensor_obj[g_sensor_cnt]->bus = sensor->bus;
|
||||
g_sensor_obj[g_sensor_cnt]->power = DEV_POWER_OFF; // will update the status later
|
||||
|
||||
/* register the sensor object into the irq list and vfs */
|
||||
ret = uData_sensor_obj_register(g_sensor_cnt);
|
||||
if (ret != 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_sensor_cnt++;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
free(g_sensor_obj[g_sensor_cnt]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int uData_sensor_hal_get_dev_list(void* buf)
|
||||
{
|
||||
sensor_list_t* list = buf;
|
||||
if(buf == NULL)
|
||||
return -1;
|
||||
|
||||
/* load the sensor count and tag list here */
|
||||
list->cnt = g_sensor_cnt;
|
||||
for(int index = 0; index < g_sensor_cnt; index++){
|
||||
list->list[index] = g_sensor_obj[index]->tag;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uData_sensor_open(inode_t *node, file_t *file)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
if((node == NULL)||(file == NULL)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* just open the /dev/sensor node here */
|
||||
if(strncmp(sensor_node_path, node->i_name, strlen(node->i_name)) == 0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
index = uData_find_selected_sensor(node->i_name);
|
||||
if(( g_sensor_obj[index]->open == NULL)||(index < 0)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_sensor_obj[index]->open();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uData_sensor_close(file_t *file)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
/* just close the /dev/sensor node here */
|
||||
if(strncmp(sensor_node_path, (file->node->i_name), strlen(file->node->i_name)) == 0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
index = uData_find_selected_sensor(file->node->i_name);
|
||||
if(( g_sensor_obj[index]->close == NULL)||(index < 0)){
|
||||
return -1;
|
||||
}
|
||||
g_sensor_obj[index]->close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t uData_sensor_read(file_t *f, void *buf, size_t len)
|
||||
{
|
||||
int index = 0;
|
||||
int ret = 0;
|
||||
|
||||
if(f == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
index = uData_find_selected_sensor(f->node->i_name);
|
||||
if(( g_sensor_obj[index]->read == NULL)||(index < 0)){
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(buf == NULL){
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = g_sensor_obj[index]->read(buf, len);
|
||||
if(ret != 0){
|
||||
goto error;
|
||||
}
|
||||
|
||||
return len;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static ssize_t uData_sensor_write(file_t *f, const void *buf, size_t len)
|
||||
{
|
||||
/* no need this functionality recently */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uData_sensor_ioctl(file_t *f, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret = 0;
|
||||
int index = 0;
|
||||
|
||||
if(f == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(cmd == SENSOR_IOCTL_GET_SENSOR_LIST){
|
||||
ret = uData_sensor_hal_get_dev_list(arg);
|
||||
if(ret != 0){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
index = uData_find_selected_sensor(f->node->i_name);
|
||||
if(( g_sensor_obj[index]->ioctl == NULL)||(index < 0)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = g_sensor_obj[index]->ioctl(cmd, arg);
|
||||
if(ret != 0){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uData_sensor_hal_register(void)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = aos_register_driver(sensor_node_path, &uData_sensor_fops, NULL);
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uData_sensor_init(void){
|
||||
int ret = 0;
|
||||
int index = 0;
|
||||
g_sensor_cnt = 0 ;
|
||||
|
||||
drv_virtual_sensor_init();
|
||||
|
||||
ret = uData_sensor_hal_register();
|
||||
if(ret != 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void test_udata_subscribe_case(void)
|
||||
{
|
||||
int ret = 0;
|
||||
uData_sensor_init();
|
||||
uData_main();
|
||||
ret = uData_subscribe(UDATA_SERVICE_BARO);
|
||||
YUNIT_ASSERT(ret == UDATA_SUCCES);
|
||||
}
|
||||
|
||||
static void test_udata_unsubscribe_case(void)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = uData_unsubscribe(UDATA_SERVICE_BARO);
|
||||
YUNIT_ASSERT(ret == UDATA_SUCCES);
|
||||
}
|
||||
|
||||
static yunit_test_case_t aos_udata_testcases[] = {
|
||||
{ "subscribe", test_udata_subscribe_case },
|
||||
{ "unsubscribe", test_udata_unsubscribe_case },
|
||||
//{ "get list", test_udata_getlist_case },
|
||||
//{ "open", test_udata_open_case},
|
||||
//{ "close", test_udata_close_case},
|
||||
//{ "ioctl", test_udata_ioctl_case},
|
||||
YUNIT_TEST_CASE_NULL
|
||||
};
|
||||
|
||||
static int init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cleanup(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void teardown(void)
|
||||
{
|
||||
}
|
||||
|
||||
static yunit_test_suite_t suites[] = {
|
||||
{ "uData", init, cleanup, setup, teardown, aos_udata_testcases },
|
||||
YUNIT_TEST_SUITE_NULL
|
||||
};
|
||||
|
||||
void test_uData(void)
|
||||
{
|
||||
yunit_add_test_suites(suites);
|
||||
}
|
||||
|
||||
AOS_TESTCASE(test_uData);
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
NAME := uData_test
|
||||
|
||||
$(NAME)_COMPONENTS += framework.common uData
|
||||
|
||||
$(NAME)_SOURCES += uData_test.c
|
||||
|
||||
$(NAME)_CFLAGS += -Wall -Werror
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
src = Split('''
|
||||
wifi_hal_test.c
|
||||
''')
|
||||
|
||||
component = aos_component('wifi_hal_test', src)
|
||||
259
Living_SDK/test/testcase/framework/wifi_hal_test/wifi_hal_test.c
Normal file
259
Living_SDK/test/testcase/framework/wifi_hal_test/wifi_hal_test.c
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <aos/aos.h>
|
||||
#include <aos/kernel.h>
|
||||
|
||||
#include <hal/soc/soc.h>
|
||||
|
||||
#include <yunit.h>
|
||||
#include <yts.h>
|
||||
#include <hal/base.h>
|
||||
#include <hal/wifi.h>
|
||||
|
||||
|
||||
static void test_timer_cb(void *arg)
|
||||
{
|
||||
int *pc = arg;
|
||||
(*pc) ++;
|
||||
}
|
||||
|
||||
static void test_timer_case(void)
|
||||
{
|
||||
int counter = 0, old_counter;
|
||||
timer_dev_t t;
|
||||
|
||||
t.port = 0;
|
||||
t.config.period = 50000; //unit is microsecond
|
||||
|
||||
t.config.reload_mode = TIMER_RELOAD_AUTO;
|
||||
t.config.cb = &test_timer_cb;
|
||||
t.config.arg = &counter;
|
||||
|
||||
hal_timer_init(&t);
|
||||
aos_msleep(1000);
|
||||
YUNIT_ASSERT(counter == 0);
|
||||
|
||||
hal_timer_start(&t);
|
||||
check_cond_wait(counter > 3, 2);
|
||||
|
||||
hal_timer_stop(&t);
|
||||
aos_msleep(1000);
|
||||
|
||||
old_counter = counter;
|
||||
aos_msleep(1000);
|
||||
YUNIT_ASSERT(counter == old_counter);
|
||||
if (counter != old_counter)
|
||||
printf("%s %d %d\n", __func__, counter, old_counter);
|
||||
}
|
||||
|
||||
|
||||
static uint8_t fixmac[6] = {0xd8,0x96,0xe0,0x03,0x04,0x01};
|
||||
|
||||
static int wifi_init(hal_wifi_module_t *m)
|
||||
{
|
||||
printf("wifi init success!!\n");
|
||||
return 0;
|
||||
};
|
||||
|
||||
static void wifi_get_mac_addr(hal_wifi_module_t *m, uint8_t *mac)
|
||||
{
|
||||
(void)m;
|
||||
printf("wifi_get_mac_addr!!\n");
|
||||
memcpy(mac, fixmac, 6);
|
||||
};
|
||||
|
||||
static int wifi_start(hal_wifi_module_t *m, hal_wifi_init_type_t *init_para)
|
||||
{
|
||||
(void)init_para;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wifi_start_adv(hal_wifi_module_t *m, hal_wifi_init_type_adv_t *init_para_adv)
|
||||
{
|
||||
(void)init_para_adv;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_ip_stat(hal_wifi_module_t *m, hal_wifi_ip_stat_t *out_net_para, hal_wifi_type_t wifi_type)
|
||||
{
|
||||
(void)wifi_type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_link_stat(hal_wifi_module_t *m, hal_wifi_link_stat_t *out_stat)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void start_scan(hal_wifi_module_t *m)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void start_scan_adv(hal_wifi_module_t *m)
|
||||
{
|
||||
}
|
||||
|
||||
static int power_off(hal_wifi_module_t *m)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int power_on(hal_wifi_module_t *m)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int suspend(hal_wifi_module_t *m)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int suspend_station(hal_wifi_module_t *m)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int suspend_soft_ap(hal_wifi_module_t *m)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_channel(hal_wifi_module_t *m, int ch)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void start_monitor(hal_wifi_module_t *m)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void stop_monitor(hal_wifi_module_t *m)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void register_monitor_cb(hal_wifi_module_t *m, monitor_data_cb_t fn)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#if (WIFI_CONFIG_SUPPORT_LOWPOWER > 0)
|
||||
static int set_listeninterval(hal_wifi_module_t *m, uint8_t listen_interval)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int enter_powersave(hal_wifi_module_t *m, uint8_t recvDTIMs)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int exit_powersave(hal_wifi_module_t *m)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static hal_wifi_module_t sim_aos_wifi_module = {
|
||||
.base.name = "sim_aos_wifi_module",
|
||||
.init = wifi_init,
|
||||
.get_mac_addr = wifi_get_mac_addr,
|
||||
.start = wifi_start,
|
||||
.start_adv = wifi_start_adv,
|
||||
.get_ip_stat = get_ip_stat,
|
||||
.get_link_stat = get_link_stat,
|
||||
.start_scan = start_scan,
|
||||
.start_scan_adv = start_scan_adv,
|
||||
.power_off = power_off,
|
||||
.power_on = power_on,
|
||||
.suspend = suspend,
|
||||
.suspend_station = suspend_station,
|
||||
.suspend_soft_ap = suspend_soft_ap,
|
||||
.set_channel = set_channel,
|
||||
.start_monitor = start_monitor,
|
||||
.stop_monitor = stop_monitor,
|
||||
.register_monitor_cb = register_monitor_cb,
|
||||
#if (WIFI_CONFIG_SUPPORT_LOWPOWER > 0)
|
||||
.set_listeninterval = set_listeninterval,
|
||||
.enter_powersave = enter_powersave,
|
||||
.exit_powersave = exit_powersave,
|
||||
#endif
|
||||
};
|
||||
|
||||
static void test_wifi_case(void)
|
||||
{
|
||||
uint8_t mac[6];
|
||||
hal_wifi_module_t *tmp;
|
||||
|
||||
printf("start wifi test case\n");
|
||||
|
||||
tmp = hal_wifi_get_default_module();
|
||||
(void)tmp;
|
||||
|
||||
hal_wifi_register_module(&sim_aos_wifi_module);
|
||||
hal_wifi_init();
|
||||
hal_wifi_get_mac_addr(&sim_aos_wifi_module, mac);
|
||||
hal_wifi_start(&sim_aos_wifi_module, NULL);
|
||||
hal_wifi_start_adv(&sim_aos_wifi_module, NULL);
|
||||
hal_wifi_get_ip_stat(&sim_aos_wifi_module, NULL, SOFT_AP);
|
||||
hal_wifi_get_link_stat(&sim_aos_wifi_module, NULL);
|
||||
hal_wifi_start_scan(&sim_aos_wifi_module);
|
||||
hal_wifi_start_scan_adv(&sim_aos_wifi_module);
|
||||
hal_wifi_power_off(&sim_aos_wifi_module);
|
||||
hal_wifi_power_on(&sim_aos_wifi_module);
|
||||
hal_wifi_suspend(&sim_aos_wifi_module);
|
||||
hal_wifi_suspend_station(&sim_aos_wifi_module);
|
||||
hal_wifi_suspend_soft_ap(&sim_aos_wifi_module);
|
||||
hal_wifi_set_channel(&sim_aos_wifi_module, 0);
|
||||
hal_wifi_start_wifi_monitor(&sim_aos_wifi_module);
|
||||
hal_wifi_stop_wifi_monitor(&sim_aos_wifi_module);
|
||||
hal_wifi_register_monitor_cb(&sim_aos_wifi_module, NULL);
|
||||
printf("first mac addr is 0x%x\n", mac[0]);
|
||||
}
|
||||
|
||||
static int init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cleanup(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void teardown(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static yunit_test_case_t aos_wifi_hal_testcases[] = {
|
||||
{ "timer", test_timer_case },
|
||||
{ "wifi", test_wifi_case },
|
||||
YUNIT_TEST_CASE_NULL
|
||||
};
|
||||
|
||||
static yunit_test_suite_t suites[] = {
|
||||
{ "hal", init, cleanup, setup, teardown, aos_wifi_hal_testcases },
|
||||
YUNIT_TEST_SUITE_NULL
|
||||
};
|
||||
|
||||
void test_wifi_hal(void)
|
||||
{
|
||||
yunit_add_test_suites(suites);
|
||||
}
|
||||
AOS_TESTCASE(test_wifi_hal);
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
NAME := wifi_hal_test
|
||||
|
||||
$(NAME)_COMPONENTS +=
|
||||
|
||||
$(NAME)_SOURCES += wifi_hal_test.c
|
||||
|
||||
$(NAME)_CFLAGS += -Wall -Werror
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue