mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2026-07-13 13:35:38 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
170
Living_SDK/include/aos/alink.h
Normal file
170
Living_SDK/include/aos/alink.h
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_ALINK_H
|
||||
#define AOS_ALINK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
enum ALINK_LOG_LEVEL {
|
||||
ALINK_LL_NONE, /* disable log */
|
||||
ALINK_LL_FATAL, /* fatal error log will output */
|
||||
ALINK_LL_ERROR, /* error + fatal log will output */
|
||||
ALINK_LL_WARN, /* warn + error + fatal log will output(default level) */
|
||||
ALINK_LL_INFO, /* info + warn + error + fatal log will output */
|
||||
ALINK_LL_DEBUG, /* debug + info + warn + error + fatal log will output */
|
||||
ALINK_LL_TRACE, /* trace + debug + info + warn + error + fatal will output */
|
||||
};
|
||||
|
||||
/**
|
||||
* Log level control
|
||||
*
|
||||
* @param[in] loglevel ALINK_LOG_LEVEL
|
||||
*/
|
||||
void alink_set_loglevel(enum ALINK_LOG_LEVEL loglevel);
|
||||
|
||||
/**
|
||||
* Enable sandbox mode, for debug
|
||||
*
|
||||
* @return 0 on success, otherwise -1 will return
|
||||
*/
|
||||
int alink_enable_sandbox_mode(void);
|
||||
|
||||
/**
|
||||
* Enable daily mode, for debug
|
||||
*
|
||||
* @param[in] server_ip IP Addr
|
||||
* @param[in] port server port
|
||||
*
|
||||
* @return 0 on success, otherwise -1 will return
|
||||
*/
|
||||
int alink_enable_daily_mode(const char *server_ip, int port);
|
||||
|
||||
/**
|
||||
* Entry function. start alink gateway service.
|
||||
*
|
||||
* @return 0 on success, otherwise -1 will return
|
||||
*/
|
||||
int alink_start(void);
|
||||
|
||||
#define ALINK_WAIT_FOREVER (0)
|
||||
|
||||
/**
|
||||
* Waiting alink connect to aliyun server
|
||||
*
|
||||
* @param[in] timeout_ms time in milliseconds, use ALINK_WAIT_FOREVER to wait until server is connected
|
||||
*
|
||||
* @return 0 when connect to server successfully, otherwise -1 will return
|
||||
*/
|
||||
int alink_wait_connect(int timeout_ms);
|
||||
|
||||
/**
|
||||
* Destroy alink service and free resources
|
||||
*
|
||||
* @note this func will block at most 15 seconds to stop all alink related process(thread)
|
||||
*
|
||||
* @return 0 on success, otherwise -1 will return
|
||||
*/
|
||||
int alink_end(void);
|
||||
|
||||
/**
|
||||
* Reset user account binding.
|
||||
*
|
||||
* @return 0 on success, -1 when params invalid
|
||||
*/
|
||||
int alink_factory_reset(void);
|
||||
|
||||
/**
|
||||
* Report alink message, it is a fundamental func.
|
||||
*
|
||||
* @note when connection with server is unstable, this func will block until got response from server or timeout.
|
||||
*
|
||||
* @param[in] method alink protocol method, i.e. "postDeviceRawData", "retrieveDeviceData".
|
||||
* @param[in] json_buffer json format buffer, like {"OnOff":"1", "Light":"80"}.
|
||||
*
|
||||
* @return 0 when successfully got response from cloud,
|
||||
* otherwise this func will block until timeout and -1 will return
|
||||
*/
|
||||
int alink_report(const char *method, const char *json_buffer);
|
||||
int alink_report_async(const char *method, const char *json_buffer,
|
||||
void *(*cb)(void *), void *arg);
|
||||
|
||||
int alink_report_rawdata(const char *rawdata, int len);
|
||||
|
||||
enum ALINK_WIFI_CALLBACK {
|
||||
/*
|
||||
* void callback_cloud_connected(void)
|
||||
* @n@n called each time when gateway successfully connect(or reconnect)
|
||||
* to aliyun server
|
||||
*/
|
||||
ALINK_CLOUD_CONNECTED = 0,
|
||||
|
||||
/*
|
||||
* void callback_cloud_disconnected(void)
|
||||
* @n@n called each time when gateway lose connection with aliyun server
|
||||
*/
|
||||
ALINK_CLOUD_DISCONNECTED,
|
||||
/*
|
||||
* int callback_read_device_status(const char *params)
|
||||
* @n@nuccessfully
|
||||
*/
|
||||
ALINK_GET_DEVICE_STATUS,
|
||||
|
||||
/*
|
||||
* void callback_write_device_status(const char *params)
|
||||
*/
|
||||
ALINK_SET_DEVICE_STATUS,
|
||||
/*
|
||||
* int callback_read_device_rawdata(const char *params)
|
||||
* @n@nuccessfully
|
||||
*/
|
||||
ALINK_GET_DEVICE_RAWDATA,
|
||||
|
||||
/*
|
||||
* void callback_write_device_rawdata(const char *params)
|
||||
*/
|
||||
ALINK_SET_DEVICE_RAWDATA,
|
||||
};
|
||||
|
||||
int awss_register_callback(unsigned char cb_type, void *cb_func);
|
||||
|
||||
/**
|
||||
* Register misc callback
|
||||
*
|
||||
* @param[in] cb_type callback type.
|
||||
* @param[in] cb_func callback func pointer, func declaration see related comments.
|
||||
*
|
||||
* @return 0 on success, otherwise -1 will return
|
||||
*/
|
||||
int alink_register_callback(unsigned char cb_type, void *cb_func);
|
||||
|
||||
/**
|
||||
* Start awss service, block method, block until awss succeed, or timeout(see Note).
|
||||
*
|
||||
* @note platform_awss_get_timeout_interval_ms() return monitor timeout interval,
|
||||
* AP connection timeout is 30s.
|
||||
*
|
||||
* @return 0 on success, otherwise non-zero value will return
|
||||
* = 0: connect AP & DHCP success
|
||||
* = -1: get ssid & passwd fail
|
||||
* = -2: connect AP / DHCP fail
|
||||
*/
|
||||
int awss_start(void);
|
||||
|
||||
/**
|
||||
* Calling this func force awss_start exit.
|
||||
*
|
||||
* @return 0 on success, otherwise -1 will return
|
||||
*/
|
||||
int awss_stop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_ALINK_H */
|
||||
|
||||
62
Living_SDK/include/aos/aos.h
Normal file
62
Living_SDK/include/aos/aos.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_AOS_H
|
||||
#define AOS_AOS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <aos/types.h>
|
||||
#include <aos/cli.h>
|
||||
#include <aos/cloud.h>
|
||||
#include <aos/debug.h>
|
||||
#include <aos/kernel.h>
|
||||
#include <aos/kv.h>
|
||||
#include <aos/list.h>
|
||||
#include <aos/log.h>
|
||||
#include <aos/vfs.h>
|
||||
#include <aos/version.h>
|
||||
#include <aos/yloop.h>
|
||||
#include <aos/errno.h>
|
||||
#include <aos/init.h>
|
||||
|
||||
/*
|
||||
#include <aos/alink.h>
|
||||
#include <aos/network.h>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Transmit data on a UART interface
|
||||
*
|
||||
* @param data pointer to the start of data
|
||||
* @param size number of bytes to transmit
|
||||
* @param timeout time to wait
|
||||
*
|
||||
* @return 0 success, EIO if an error occurred with any step
|
||||
*/
|
||||
int32_t aos_uart_send(void *data, uint32_t size, uint32_t timeout);
|
||||
|
||||
|
||||
/**
|
||||
* Recv data on a UART interface
|
||||
*
|
||||
* @param data pointer to the start of recv buf
|
||||
* @param expect_size number of bytes expect to recv
|
||||
* @param recv_size number of bytes trully received
|
||||
* @param timeout time to wait
|
||||
*
|
||||
* @return 0 success, EIO if an error occurred with any step
|
||||
*/
|
||||
int32_t aos_uart_recv(void *data, uint32_t expect_size, uint32_t *recv_size, uint32_t timeout);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_AOS_H */
|
||||
|
||||
195
Living_SDK/include/aos/cli.h
Normal file
195
Living_SDK/include/aos/cli.h
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_CLI_H
|
||||
#define AOS_CLI_H
|
||||
|
||||
#ifndef AOS_CLI_MINI_SIZE
|
||||
#define AOS_CLI_MINI_SIZE 0
|
||||
#endif
|
||||
|
||||
#if(AOS_CLI_MINI_SIZE > 0)
|
||||
|
||||
/*can config to cut mem size*/
|
||||
#define INBUF_SIZE 256
|
||||
#define OUTBUF_SIZE 200 /*not use now*/
|
||||
#define MAX_COMMANDS 32
|
||||
|
||||
#define CLI_MAX_ARG_NUM 8
|
||||
#define CLI_MAX_ONCECMD_NUM 1
|
||||
|
||||
#else
|
||||
/*can config to cut mem size*/
|
||||
#define MAX_COMMANDS 64
|
||||
#define INBUF_SIZE 256
|
||||
#define OUTBUF_SIZE 2048
|
||||
|
||||
#define CLI_MAX_ARG_NUM 16
|
||||
#define CLI_MAX_ONCECMD_NUM 6
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef FUNCPTR
|
||||
typedef void (*FUNCPTR)(void);
|
||||
#endif
|
||||
|
||||
/* Structure for registering CLI commands */
|
||||
struct cli_command {
|
||||
const char *name;
|
||||
const char *help;
|
||||
|
||||
void (*function)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
};
|
||||
|
||||
struct cli_st {
|
||||
int initialized;
|
||||
int echo_disabled;
|
||||
|
||||
const struct cli_command *commands[MAX_COMMANDS];
|
||||
|
||||
unsigned int num_commands;
|
||||
unsigned int bp; /* buffer pointer */
|
||||
|
||||
char inbuf[INBUF_SIZE];
|
||||
char *outbuf;
|
||||
#if(AOS_CLI_MINI_SIZE <= 0)
|
||||
int his_idx;
|
||||
int his_cur;
|
||||
char history[INBUF_SIZE];
|
||||
#endif
|
||||
};
|
||||
|
||||
#define CLI_ARGS char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv
|
||||
|
||||
#ifdef CONFIG_AOS_CLI
|
||||
|
||||
#define cmd_printf(...) \
|
||||
do { \
|
||||
if (xWriteBufferLen > 0) { \
|
||||
snprintf(pcWriteBuffer, xWriteBufferLen, __VA_ARGS__); \
|
||||
xWriteBufferLen-= os_strlen(pcWriteBuffer); \
|
||||
pcWriteBuffer+= os_strlen(pcWriteBuffer); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
/**
|
||||
* This function registers a command with the command-line interface.
|
||||
*
|
||||
* @param[in] command The structure to register one CLI command
|
||||
*
|
||||
* @return 0 on success, error code otherwise.
|
||||
*/
|
||||
int aos_cli_register_command(const struct cli_command *command);
|
||||
|
||||
/**
|
||||
* This function unregisters a command from the command-line interface.
|
||||
*
|
||||
* @param[in] command The structure to unregister one CLI command
|
||||
*
|
||||
* @return 0 on success, error code otherwise.
|
||||
*/
|
||||
int aos_cli_unregister_command(const struct cli_command *command);
|
||||
|
||||
/**
|
||||
* Register a batch of CLI commands
|
||||
* Often, a module will want to register several commands.
|
||||
*
|
||||
* @param[in] commands Pointer to an array of commands.
|
||||
* @param[in] num_commands Number of commands in the array.
|
||||
*
|
||||
* @return 0 on success, error code otherwise.
|
||||
*/
|
||||
int aos_cli_register_commands(const struct cli_command *commands, int num_commands);
|
||||
|
||||
/**
|
||||
* Unregister a batch of CLI commands
|
||||
*
|
||||
* @param[in] commands Pointer to an array of commands.
|
||||
* @param[in] num_commands Number of commands in the array.
|
||||
*
|
||||
* @return 0 on success, error code otherwise.
|
||||
*/
|
||||
int aos_cli_unregister_commands(const struct cli_command *commands, int num_commands);
|
||||
|
||||
/**
|
||||
* Print CLI msg
|
||||
*
|
||||
* @param[in] buff Pointer to a char * buffer.
|
||||
*
|
||||
* @return 0 on success, error code otherwise.
|
||||
*/
|
||||
#if defined BUILD_BIN || defined BUILD_KERNEL
|
||||
/* SINGLEBIN or KERNEL */
|
||||
int aos_cli_printf(const char *buff, ...);
|
||||
#else
|
||||
/* FRAMWORK or APP */
|
||||
#define aos_cli_printf(fmt, ...) csp_printf("%s" fmt, aos_cli_get_tag(), ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CLI initial function
|
||||
*
|
||||
* @return 0 on success, error code otherwise
|
||||
*/
|
||||
int aos_cli_init(void);
|
||||
|
||||
/**
|
||||
* Stop the CLI thread and carry out the cleanup
|
||||
*
|
||||
* @return 0 on success, error code otherwise.
|
||||
*
|
||||
*/
|
||||
int aos_cli_stop(void);
|
||||
|
||||
/**
|
||||
* CLI get tag string
|
||||
*
|
||||
* @return cli tag storing buffer
|
||||
*/
|
||||
const char *aos_cli_get_tag(void);
|
||||
|
||||
#else /* CONFIG_AOS_CLI */
|
||||
#include "k_types.h"
|
||||
|
||||
#define cmd_printf(...) do {} while(0)
|
||||
|
||||
RHINO_INLINE int aos_cli_register_command(const struct cli_command *command)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
RHINO_INLINE int aos_cli_unregister_command(const struct cli_command *command)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
RHINO_INLINE int aos_cli_register_commands(const struct cli_command *commands,
|
||||
int num_commands)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
RHINO_INLINE int aos_cli_unregister_commands(const struct cli_command *commands,
|
||||
int num_commands)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define aos_cli_printf csp_printf
|
||||
|
||||
RHINO_INLINE int aos_cli_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
RHINO_INLINE int aos_cli_stop(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_CLI_H */
|
||||
|
||||
65
Living_SDK/include/aos/cloud.h
Normal file
65
Living_SDK/include/aos/cloud.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_CLOUD_H
|
||||
#define AOS_CLOUD_H
|
||||
|
||||
enum {
|
||||
CLOUD_CONNECTED,
|
||||
CLOUD_DISCONNECTED,
|
||||
GET_DEVICE_STATUS,
|
||||
SET_DEVICE_STATUS,
|
||||
GET_DEVICE_RAWDATA,
|
||||
SET_DEVICE_RAWDATA,
|
||||
UPGRADE_DEVICE,
|
||||
CANCEL_UPGRADE_DEVICE,
|
||||
GET_SUB_DEVICE_STATUS,
|
||||
SET_SUB_DEVICE_STATUS,
|
||||
MAX_EVENT_TYPE,
|
||||
};
|
||||
|
||||
typedef void (*aos_cloud_cb_t)(int event, const char *json_buffer);
|
||||
|
||||
/**
|
||||
* Register cloud event callback.
|
||||
*
|
||||
* @param[in] cb_type event type interested.
|
||||
* @param[in] cb cloud event callback.
|
||||
*
|
||||
* @return the operation status, 0 is OK, others is error.
|
||||
*/
|
||||
int aos_cloud_register_callback(int cb_type, aos_cloud_cb_t cb);
|
||||
|
||||
/**
|
||||
* Report event to cloud.
|
||||
*
|
||||
* @param[in] method remote method name.
|
||||
* @param[in] json_buffer method's payload.
|
||||
* @param[in] done_cb report done callback.
|
||||
* @param[in] arg private data passed to done_cb.
|
||||
*
|
||||
* @return the operation status, 0 is OK, others is error.
|
||||
*/
|
||||
int aos_cloud_report(const char *method,
|
||||
const char *json_buffer,
|
||||
void (*done_cb)(void *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Trigger specific event, used by Cloud Backend.
|
||||
*
|
||||
* @param[in] cb_type event type.
|
||||
* @param[in] json_buffer payload.
|
||||
*/
|
||||
void aos_cloud_trigger(int cb_type, const char *json_buffer);
|
||||
|
||||
/**
|
||||
* Register Cloud Backend.
|
||||
*
|
||||
* @param[in] report called when user do aos_cloud_report.
|
||||
*/
|
||||
void aos_cloud_register_backend(int (*report)(const char *method, const char *json_buffer));
|
||||
|
||||
#endif /* AOS_CLOUD_H */
|
||||
|
||||
301
Living_SDK/include/aos/debug.h
Normal file
301
Living_SDK/include/aos/debug.h
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_DEBUG_H
|
||||
#define AOS_DEBUG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SHORT_FILE __FILENAME__
|
||||
|
||||
#define debug_print_assert(A,B,C,D,E,F)
|
||||
|
||||
#if (!defined(unlikely))
|
||||
#define unlikely(EXPRESSSION) !!(EXPRESSSION)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check that an expression is true (non-zero).
|
||||
* If expression evalulates to false, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.) using the default debugging output method.
|
||||
*
|
||||
* @param[in] X expression to be evaluated.
|
||||
*/
|
||||
#if (!defined(check))
|
||||
#define check(X) \
|
||||
do { \
|
||||
if (unlikely(!(X))) { \
|
||||
debug_print_assert(0, #X, NULL, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__); \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check that an expression is true (non-zero) with an explanation.
|
||||
* If expression evalulates to false, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.) using the default debugging output method.
|
||||
*
|
||||
* @param[in] X expression to be evaluated.
|
||||
* @param[in] STR If the expression evaluate to false, custom string to print.
|
||||
*/
|
||||
#if (!defined(check_string))
|
||||
#define check_string(X, STR) \
|
||||
do { \
|
||||
if (unlikely(!(X))) { \
|
||||
debug_print_assert(0, #X, STR, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__); \
|
||||
AOS_ASSERTION_FAIL_ACTION(); \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Requires that an expression evaluate to true.
|
||||
* If expression evalulates to false, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.) using the default debugging output method then jumps to a label.
|
||||
*
|
||||
* @param[in] X expression to be evalulated.
|
||||
* @param[in] LABEL if expression evaluate to false,jumps to the LABEL.
|
||||
*/
|
||||
#if (!defined(require))
|
||||
#define require(X, LABEL) \
|
||||
do { \
|
||||
if (unlikely(!(X))) { \
|
||||
debug_print_assert( 0, #X, NULL, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__ ); \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Requires that an expression evaluate to true with an explanation.
|
||||
* If expression evalulates to false, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.) and a custom explanation string using the default debugging output method then jumps to a label.
|
||||
*
|
||||
* @param[in] X expression to be evalulated.
|
||||
* @param[in] LABEL if expression evaluate to false,jumps to the LABEL.
|
||||
* @param[in] STR if expression evaluate to false,custom explanation string to print.
|
||||
*/
|
||||
#if (!defined(require_string))
|
||||
#define require_string(X, LABEL, STR) \
|
||||
do { \
|
||||
if (unlikely(!(X))) { \
|
||||
debug_print_assert(0, #X, STR, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__); \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Requires that an expression evaluate to true.
|
||||
* If expression evalulates to false, this jumps to a label. No debugging information is printed.
|
||||
*
|
||||
* @param[in] X expression to be evalulated
|
||||
* @param[in] LABEL if expression evaluate to false,jumps to the LABEL.
|
||||
*/
|
||||
#if (!defined(require_quiet))
|
||||
#define require_quiet(X, LABEL) \
|
||||
do { \
|
||||
if (unlikely(!(X))) { \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Require that an error code is noErr (0).
|
||||
* If the error code is non-0, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.) using the default debugging output method then jumps to a label.
|
||||
*
|
||||
* @param[in] ERR error to be evaluated
|
||||
* @param[in] LABEL If the error code is non-0,jumps to the LABEL.
|
||||
*/
|
||||
#if (!defined(require_noerr))
|
||||
#define require_noerr(ERR, LABEL) \
|
||||
do { \
|
||||
int localErr; \
|
||||
\
|
||||
localErr = (int)(ERR); \
|
||||
if (unlikely(localErr != 0)) { \
|
||||
debug_print_assert(localErr, NULL, NULL, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__); \
|
||||
goto LABEL; \
|
||||
} \
|
||||
\
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Require that an error code is noErr (0) with an explanation.
|
||||
* If the error code is non-0, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.), and a custom explanation string using the default debugging output method using the
|
||||
* default debugging output method then jumps to a label.
|
||||
*
|
||||
* @param[in] ERR error to be evaluated
|
||||
* @param[in] LABEL If the error code is non-0, jumps to the LABEL.
|
||||
* @param[in] STR If the error code is non-0, custom explanation string to print
|
||||
*/
|
||||
#if (!defined(require_noerr_string))
|
||||
#define require_noerr_string(ERR, LABEL, STR) \
|
||||
do { \
|
||||
int localErr; \
|
||||
\
|
||||
localErr = (int)(ERR); \
|
||||
if (unlikely(localErr != 0)) { \
|
||||
debug_print_assert(localErr, NULL, STR, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__); \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Require that an error code is noErr (0) with an explanation and action to execute otherwise.
|
||||
* If the error code is non-0, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.), and a custom explanation string using the default debugging output method using the
|
||||
* default debugging output method then executes an action and jumps to a label.
|
||||
*
|
||||
* @param[in] ERR error to be evaluated.
|
||||
* @param[in] LABEL If the error code is non-0, jumps to the LABEL.
|
||||
* @param[in] ACTION If the error code is non-0, custom code to executes.
|
||||
* @param[in] STR If the error code is non-0, custom explanation string to print.
|
||||
*/
|
||||
#if (!defined(require_noerr_action_string))
|
||||
#define require_noerr_action_string(ERR, LABEL, ACTION, STR) \
|
||||
do { \
|
||||
int localErr; \
|
||||
\
|
||||
localErr = (int)(ERR); \
|
||||
if (unlikely(localErr != 0)) { \
|
||||
debug_print_assert(localErr, NULL, STR, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__); \
|
||||
{ ACTION; } \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Require that an error code is noErr (0).
|
||||
* If the error code is non-0, this jumps to a label. No debugging information is printed.
|
||||
*
|
||||
* @param[in] ERR error to be evaluated.
|
||||
* @param[in] LABEL If the error code is non-0, jumps to the LABEL.
|
||||
*/
|
||||
#if (!defined(require_noerr_quiet))
|
||||
#define require_noerr_quiet(ERR, LABEL) \
|
||||
do { \
|
||||
if (unlikely((ERR) != 0)) { \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Require that an error code is noErr (0) with an action to execute otherwise.
|
||||
* If the error code is non-0, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.) using the default debugging output method then executes an action and jumps to a label.
|
||||
*
|
||||
* @param[in] ERR error to be evaluated.
|
||||
* @param[in] LABEL If the error code is non-0, jumps to the LABEL.
|
||||
* @param[in] ACTION If the error code is non-0, custom code to executes.
|
||||
*/
|
||||
#if (!defined(require_noerr_action))
|
||||
#define require_noerr_action(ERR, LABEL, ACTION) \
|
||||
do { \
|
||||
int localErr; \
|
||||
\
|
||||
localErr = (int)(ERR); \
|
||||
if (unlikely(localErr != 0)) { \
|
||||
debug_print_assert(localErr, NULL, NULL, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__); \
|
||||
{ ACTION; } \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Require that an error code is noErr (0) with an action to execute otherwise.
|
||||
* If the error code is non-0, this executes an action and jumps to a label. No debugging information is printed.
|
||||
*
|
||||
* @param[in] ERR error to be evaluated.
|
||||
* @param[in] LABEL If the error code is non-0, jumps to the LABEL.
|
||||
* @param[in] ACTION If the error code is non-0, custom code to executes.
|
||||
*/
|
||||
#if (!defined(require_noerr_action_quiet))
|
||||
#define require_noerr_action_quiet(ERR, LABEL, ACTION) \
|
||||
do { \
|
||||
if (unlikely((ERR) != 0)) { \
|
||||
{ ACTION; } \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Requires that an expression evaluate to true with an action to execute otherwise.
|
||||
* If expression evalulates to false, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.) using the default debugging output method then executes an action and jumps to a label.
|
||||
*
|
||||
* @param[in] X expression to be evaluated.
|
||||
* @param[in] LABEL If the expression evaluate to false, jumps to the LABEL.
|
||||
* @param[in] ACTION If the expression evaluate to false, custom code to executes.
|
||||
*/
|
||||
#if (!defined(require_action))
|
||||
#define require_action(X, LABEL, ACTION) \
|
||||
do { \
|
||||
if (unlikely(!(X))) { \
|
||||
debug_print_assert(0, #X, NULL, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__); \
|
||||
{ ACTION; } \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while (1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Requires that an expression evaluate to true with an explanation and action to execute otherwise.
|
||||
* If expression evalulates to false, this prints debugging information (actual expression string, file, line number,
|
||||
* function name, etc.) and a custom explanation string using the default debugging output method then executes an
|
||||
* action and jumps to a label.
|
||||
*
|
||||
* @param[in] X expression to be evaluated.
|
||||
* @param[in] LABEL If the expression evaluate to false, jumps to the LABEL.
|
||||
* @param[in] ACTION If the expression evaluate to false, custom code to executes.
|
||||
* @param[in] STR If the expression evaluate to false, custom string to print.
|
||||
*/
|
||||
#if (!defined(require_action_string))
|
||||
#define require_action_string(X, LABEL, ACTION, STR) \
|
||||
do { \
|
||||
if (unlikely(!(X))) { \
|
||||
debug_print_assert(0, #X, STR, SHORT_FILE, __LINE__, __PRETTY_FUNCTION__); \
|
||||
{ ACTION; } \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while (1 == 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Requires that an expression evaluate to true with an action to execute otherwise.
|
||||
* If expression evalulates to false, this executes an action and jumps to a label.
|
||||
* No debugging information is printed.
|
||||
*
|
||||
* @param[in] X expression to be evaluated.
|
||||
* @param[in] LABEL If the expression evaluate to false, jumps to the LABEL.
|
||||
* @param[in] ACTION If the expression evaluate to false, custom code to executes.
|
||||
*/
|
||||
#if (!defined(require_action_quiet))
|
||||
#define require_action_quiet(X, LABEL, ACTION) \
|
||||
do { \
|
||||
if (unlikely(!(X))) { \
|
||||
{ ACTION; } \
|
||||
goto LABEL; \
|
||||
} \
|
||||
\
|
||||
} while(1 == 0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_DEBUG_H */
|
||||
|
||||
207
Living_SDK/include/aos/errno.h
Normal file
207
Living_SDK/include/aos/errno.h
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_ERRNO_H
|
||||
#define AOS_ERRNO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__)&&!defined(__CC_ARM)
|
||||
#include <errno.h>
|
||||
#else
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Arg list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#ifdef ENOMEM
|
||||
#undef ENOMEM
|
||||
#endif
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#ifdef EINVAL
|
||||
#undef EINVAL
|
||||
#endif
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#ifdef EDOM
|
||||
#undef EDOM
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#endif
|
||||
#ifdef ERANGE
|
||||
#undef ERANGE
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
#endif
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
|
||||
#define EDEADLOCK EDEADLK
|
||||
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#ifdef EILSEQ
|
||||
#undef EILSEQ
|
||||
#endif
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale NFS file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
|
||||
|
||||
#define ENSROK 0 /* DNS server returned answer with no data */
|
||||
#define ENSRNODATA 160 /* DNS server returned answer with no data */
|
||||
#define ENSRFORMERR 161 /* DNS server claims query was misformatted */
|
||||
#define ENSRSERVFAIL 162 /* DNS server returned general failure */
|
||||
#define ENSRNOTFOUND 163 /* Domain name not found */
|
||||
#define ENSRNOTIMP 164 /* DNS server does not implement requested operation */
|
||||
#define ENSRREFUSED 165 /* DNS server refused query */
|
||||
#define ENSRBADQUERY 166 /* Misformatted DNS query */
|
||||
#define ENSRBADNAME 167 /* Misformatted domain name */
|
||||
#define ENSRBADFAMILY 168 /* Unsupported address family */
|
||||
#define ENSRBADRESP 169 /* Misformatted DNS reply */
|
||||
#define ENSRCONNREFUSED 170 /* Could not contact DNS servers */
|
||||
#define ENSRTIMEOUT 171 /* Timeout while contacting DNS servers */
|
||||
#define ENSROF 172 /* End of file */
|
||||
#define ENSRFILE 173 /* Error reading file */
|
||||
#define ENSRNOMEM 174 /* Out of memory */
|
||||
#define ENSRDESTRUCTION 175 /* Application terminated lookup */
|
||||
#define ENSRQUERYDOMAINTOOLONG 176 /* Domain name is too long */
|
||||
#define ENSRCNAMELOOP 177 /* Domain name is too long */
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Redefine the errno, Only use in framework/app
|
||||
*
|
||||
*/
|
||||
#ifdef BUILD_BIN
|
||||
|
||||
#undef set_errno
|
||||
#define set_errno(err) do { if (err) { errno = (err); } } while(0)
|
||||
|
||||
|
||||
#else
|
||||
#ifdef BUILD_APP
|
||||
extern int get_errno(void);
|
||||
extern void set_errno(int err);
|
||||
|
||||
#undef errno
|
||||
#define errno get_errno()
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_ERRNO_H */
|
||||
|
||||
70
Living_SDK/include/aos/init.h
Normal file
70
Living_SDK/include/aos/init.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_INIT_H
|
||||
#define AOS_INIT_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
bool cli_enable;
|
||||
} kinit_t;
|
||||
|
||||
extern int aos_kernel_init(kinit_t *kinit);
|
||||
|
||||
#ifdef AOS_BINS
|
||||
#include <k_api.h>
|
||||
struct app_info_t {
|
||||
void (*app_entry)(void *ksyscall_tbl, void *fsyscall_tbl, int argc, char *argv[]);
|
||||
unsigned int data_ram_start;
|
||||
unsigned int data_ram_end;
|
||||
unsigned int data_flash_begin;
|
||||
unsigned int bss_start;
|
||||
unsigned int bss_end;
|
||||
unsigned int heap_start;
|
||||
unsigned int heap_end;
|
||||
};
|
||||
|
||||
struct framework_info_t {
|
||||
void (*framework_entry)(void *syscall_tbl, int argc, char *argv[]);
|
||||
unsigned int data_ram_start;
|
||||
unsigned int data_ram_end;
|
||||
unsigned int data_flash_begin;
|
||||
unsigned int bss_start;
|
||||
unsigned int bss_end;
|
||||
unsigned int heap_start;
|
||||
unsigned int heap_end;
|
||||
};
|
||||
|
||||
struct m_app_info_t {
|
||||
void (*app_entry)(void *ksyscall_tbl, int argc, char *argv[]);
|
||||
unsigned int data_ram_start;
|
||||
unsigned int data_ram_end;
|
||||
unsigned int data_flash_begin;
|
||||
unsigned int bss_start;
|
||||
unsigned int bss_end;
|
||||
unsigned int heap_start;
|
||||
unsigned int heap_end;
|
||||
/* reserve for other */
|
||||
unsigned int reserve0;
|
||||
unsigned int reserve1;
|
||||
/* this bin_type must be here, 0x28, uniform with single bin & kernel bin,
|
||||
arm cortex not used */
|
||||
unsigned int bin_type;
|
||||
unsigned int reserve2;
|
||||
unsigned int reserve3;
|
||||
unsigned int reserve4;
|
||||
unsigned int reserve5;
|
||||
unsigned int reserve6;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* AOS_INIT_H */
|
||||
|
||||
155
Living_SDK/include/aos/internal/event_type_code.h
Normal file
155
Living_SDK/include/aos/internal/event_type_code.h
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_EVENT_TYPE_CODE_API_H
|
||||
#define AOS_EVENT_TYPE_CODE_API_H
|
||||
|
||||
/* remote procedure call */
|
||||
#define EV_RPC 0x0100
|
||||
|
||||
/* YunIO event */
|
||||
#define EV_YUNIO 0x0101
|
||||
#define CODE_YUNIO_CMD_START 1
|
||||
#define CODE_YUNIO_CMD_RETRY 2
|
||||
#define CODE_YUNIO_CMD_DISCONNECT 3
|
||||
#define CODE_YUNIO_ON_CONNECTED 4
|
||||
#define CODE_YUNIO_ON_DISCONNECTED 5
|
||||
#define CODE_YUNIO_ON_CONNECT_FAILED 6
|
||||
#define CODE_YUNIO_ON_READ_ERROR 7
|
||||
#define CODE_YUNIO_ON_WRITE_ERROR 8
|
||||
#define CODE_YUNIO_ON_HEARTBIT_ERROR 9
|
||||
#define CODE_YUNIO_PUBLISH_SUCCESS 10
|
||||
#define CODE_YUNIO_PUBLISH_TIMEOUT 11
|
||||
|
||||
/** OTA event define */
|
||||
#define EV_OTA 0x0102
|
||||
#define CODE_OTA_ON_RESULT 1
|
||||
|
||||
/** register device service */
|
||||
#define EV_DEVICE_REGISTER 0x0103
|
||||
#define CODE_REGISTER_ON_RESULT 1
|
||||
#define VALUE_REGISTER_SUCCESS 0
|
||||
|
||||
/** id2 device activate */
|
||||
#define EV_ACTIVATE_ID2 0x0104
|
||||
#define CODE_ACTIVATE_ID2_ON_RESULT 1
|
||||
#define VALUE_ACTIVATE_ID2_SUCCESS 0
|
||||
#define VALUE_ACTIVATE_ID2_FAILURE 1
|
||||
|
||||
#define EV_DDA 0x0105
|
||||
#define CODE_DDA_ON_CONNECTED 1
|
||||
|
||||
#define EV_BZ_COMBO 0x0106
|
||||
#define CODE_COMBO_AP_INFO_READY 1
|
||||
|
||||
/** General key define */
|
||||
#define EV_KEY 0x0201
|
||||
#define CODE_RECORD 1
|
||||
#define CODE_VOLUME 2 /* Reserve */
|
||||
#define CODE_VOLUME_INC 3
|
||||
#define CODE_VOLUME_DEC 4
|
||||
#define CODE_PLAY_PAUSE 5
|
||||
#define CODE_MUTE 6
|
||||
#define CODE_CHANNEL 7
|
||||
#define CODE_NEXT 8
|
||||
#define CODE_RECORD_PRE 9
|
||||
#define CODE_RESET 0x1001
|
||||
#define CODE_STATUS 11
|
||||
#define CODE_ELINK 12
|
||||
#define CODE_BOOT 13
|
||||
/** General key value */
|
||||
#define VALUE_KEY_UP 0
|
||||
#define VALUE_KEY_DOWN 1
|
||||
#define VALUE_KEY_CLICK 2
|
||||
#define VALUE_KEY_LTCLICK 3
|
||||
#define VALUE_KEY_LLTCLICK 4
|
||||
#define VALUE_KEY_DBCLICK 5
|
||||
/** General channel value */
|
||||
#define VALUE_SYS_CHN_CONNECTED 0
|
||||
#define VALUE_SYS_CHN_CONNECTING 1
|
||||
#define VALUE_SYS_CHN_DISCONNECTED 2
|
||||
|
||||
/** Reserve event */
|
||||
#define EV_KNOD 0x0203
|
||||
|
||||
/** SD card event */
|
||||
#define EV_SD 0x0204
|
||||
#define CODE_SD_PLUG 1
|
||||
#define VALUE_SD_OUT 0
|
||||
#define VALUE_SD_IN 1
|
||||
|
||||
/** LAN Driver event */
|
||||
#define EV_LAN 0x0205
|
||||
#define VALUE_LAN_OUT 0
|
||||
#define VALUE_LAN_IN 1
|
||||
|
||||
/** Net event define */
|
||||
#define EV_NET 0x0206
|
||||
#define CODE_NET_DHCP_START 1
|
||||
#define CODE_NET_DHCP_RESULT 2
|
||||
#define CODE_NET_IP_STATIC 3
|
||||
#define CODE_NET_STATUS 4
|
||||
#define VALUE_NET_LAN_OK 0x01
|
||||
#define VALUE_NET_WIFI_OK 0x02
|
||||
|
||||
/** Usb driver event */
|
||||
#define EV_USB 0x0207
|
||||
#define VALUE_USB_OUT 0
|
||||
#define VALUE_USB_IN 1
|
||||
|
||||
/** PM event */
|
||||
#define EV_PM 0x0208
|
||||
#define CODE_PM_ENTER_INFORM 1
|
||||
#define CODE_PM_ENTER 2
|
||||
#define CODE_PM_DONE 3
|
||||
#define CODE_PM_QUIT 4
|
||||
#define CODE_PM_SHUTDOWN_INFORM 5
|
||||
#define CODE_PM_STARTUP_INFORM 6
|
||||
#define CODE_PM_LOWPOWER_INFORM 7
|
||||
#define CODE_PM_POWERRECOVER_INFORM 8
|
||||
#define CODE_PM_START_HEARTBEAT_INFORM 9
|
||||
#define CODE_PM_STOP_HEARTBEAT_INFORM 10
|
||||
#define VALUE_PM_IDLE_INFORM 1
|
||||
#define VALUE_PM_POWERBUTTON_INFORM 2
|
||||
|
||||
/** File system event */
|
||||
#define EV_FS 0x0209
|
||||
#define CODE_FSYS_SD_LOAD 1
|
||||
#define CODE_FSYS_UDISK_LOAD 2
|
||||
#define CODE_FSYS_FLASH_LOAD 3
|
||||
#define CODE_FSYS_SD_SPACE 4
|
||||
#define CODE_FSYS_UDISK_SPACE 5
|
||||
#define CODE_FSYS_FLASH_SPACE 6
|
||||
|
||||
/** Bluetooth */
|
||||
#define EV_BT 0x020A
|
||||
#define CODE_BT_DEVICE_CONNECT 1
|
||||
#define CODE_BT_DEVICE_DISCONNECT 2
|
||||
#define CODE_BT_MODE_ON 3
|
||||
#define CODE_BT_MODE_OFF 4
|
||||
|
||||
/** DLNA */
|
||||
#define EV_DLNA 0x020B
|
||||
#define CODE_DLNA_DEVICE_CONNECT 1
|
||||
#define CODE_DLNA_DEVICE_DISCONNECT 2
|
||||
#define CODE_DLNA_MODE_ON 3
|
||||
#define CODE_DLNA_MODE_OFF 4
|
||||
|
||||
/** AIRPLAY */
|
||||
#define EV_AIRPLAY 0x020C
|
||||
#define CODE_AIRPLAY_DEVICE_CONNECT 1
|
||||
#define CODE_AIRPLAY_DEVICE_DISCONNECT 2
|
||||
#define CODE_AIRPLAY_MODE_ON 3
|
||||
#define CODE_AIRPLAY_MODE_OFF 4
|
||||
|
||||
/** AT */
|
||||
#define EV_AT 0x020D
|
||||
#define CODE_AT_IF_READY 1
|
||||
#define CODE_AT_IF_DISAPPEAR 2
|
||||
|
||||
/** AT */
|
||||
#define EV_BLE 0x020E
|
||||
#define CODE_BLE_TX_COMPLETED 1
|
||||
#endif /* AOS_EVENT_TYPE_CODE_API_H */
|
||||
|
||||
138
Living_SDK/include/aos/internal/log_impl.h
Normal file
138
Living_SDK/include/aos/internal/log_impl.h
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_LOG_IMPL_H
|
||||
#define AOS_LOG_IMPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern unsigned int aos_log_level;
|
||||
static inline unsigned int aos_log_get_level(void)
|
||||
{
|
||||
return aos_log_level;
|
||||
}
|
||||
|
||||
enum log_level_bit {
|
||||
AOS_LL_V_NONE_BIT = -1,
|
||||
AOS_LL_V_FATAL_BIT,
|
||||
AOS_LL_V_ERROR_BIT,
|
||||
AOS_LL_V_WARN_BIT,
|
||||
AOS_LL_V_INFO_BIT,
|
||||
AOS_LL_V_DEBUG_BIT,
|
||||
AOS_LL_V_MAX_BIT
|
||||
};
|
||||
|
||||
#define AOS_LOG_LEVEL aos_log_get_level()
|
||||
|
||||
#define AOS_LL_V_NONE 0
|
||||
#define AOS_LL_V_ALL 0XFF
|
||||
#define AOS_LL_V_FATAL (1 << AOS_LL_V_FATAL_BIT)
|
||||
#define AOS_LL_V_ERROR (1 << AOS_LL_V_ERROR_BIT)
|
||||
#define AOS_LL_V_WARN (1 << AOS_LL_V_WARN_BIT)
|
||||
#define AOS_LL_V_INFO (1 << AOS_LL_V_INFO_BIT)
|
||||
#define AOS_LL_V_DEBUG (1 << AOS_LL_V_DEBUG_BIT)
|
||||
|
||||
/*
|
||||
* color def.
|
||||
* see http://stackoverflow.com/questions/3585846/color-text-in-terminal-applications-in-unix
|
||||
*/
|
||||
#define COL_DEF "\x1B[0m" /* white */
|
||||
#define COL_RED "\x1B[31m" /* red */
|
||||
#define COL_GRE "\x1B[32m" /* green */
|
||||
#define COL_BLU "\x1B[34m" /* blue */
|
||||
#define COL_YEL "\x1B[33m" /* yellow */
|
||||
#define COL_WHE "\x1B[37m" /* white */
|
||||
#define COL_CYN "\x1B[36m"
|
||||
#define COL_MAG "\x1B[35m"
|
||||
|
||||
#include <aos/kernel.h>
|
||||
extern int csp_printf(const char *fmt, ...);
|
||||
#ifdef CONFIG_LOGMACRO_DETAILS
|
||||
#define log_print(CON, MOD, COLOR, LVL, FMT, ...) \
|
||||
do { \
|
||||
if (AOS_LOG_LEVEL & CON) { \
|
||||
long long ms = aos_now_ms(); \
|
||||
csp_printf(COLOR " [%4d.%03d]<%s> %s [%s#%d] : ", (int)(ms/1000), (int)(ms%1000), LVL, MOD, __FUNCTION__, __LINE__); \
|
||||
csp_printf(FMT COL_DEF "\r\n", ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#if defined(LOG_SIMPLE)
|
||||
extern void log_print_simple(unsigned int log_level, const char *fmt, ...);
|
||||
#define log_print(CON, MOD, COLOR, LVL, FMT, ...) \
|
||||
do { \
|
||||
log_print_simple(CON, FMT, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
#else
|
||||
#define log_print(CON, MOD, COLOR, LVL, FMT, ...) \
|
||||
do { \
|
||||
if (AOS_LOG_LEVEL & CON) { \
|
||||
csp_printf("[%06d]<" LVL "> ", (unsigned)aos_now_ms()); \
|
||||
csp_printf(FMT, ##__VA_ARGS__); \
|
||||
csp_printf("\r\n"); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define void_func(fmt, ...)
|
||||
|
||||
#ifndef os_printf
|
||||
#ifndef csp_printf
|
||||
int csp_printf(const char *fmt, ...);
|
||||
#else
|
||||
extern int csp_printf(const char *fmt, ...);
|
||||
#endif
|
||||
#else
|
||||
extern int csp_printf(const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
#undef LOGF
|
||||
#undef LOGE
|
||||
#undef LOGW
|
||||
#undef LOGI
|
||||
#undef LOGD
|
||||
#undef LOG
|
||||
|
||||
#define LOG_IMPL(fmt, ...) \
|
||||
log_print(AOS_LL_V_ALL, "AOS", COL_DEF, "V", fmt, ##__VA_ARGS__)
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define CONFIG_LOGMACRO_SILENT
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define LOGD_IMPL(mod, fmt, ...) \
|
||||
log_print(AOS_LL_V_DEBUG, mod, COL_WHE, "D", fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define LOGD_IMPL(mod, fmt, ...) void_func(fmt, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOGMACRO_SILENT
|
||||
#define LOGF_IMPL(mod, fmt, ...) void_func(fmt, ##__VA_ARGS__)
|
||||
#define LOGE_IMPL(mod, fmt, ...) void_func(fmt, ##__VA_ARGS__)
|
||||
#define LOGW_IMPL(mod, fmt, ...) void_func(fmt, ##__VA_ARGS__)
|
||||
#define LOGI_IMPL(mod, fmt, ...) void_func(fmt, ##__VA_ARGS__)
|
||||
|
||||
#else
|
||||
|
||||
#define LOGF_IMPL(mod, fmt, ...) \
|
||||
log_print(AOS_LL_V_FATAL, mod, COL_RED, "F", fmt, ##__VA_ARGS__)
|
||||
#define LOGE_IMPL(mod, fmt, ...) \
|
||||
log_print(AOS_LL_V_ERROR, mod, COL_YEL, "E", fmt, ##__VA_ARGS__)
|
||||
#define LOGW_IMPL(mod, fmt, ...) \
|
||||
log_print(AOS_LL_V_WARN, mod, COL_BLU, "W", fmt, ##__VA_ARGS__)
|
||||
#define LOGI_IMPL(mod, fmt, ...) \
|
||||
log_print(AOS_LL_V_INFO, mod, COL_GRE, "I", fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif /* CONFIG_LOGMACRO_SILENT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_LOG_IMPL_H */
|
||||
|
||||
550
Living_SDK/include/aos/kernel.h
Normal file
550
Living_SDK/include/aos/kernel.h
Normal file
|
|
@ -0,0 +1,550 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_KERNEL_H
|
||||
#define AOS_KERNEL_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AOS_WAIT_FOREVER 0xffffffffu
|
||||
#define AOS_NO_WAIT 0x0
|
||||
#define AOS_DEFAULT_APP_PRI 32
|
||||
|
||||
typedef struct {
|
||||
void *hdl;
|
||||
} aos_hdl_t;
|
||||
|
||||
typedef aos_hdl_t aos_task_t;
|
||||
typedef aos_hdl_t aos_mutex_t;
|
||||
typedef aos_hdl_t aos_sem_t;
|
||||
typedef aos_hdl_t aos_queue_t;
|
||||
typedef aos_hdl_t aos_timer_t;
|
||||
typedef aos_hdl_t aos_work_t;
|
||||
typedef aos_hdl_t aos_event_t;
|
||||
|
||||
typedef struct {
|
||||
void *hdl;
|
||||
void *stk;
|
||||
} aos_workqueue_t;
|
||||
|
||||
typedef unsigned int aos_task_key_t;
|
||||
|
||||
/**
|
||||
* Reboot AliOS.
|
||||
*/
|
||||
void aos_reboot(void);
|
||||
|
||||
/**
|
||||
* Get HZ(ticks per second).
|
||||
*
|
||||
* @return RHINO_CONFIG_TICKS_PER_SECOND.
|
||||
*/
|
||||
int aos_get_hz(void);
|
||||
|
||||
/**
|
||||
* Get kernel version.
|
||||
*
|
||||
* @return SYSINFO_KERNEL_VERSION.
|
||||
*/
|
||||
const char *aos_version_get(void);
|
||||
|
||||
/**
|
||||
* Create a task.
|
||||
*
|
||||
* @param[in] name task name.
|
||||
* @param[in] fn function to run.
|
||||
* @param[in] arg argument of the function.
|
||||
* @param[in] stacksize stack-size in bytes.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_task_new(const char *name, void (*fn)(void *), void *arg, int stack_size);
|
||||
|
||||
/**
|
||||
* Create a task.
|
||||
*
|
||||
* @param[in] task handle.
|
||||
* @param[in] name task name.
|
||||
* @param[in] fn task function.
|
||||
* @param[in] arg argument of the function..
|
||||
* @param[in] stack_buf stack-buf: if stack_buf==NULL, provided by kernel.
|
||||
* @param[in] stack_size stack-size in bytes.
|
||||
* @param[in] prio priority value, the max is RHINO_CONFIG_USER_PRI_MAX(default 60).
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_task_new_ext(aos_task_t *task, const char *name, void (*fn)(void *), void *arg,
|
||||
int stack_size, int prio);
|
||||
|
||||
/**
|
||||
* Exit a task.
|
||||
*
|
||||
* @param[in] code not used now.
|
||||
*/
|
||||
void aos_task_exit(int code);
|
||||
|
||||
/**
|
||||
* Get task name.
|
||||
*
|
||||
* @return the name of the task
|
||||
*/
|
||||
const char *aos_task_name(void);
|
||||
|
||||
/**
|
||||
* Create a task key.
|
||||
*
|
||||
* @param[in] key pointer of key object.
|
||||
*
|
||||
* @return 0: success, -EINVAL: error.
|
||||
*/
|
||||
int aos_task_key_create(aos_task_key_t *key);
|
||||
|
||||
/**
|
||||
* Delete a task key.
|
||||
*
|
||||
* @param[in] key key object.
|
||||
*/
|
||||
void aos_task_key_delete(aos_task_key_t key);
|
||||
|
||||
/**
|
||||
* Associate a task-specific value with a key.
|
||||
*
|
||||
* @param[in] key key object.
|
||||
* @param[in] vp pointer of a task-specific value.
|
||||
*
|
||||
* @return the check status, 0 is OK, -1 indicates invalid.
|
||||
*/
|
||||
int aos_task_setspecific(aos_task_key_t key, void *vp);
|
||||
|
||||
/**
|
||||
* Get the value currently bound to the specified key.
|
||||
*
|
||||
* @param[in] key key object.
|
||||
*/
|
||||
void *aos_task_getspecific(aos_task_key_t key);
|
||||
|
||||
/**
|
||||
* Alloc a mutex.
|
||||
*
|
||||
* @param[in] mutex pointer of mutex object, mutex object must be alloced,
|
||||
* hdl pointer in aos_mutex_t will refer a kernel obj internally.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_mutex_new(aos_mutex_t *mutex);
|
||||
|
||||
/**
|
||||
* Free a mutex.
|
||||
*
|
||||
* @param[in] mutex mutex object, mem refered by hdl pointer in aos_mutex_t will
|
||||
* be freed internally.
|
||||
*/
|
||||
void aos_mutex_free(aos_mutex_t *mutex);
|
||||
|
||||
/**
|
||||
* Lock a mutex.
|
||||
*
|
||||
* @param[in] mutex mutex object, it contains kernel obj pointer which aos_mutex_new alloced.
|
||||
* @param[in] timeout waiting until timeout in milliseconds.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_mutex_lock(aos_mutex_t *mutex, unsigned int timeout);
|
||||
|
||||
/**
|
||||
* Unlock a mutex.
|
||||
*
|
||||
* @param[in] mutex mutex object, it contains kernel obj pointer which oc_mutex_new alloced.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_mutex_unlock(aos_mutex_t *mutex);
|
||||
|
||||
/**
|
||||
* This function will check if mutex is valid.
|
||||
*
|
||||
* @param[in] mutex pointer to the mutex.
|
||||
*
|
||||
* @return 0: invalid, 1: valid.
|
||||
*/
|
||||
int aos_mutex_is_valid(aos_mutex_t *mutex);
|
||||
|
||||
/**
|
||||
* Alloc a semaphore.
|
||||
*
|
||||
* @param[out] sem pointer of semaphore object, semaphore object must be alloced,
|
||||
* hdl pointer in aos_sem_t will refer a kernel obj internally.
|
||||
* @param[in] count initial semaphore counter.
|
||||
*
|
||||
* @return 0:success.
|
||||
*/
|
||||
int aos_sem_new(aos_sem_t *sem, int count);
|
||||
|
||||
/**
|
||||
* Destroy a semaphore.
|
||||
*
|
||||
* @param[in] sem pointer of semaphore object, mem refered by hdl pointer
|
||||
* in aos_sem_t will be freed internally.
|
||||
*/
|
||||
void aos_sem_free(aos_sem_t *sem);
|
||||
|
||||
/**
|
||||
* Acquire a semaphore.
|
||||
*
|
||||
* @param[in] sem semaphore object, it contains kernel obj pointer which aos_sem_new alloced.
|
||||
* @param[in] timeout waiting until timeout in milliseconds.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_sem_wait(aos_sem_t *sem, unsigned int timeout);
|
||||
|
||||
/**
|
||||
* Release a semaphore.
|
||||
*
|
||||
* @param[in] sem semaphore object, it contains kernel obj pointer which aos_sem_new alloced.
|
||||
*/
|
||||
void aos_sem_signal(aos_sem_t *sem);
|
||||
|
||||
/**
|
||||
* This function will check if semaphore is valid.
|
||||
*
|
||||
* @param[in] sem pointer to the semaphore.
|
||||
*
|
||||
* @return 0: invalid, 1: valid.
|
||||
*/
|
||||
int aos_sem_is_valid(aos_sem_t *sem);
|
||||
|
||||
/**
|
||||
* Release all semaphore.
|
||||
*
|
||||
* @param[in] sem semaphore object, it contains kernel obj pointer which aos_sem_new alloced.
|
||||
*/
|
||||
void aos_sem_signal_all(aos_sem_t *sem);
|
||||
|
||||
/**
|
||||
* This function will create an event with an initialization flag set.
|
||||
* This function should not be called from interrupt context.
|
||||
*
|
||||
* @param[in] event event object pointer.
|
||||
* @param[in] flags initialization flag set(provided by caller).
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
|
||||
int aos_event_new(aos_event_t *event, unsigned int flags);
|
||||
|
||||
/**
|
||||
* This function will free an event.
|
||||
* This function shoud not be called from interrupt context.
|
||||
*
|
||||
* @param[in] event memory refered by hdl pointer in event will be freed.
|
||||
*
|
||||
* @return N/A.
|
||||
*/
|
||||
|
||||
void aos_event_free(aos_event_t *event);
|
||||
|
||||
/**
|
||||
* This function will try to get flag set from given event, if the request flag
|
||||
* set is satisfied, it will return immediately, if the request flag set is not
|
||||
* satisfied with timeout(RHINO_WAIT_FOREVER,0xFFFFFFFF), the caller task will be
|
||||
* pended on event until the flag is satisfied, if the request flag is not
|
||||
* satisfied with timeout(RHINO_NO_WAIT, 0x0), it will also return immediately.
|
||||
* Note, this function should not be called from interrupt context because it has
|
||||
* possible to lead context switch and an interrupt has no TCB to save context.
|
||||
*
|
||||
* @param[in] event event object pointer.
|
||||
* @param[in] flags request flag set.
|
||||
* @param[in] opt operation type, such as AND,OR,AND_CLEAR,OR_CLEAR.
|
||||
* @param[out] actl_flags the internal flags value hold by event.
|
||||
* @param[in] flags request flag set.
|
||||
* @param[in] timeout max wait time in millisecond.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
|
||||
int aos_event_get(aos_event_t *event, unsigned int flags, unsigned char opt,
|
||||
unsigned int *actl_flags, unsigned int timeout);
|
||||
|
||||
/**
|
||||
* This function will set flag set to given event, and it will check if any task
|
||||
* which is pending on the event should be waken up.
|
||||
*
|
||||
* @param[in] event event object pointer.
|
||||
* @param[in] flags flag set to be set into event.
|
||||
* @param[in] opt operation type, such as AND,OR.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
|
||||
int aos_event_set(aos_event_t *event, unsigned int flags, unsigned char opt);
|
||||
|
||||
/**
|
||||
* This function will create a queue.
|
||||
*
|
||||
* @param[in] queue pointer to the queue(the space is provided by user).
|
||||
* @param[in] buf buf of the queue(provided by user).
|
||||
* @param[in] size the bytes of the buf.
|
||||
* @param[in] max_msg the max size of the msg.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
|
||||
int aos_queue_new(aos_queue_t *queue, void *buf, unsigned int size, int max_msg);
|
||||
|
||||
/**
|
||||
* This function will delete a queue.
|
||||
*
|
||||
* @param[in] queue pointer to the queue.
|
||||
*/
|
||||
void aos_queue_free(aos_queue_t *queue);
|
||||
|
||||
/**
|
||||
* This function will send a msg to the front of a queue.
|
||||
*
|
||||
* @param[in] queue pointer to the queue.
|
||||
* @param[in] msg msg to send.
|
||||
* @param[in] size size of the msg.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_queue_send(aos_queue_t *queue, void *msg, unsigned int size);
|
||||
|
||||
/**
|
||||
* This function will receive msg from a queue.
|
||||
*
|
||||
* @param[in] queue pointer to the queue.
|
||||
* @param[in] ms ms to wait before receive.
|
||||
* @param[out] msg buf to save msg.
|
||||
* @param[out] size size of the msg.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_queue_recv(aos_queue_t *queue, unsigned int ms, void *msg, unsigned int *size);
|
||||
|
||||
/**
|
||||
* This function will check if queue is valid.
|
||||
*
|
||||
* @param[in] queue pointer to the queue.
|
||||
*
|
||||
* @return 0: invalid, 1: valid.
|
||||
*/
|
||||
int aos_queue_is_valid(aos_queue_t *queue);
|
||||
|
||||
/**
|
||||
* This function will return buf ptr if queue is inited.
|
||||
*
|
||||
* @param[in] queue pointer to the queue.
|
||||
*
|
||||
* @return NULL: error.
|
||||
*/
|
||||
void *aos_queue_buf_ptr(aos_queue_t *queue);
|
||||
|
||||
/**
|
||||
* This function will create a timer and run auto.
|
||||
*
|
||||
* @param[in] timer pointer to the timer.
|
||||
* @param[in] fn callbak of the timer.
|
||||
* @param[in] arg the argument of the callback.
|
||||
* @param[in] ms ms of the normal timer triger.
|
||||
* @param[in] repeat repeat or not when the timer is created.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_timer_new(aos_timer_t *timer, void (*fn)(void *, void *),
|
||||
void *arg, int ms, int repeat);
|
||||
|
||||
/**
|
||||
* This function will create a timer.
|
||||
*
|
||||
* @param[in] timer pointer to the timer.
|
||||
* @param[in] fn callbak of the timer.
|
||||
* @param[in] arg the argument of the callback.
|
||||
* @param[in] ms ms of the normal timer triger.
|
||||
* @param[in] repeat repeat or not when the timer is created.
|
||||
* @param[in] auto_run run auto or not when the timer is created.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_timer_new_ext(aos_timer_t *timer, void (*fn)(void *, void *),
|
||||
void *arg, int ms, int repeat, unsigned char auto_run);
|
||||
|
||||
/**
|
||||
* This function will delete a timer.
|
||||
*
|
||||
* @param[in] timer pointer to a timer.
|
||||
*/
|
||||
void aos_timer_free(aos_timer_t *timer);
|
||||
|
||||
/**
|
||||
* This function will start a timer.
|
||||
*
|
||||
* @param[in] timer pointer to the timer.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_timer_start(aos_timer_t *timer);
|
||||
|
||||
/**
|
||||
* This function will stop a timer.
|
||||
*
|
||||
* @param[in] timer pointer to the timer.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_timer_stop(aos_timer_t *timer);
|
||||
|
||||
/**
|
||||
* This function will change attributes of a timer.
|
||||
*
|
||||
* @param[in] timer pointer to the timer.
|
||||
* @param[in] ms ms of the timer triger.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_timer_change(aos_timer_t *timer, int ms);
|
||||
|
||||
/**
|
||||
* This function will creat a workqueue.
|
||||
*
|
||||
* @param[in] workqueue the workqueue to be created.
|
||||
* @param[in] pri the priority of the worker.
|
||||
* @param[in] stack_size the size of the worker-stack.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_workqueue_create(aos_workqueue_t *workqueue, int pri, int stack_size);
|
||||
|
||||
/**
|
||||
* This function will initialize a work.
|
||||
*
|
||||
* @param[in] work the work to be initialized.
|
||||
* @param[in] fn the call back function to run.
|
||||
* @param[in] arg the paraments of the function.
|
||||
* @param[in] dly ms to delay before run.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_work_init(aos_work_t *work, void (*fn)(void *), void *arg, int dly);
|
||||
|
||||
/**
|
||||
* This function will destroy a work.
|
||||
*
|
||||
* @param[in] work the work to be destroied.
|
||||
*/
|
||||
void aos_work_destroy(aos_work_t *work);
|
||||
|
||||
/**
|
||||
* This function will run a work on a workqueue.
|
||||
*
|
||||
* @param[in] workqueue the workqueue to run work.
|
||||
* @param[in] work the work to run.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_work_run(aos_workqueue_t *workqueue, aos_work_t *work);
|
||||
|
||||
/**
|
||||
* This function will run a work on the default workqueue.
|
||||
*
|
||||
* @param[in] work the work to run.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_work_sched(aos_work_t *work);
|
||||
|
||||
/**
|
||||
* This function will cancel a work on the default workqueue.
|
||||
*
|
||||
* @param[in] work the work to cancel.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int aos_work_cancel(aos_work_t *work);
|
||||
|
||||
/**
|
||||
* Realloc memory.
|
||||
*
|
||||
* @param[in] mem current memory address point.
|
||||
* @param[in] size new size of the mem to remalloc.
|
||||
*
|
||||
* @return NULL: error.
|
||||
*/
|
||||
void *aos_realloc(void *mem, unsigned int size);
|
||||
|
||||
/**
|
||||
* Alloc memory.
|
||||
*
|
||||
* @param[in] size size of the mem to malloc.
|
||||
*
|
||||
* @return NULL: error.
|
||||
*/
|
||||
void *aos_malloc(unsigned int size);
|
||||
|
||||
/**
|
||||
* Alloc memory and clear to zero.
|
||||
*
|
||||
* @param[in] size size of the mem to malloc.
|
||||
*
|
||||
* @return NULL: error.
|
||||
*/
|
||||
void *aos_zalloc(unsigned int size);
|
||||
|
||||
/**
|
||||
* Trace alloced mems.
|
||||
*
|
||||
* @param[in] addr pointer of the mem alloced by malloc.
|
||||
* @param[in] allocator buildin_address.
|
||||
*/
|
||||
void aos_alloc_trace(void *addr, size_t allocator);
|
||||
|
||||
/**
|
||||
* Free memory.
|
||||
*
|
||||
* @param[in] ptr address point of the mem.
|
||||
*/
|
||||
void aos_free(void *mem);
|
||||
|
||||
/**
|
||||
* Get current time in nano seconds.
|
||||
*
|
||||
* @return elapsed time in nano seconds from system starting.
|
||||
*/
|
||||
long long aos_now(void);
|
||||
|
||||
/**
|
||||
* Get current time in mini seconds.
|
||||
*
|
||||
* @return elapsed time in mini seconds from system starting.
|
||||
*/
|
||||
long long aos_now_ms(void);
|
||||
|
||||
/**
|
||||
* Msleep.
|
||||
*
|
||||
* @param[in] ms sleep time in milliseconds.
|
||||
*/
|
||||
void aos_msleep(int ms);
|
||||
|
||||
/**
|
||||
* Initialize system
|
||||
*/
|
||||
void aos_init(void);
|
||||
|
||||
/**
|
||||
* Start system
|
||||
*/
|
||||
void aos_start(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_KERNEL_H */
|
||||
|
||||
65
Living_SDK/include/aos/kv.h
Normal file
65
Living_SDK/include/aos/kv.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_KV_H
|
||||
#define AOS_KV_H
|
||||
|
||||
#include <aos/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Add a new KV pair.
|
||||
*
|
||||
* @param[in] key the key of the KV pair.
|
||||
* @param[in] value the value of the KV pair.
|
||||
* @param[in] len the length of the value.
|
||||
* @param[in] sync save the KV pair to flash right now (should always be 1).
|
||||
*
|
||||
* @return 0 on success, negative error on failure.
|
||||
*/
|
||||
int aos_kv_set(const char *key, const void *value, int len, int sync);
|
||||
|
||||
/**
|
||||
* Get the KV pair's value stored in buffer by its key.
|
||||
*
|
||||
* @note: the buffer_len should be larger than the real length of the value,
|
||||
* otherwise buffer would be NULL.
|
||||
*
|
||||
* @param[in] key the key of the KV pair to get.
|
||||
* @param[out] buffer the memory to store the value.
|
||||
* @param[in-out] buffer_len in: the length of the input buffer.
|
||||
* out: the real length of the value.
|
||||
*
|
||||
* @return 0 on success, negative error on failure.
|
||||
*/
|
||||
int aos_kv_get(const char *key, void *buffer, int *buffer_len);
|
||||
|
||||
/**
|
||||
* Delete the KV pair by its key.
|
||||
*
|
||||
* @param[in] key the key of the KV pair to delete.
|
||||
*
|
||||
* @return 0 on success, negative error on failure.
|
||||
*/
|
||||
int aos_kv_del(const char *key);
|
||||
|
||||
/**
|
||||
* Delete the KV pair by key's prefix.
|
||||
*
|
||||
* @param[in] key the key's prefix of the KV pair to delete.
|
||||
*
|
||||
* @return 0 on success, negative error on failure.
|
||||
*/
|
||||
int aos_kv_del_by_prefix(const char *prefix);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_KV_H */
|
||||
|
||||
338
Living_SDK/include/aos/list.h
Normal file
338
Living_SDK/include/aos/list.h
Normal file
|
|
@ -0,0 +1,338 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_LIST_H
|
||||
#define AOS_LIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get offset of a member variable.
|
||||
*
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the variable within the struct.
|
||||
*/
|
||||
#define aos_offsetof(type, member) ((size_t)&(((type *)0)->member))
|
||||
|
||||
/*
|
||||
* Get the struct for this entry.
|
||||
*
|
||||
* @param[in] ptr the list head to take the element from.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the variable within the struct.
|
||||
*/
|
||||
#define aos_container_of(ptr, type, member) \
|
||||
((type *) ((char *) (ptr) - aos_offsetof(type, member)))
|
||||
|
||||
/* for double link list */
|
||||
typedef struct dlist_s {
|
||||
struct dlist_s *prev;
|
||||
struct dlist_s *next;
|
||||
} dlist_t;
|
||||
|
||||
static inline void __dlist_add(dlist_t *node, dlist_t *prev, dlist_t *next)
|
||||
{
|
||||
node->next = next;
|
||||
node->prev = prev;
|
||||
|
||||
prev->next = node;
|
||||
next->prev = node;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the struct for this entry.
|
||||
*
|
||||
* @param[in] addr the list head to take the element from.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the dlist_t within the struct.
|
||||
*/
|
||||
#define dlist_entry(addr, type, member) \
|
||||
((type *)((long)addr - aos_offsetof(type, member)))
|
||||
|
||||
|
||||
static inline void dlist_add(dlist_t *node, dlist_t *queue)
|
||||
{
|
||||
__dlist_add(node, queue, queue->next);
|
||||
}
|
||||
|
||||
static inline void dlist_add_tail(dlist_t *node, dlist_t *queue)
|
||||
{
|
||||
__dlist_add(node, queue->prev, queue);
|
||||
}
|
||||
|
||||
static inline void dlist_del(dlist_t *node)
|
||||
{
|
||||
dlist_t *prev = node->prev;
|
||||
dlist_t *next = node->next;
|
||||
|
||||
prev->next = next;
|
||||
next->prev = prev;
|
||||
}
|
||||
|
||||
static inline void dlist_init(dlist_t *node)
|
||||
{
|
||||
node->next = node->prev = node;
|
||||
}
|
||||
|
||||
static inline void INIT_AOS_DLIST_HEAD(dlist_t *list)
|
||||
{
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
}
|
||||
|
||||
static inline int dlist_empty(const dlist_t *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise the list.
|
||||
*
|
||||
* @param[in] list the list to be inited.
|
||||
*/
|
||||
#define AOS_DLIST_INIT(list) {&(list), &(list)}
|
||||
|
||||
/*
|
||||
* Get the first element from a list
|
||||
*
|
||||
* @param[in] ptr the list head to take the element from.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the dlist_t within the struct.
|
||||
*/
|
||||
#define dlist_first_entry(ptr, type, member) \
|
||||
dlist_entry((ptr)->next, type, member)
|
||||
|
||||
/*
|
||||
* Iterate over a list.
|
||||
*
|
||||
* @param[in] pos the &struct dlist_t to use as a loop cursor.
|
||||
* @param[in] head he head for your list.
|
||||
*/
|
||||
#define dlist_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); pos = pos->next)
|
||||
|
||||
/*
|
||||
* Iterate over a list safe against removal of list entry.
|
||||
*
|
||||
* @param[in] pos the &struct dlist_t to use as a loop cursor.
|
||||
* @param[in] n another &struct dlist_t to use as temporary storage.
|
||||
* @param[in] head he head for your list.
|
||||
*/
|
||||
#define dlist_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||
pos = n, n = pos->next)
|
||||
|
||||
/*
|
||||
* Iterate over list of given type.
|
||||
*
|
||||
* @param[in] queue he head for your list.
|
||||
* @param[in] node the &struct dlist_t to use as a loop cursor.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the dlist_t within the struct.
|
||||
*/
|
||||
#define dlist_for_each_entry(queue, node, type, member) \
|
||||
for (node = aos_container_of((queue)->next, type, member); \
|
||||
&node->member != (queue); \
|
||||
node = aos_container_of(node->member.next, type, member))
|
||||
|
||||
/*
|
||||
* Iterate over list of given type safe against removal of list entry.
|
||||
*
|
||||
* @param[in] queue the head for your list.
|
||||
* @param[in] n the type * to use as a temp.
|
||||
* @param[in] node the type * to use as a loop cursor.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the dlist_t within the struct.
|
||||
*/
|
||||
#define dlist_for_each_entry_safe(queue, n, node, type, member) \
|
||||
for (node = aos_container_of((queue)->next, type, member), \
|
||||
n = (queue)->next ? (queue)->next->next : NULL; \
|
||||
&node->member != (queue); \
|
||||
node = aos_container_of(n, type, member), n = n ? n->next : NULL)
|
||||
|
||||
/*
|
||||
* Get the struct for this entry.
|
||||
* @param[in] ptr the list head to take the element from.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the variable within the struct.
|
||||
*/
|
||||
#define list_entry(ptr, type, member) \
|
||||
aos_container_of(ptr, type, member)
|
||||
|
||||
|
||||
/*
|
||||
* Iterate backwards over list of given type.
|
||||
*
|
||||
* @param[in] pos the type * to use as a loop cursor.
|
||||
* @param[in] head he head for your list.
|
||||
* @param[in] member the name of the dlist_t within the struct.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
*/
|
||||
#define dlist_for_each_entry_reverse(pos, head, member, type) \
|
||||
for (pos = list_entry((head)->prev, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.prev, type, member))
|
||||
|
||||
|
||||
/*
|
||||
* Get the list length.
|
||||
*
|
||||
* @param[in] queue the head for your list.
|
||||
*/
|
||||
static inline int dlist_entry_number(dlist_t *queue)
|
||||
{
|
||||
int num;
|
||||
dlist_t *cur = queue;
|
||||
for (num=0;cur->next != queue;cur=cur->next, num++)
|
||||
;
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Initialise the list.
|
||||
*
|
||||
* @param[in] name the list to be initialized.
|
||||
*/
|
||||
#define AOS_DLIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
/*
|
||||
* Initialise the list.
|
||||
*
|
||||
* @param[in] name the list to be initialized.
|
||||
*/
|
||||
#define AOS_DLIST_HEAD(name) \
|
||||
dlist_t name = AOS_DLIST_HEAD_INIT(name)
|
||||
|
||||
/* for single link list */
|
||||
typedef struct slist_s {
|
||||
struct slist_s *next;
|
||||
} slist_t;
|
||||
|
||||
static inline void slist_add(slist_t *node, slist_t *head)
|
||||
{
|
||||
node->next = head->next;
|
||||
head->next = node;
|
||||
}
|
||||
|
||||
static inline void slist_add_tail(slist_t *node, slist_t *head)
|
||||
{
|
||||
while (head->next) {
|
||||
head = head->next;
|
||||
}
|
||||
|
||||
slist_add(node, head);
|
||||
}
|
||||
|
||||
static inline void slist_del(slist_t *node, slist_t *head)
|
||||
{
|
||||
while (head->next) {
|
||||
if (head->next == node) {
|
||||
head->next = node->next;
|
||||
break;
|
||||
}
|
||||
|
||||
head = head->next;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int slist_empty(const slist_t *head)
|
||||
{
|
||||
return !head->next;
|
||||
}
|
||||
|
||||
static inline void slist_init(slist_t *head)
|
||||
{
|
||||
head->next = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Iterate over list of given type.
|
||||
*
|
||||
* @param[in] queue he head for your list.
|
||||
* @param[in] node the type * to use as a loop cursor.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the slist_t within the struct.
|
||||
*/
|
||||
#define slist_for_each_entry(queue, node, type, member) \
|
||||
for (node = aos_container_of((queue)->next, type, member); \
|
||||
&node->member; \
|
||||
node = aos_container_of(node->member.next, type, member))
|
||||
|
||||
/*
|
||||
* Iterate over list of given type safe against removal of list entry.
|
||||
*
|
||||
* @param[in] queue the head for your list.
|
||||
* @param[in] tmp the type * to use as a temp.
|
||||
* @param[in] node the type * to use as a loop cursor.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the slist_t within the struct.
|
||||
*/
|
||||
#define slist_for_each_entry_safe(queue, tmp, node, type, member) \
|
||||
for (node = aos_container_of((queue)->next, type, member), \
|
||||
tmp = (queue)->next ? (queue)->next->next : NULL; \
|
||||
&node->member; \
|
||||
node = aos_container_of(tmp, type, member), tmp = tmp ? tmp->next : tmp)
|
||||
|
||||
/*
|
||||
* Initialise the list.
|
||||
*
|
||||
* @param[in] name the list to be initialized.
|
||||
*/
|
||||
#define AOS_SLIST_HEAD_INIT(name) {0}
|
||||
|
||||
/*
|
||||
* Initialise the list.
|
||||
*
|
||||
* @param[in] name the list to be initialized.
|
||||
*/
|
||||
#define AOS_SLIST_HEAD(name) \
|
||||
slist_t name = AOS_SLIST_HEAD_INIT(name)
|
||||
|
||||
/*
|
||||
* Get the struct for this entry.
|
||||
* @param[in] addr the list head to take the element from.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the slist_t within the struct.
|
||||
*/
|
||||
#define slist_entry(addr, type, member) ( \
|
||||
addr ? (type *)((long)addr - aos_offsetof(type, member)) : (type *)addr \
|
||||
)
|
||||
|
||||
/*
|
||||
* Get the first element from a list.
|
||||
*
|
||||
* @param[in] ptr the list head to take the element from.
|
||||
* @param[in] type the type of the struct this is embedded in.
|
||||
* @param[in] member the name of the slist_t within the struct.
|
||||
*/
|
||||
#define slist_first_entry(ptr, type, member) \
|
||||
slist_entry((ptr)->next, type, member)
|
||||
|
||||
/*
|
||||
* Get the list length.
|
||||
*
|
||||
* @param[in] queue the head for your list.
|
||||
*/
|
||||
static inline int slist_entry_number(slist_t *queue)
|
||||
{
|
||||
int num;
|
||||
slist_t *cur = queue;
|
||||
for (num=0;cur->next;cur=cur->next, num++)
|
||||
;
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_LIST_H */
|
||||
|
||||
95
Living_SDK/include/aos/log.h
Normal file
95
Living_SDK/include/aos/log.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_LOG_H
|
||||
#define AOS_LOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <aos/internal/log_impl.h>
|
||||
|
||||
typedef enum {
|
||||
AOS_LL_NONE, /* disable log */
|
||||
AOS_LL_FATAL, /* fatal log will output */
|
||||
AOS_LL_ERROR, /* fatal + error log will output */
|
||||
AOS_LL_WARN, /* fatal + warn + error log will output(default level) */
|
||||
AOS_LL_INFO, /* info + warn + error log will output */
|
||||
AOS_LL_DEBUG, /* debug + info + warn + error + fatal log will output */
|
||||
} aos_log_level_t;
|
||||
|
||||
extern unsigned int aos_log_level;
|
||||
/**
|
||||
* Get the log level.
|
||||
*/
|
||||
static inline int aos_get_log_level(void) {
|
||||
return aos_log_level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the log level.
|
||||
*
|
||||
* @param[in] log_level level to be set,must be one of AOS_LL_NONE,AOS_LL_FATAL,AOS_LL_ERROR,AOS_LL_WARN,AOS_LL_INFO or AOS_LL_DEBUG.
|
||||
*/
|
||||
void aos_set_log_level(aos_log_level_t log_level);
|
||||
|
||||
/*
|
||||
* Log at fatal level.
|
||||
*
|
||||
* @param[in] mod string description of module.
|
||||
* @param[in] fmt same as printf() usage.
|
||||
*/
|
||||
#define LOGF(mod, fmt, ...) LOGF_IMPL(mod, fmt, ##__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Log at error level.
|
||||
*
|
||||
* @param[in] mod string description of module.
|
||||
* @param[in] fmt same as printf() usage.
|
||||
*/
|
||||
#define LOGE(mod, fmt, ...) LOGE_IMPL(mod, fmt, ##__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Log at warning level.
|
||||
*
|
||||
* @param[in] mod string description of module.
|
||||
* @param[in] fmt same as printf() usage.
|
||||
*/
|
||||
#define LOGW(mod, fmt, ...) LOGW_IMPL(mod, fmt, ##__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Log at info level.
|
||||
*
|
||||
* @param[in] mod string description of module.
|
||||
* @param[in] fmt same as printf() usage.
|
||||
*/
|
||||
#define LOGI(mod, fmt, ...) LOGI_IMPL(mod, fmt, ##__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Log at debug level.
|
||||
*
|
||||
* @param[in] mod string description of module.
|
||||
* @param[in] fmt same as printf() usage.
|
||||
*/
|
||||
#define LOGD(mod, fmt, ...) LOGD_IMPL(mod, fmt, ##__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Log at the level set by aos_set_log_level().
|
||||
*
|
||||
* @param[in] fmt same as printf() usage.
|
||||
*/
|
||||
#define LOG(fmt, ...) LOG_IMPL(fmt, ##__VA_ARGS__)
|
||||
|
||||
#ifdef AOS_DISABLE_ALL_LOGS
|
||||
extern int log_check_uart_input(int);
|
||||
extern char log_get_enable_aos_log_flag(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_LOG_H */
|
||||
|
||||
61
Living_SDK/include/aos/mbedtls_ssl.h
Normal file
61
Living_SDK/include/aos/mbedtls_ssl.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_MBEDTLS_SSL_H
|
||||
#define AOS_MBEDTLS_SSL_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <aos/aos.h>
|
||||
|
||||
|
||||
/**
|
||||
* Create a ssl connect.
|
||||
*
|
||||
* @param[in] tcp_fd handle of the tcp socket.
|
||||
* @param[in] ca_cert CA.
|
||||
* @param[in] ca_cert_len length of the CA.
|
||||
*
|
||||
* @return NULL: error; ssl_param: success.
|
||||
*/
|
||||
void *mbedtls_ssl_connect(void *tcp_fd, const char *ca_cert, int ca_cert_len);
|
||||
|
||||
/**
|
||||
* Send data through ssl.
|
||||
*
|
||||
* @param[in] ssl handle of the ssl.
|
||||
* @param[in] buffer data to send.
|
||||
* @param[in] length length of the data.
|
||||
*
|
||||
* @return -1: error; others: length of the data be sended.
|
||||
*/
|
||||
int mbedtls_ssl_send(void *ssl, const char *buffer, int length);
|
||||
|
||||
/**
|
||||
* Recv data through ssl.
|
||||
*
|
||||
* @param[in] ssl handle of the ssl.
|
||||
* @param[in] buffer buffer to recv data.
|
||||
* @param[in] length the max size of the buffer.
|
||||
*
|
||||
* @return -1: error; 0: EOF; others: length of the data be sended.
|
||||
*/
|
||||
int mbedtls_ssl_recv(void *ssl, char *buffer, int length);
|
||||
|
||||
/**
|
||||
* Close the ssl.
|
||||
*
|
||||
* @param[in] ssl handle to be closed.
|
||||
*
|
||||
* @return 0: success.
|
||||
*/
|
||||
int mbedtls_ssl_close(void *ssl);
|
||||
|
||||
#endif /* AOS_MBEDTLS_SSL_H */
|
||||
|
||||
40
Living_SDK/include/aos/network.h
Normal file
40
Living_SDK/include/aos/network.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_NETWORK_H
|
||||
#define AOS_NETWORK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/* network */
|
||||
#ifdef WITH_LWIP
|
||||
#include <lwip/def.h>
|
||||
#include <lwip/netdb.h>
|
||||
#include <lwip/sockets.h>
|
||||
#elif defined(WITH_SAL)
|
||||
#include <sal_arch.h>
|
||||
#include <sal_def.h>
|
||||
#include <sal_ipaddr.h>
|
||||
#include <sal_sockets.h>
|
||||
#elif !defined(CONFIG_NO_TCPIP)
|
||||
#include <netdb.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/eventfd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_NETWORK_H */
|
||||
|
||||
53
Living_SDK/include/aos/types.h
Normal file
53
Living_SDK/include/aos/types.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_TYPES_H
|
||||
#define AOS_TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(WITH_LWIP) || defined(CONFIG_NO_TCPIP) || defined(WITH_SAL)
|
||||
#define POLLIN 0x1
|
||||
#define POLLOUT 0x2
|
||||
#define POLLERR 0x4
|
||||
struct pollfd {
|
||||
int fd;
|
||||
short events;
|
||||
short revents;
|
||||
};
|
||||
#else
|
||||
#include <poll.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifndef AOS_EXPORTX
|
||||
/**
|
||||
* define the AOS_EXPORT macro*
|
||||
*/
|
||||
|
||||
#define AOS_EXPORT(ret, fun, ...)
|
||||
#endif
|
||||
|
||||
#ifndef AOS_COMPONENT_INIT
|
||||
|
||||
/**
|
||||
* define the AOS_COMPONENT_INIT macro
|
||||
*/
|
||||
#define AOS_COMPONENT_INIT(fun, ...)
|
||||
#endif
|
||||
|
||||
#ifndef AOS_TESTCASE
|
||||
/**
|
||||
* define the AOS_TESTCASE macro
|
||||
*/
|
||||
#define AOS_TESTCASE(fun, ...)
|
||||
#endif
|
||||
|
||||
#endif /* AOS_TYPES_H */
|
||||
|
||||
18
Living_SDK/include/aos/uData.h
Normal file
18
Living_SDK/include/aos/uData.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef UDATA_H
|
||||
#define UDATA_H
|
||||
|
||||
#include "../../framework/uData/include/uData_com_desc.h"
|
||||
|
||||
int uData_report_publish(input_event_t *event, void *pdata);
|
||||
int uData_dev_ioctl(udata_t* pkg, uint8_t cmd, long long parm);
|
||||
int uData_subscribe(udata_type_e type);
|
||||
int uData_unsubscribe(udata_type_e type);
|
||||
|
||||
|
||||
#endif /*UDATA_H*/
|
||||
|
||||
49
Living_SDK/include/aos/version.h
Normal file
49
Living_SDK/include/aos/version.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_VERSION_H
|
||||
#define AOS_VERSION_H
|
||||
|
||||
/**
|
||||
* Get aos product model.
|
||||
*
|
||||
* @return model success, 0 failure.
|
||||
*/
|
||||
const char *aos_get_product_model(void);
|
||||
|
||||
/**
|
||||
* Get aos os version.
|
||||
*
|
||||
* @return os version success, 0 failure.
|
||||
*/
|
||||
const char *aos_get_os_version(void);
|
||||
|
||||
/**
|
||||
* Get aos kernel version.
|
||||
*
|
||||
* @return kernel version success, 0 failure.
|
||||
*/
|
||||
const char *aos_get_kernel_version(void);
|
||||
|
||||
/**
|
||||
* Get aos app version.
|
||||
*
|
||||
* @return app version success, 0 failure.
|
||||
*/
|
||||
const char *aos_get_app_version(void);
|
||||
|
||||
/**
|
||||
* Get aos device name.
|
||||
*
|
||||
* @return device name success, 0 failure.
|
||||
*/
|
||||
const char *aos_get_device_name(void);
|
||||
|
||||
/**
|
||||
* dump sys info.
|
||||
*/
|
||||
void dump_sys_info(void);
|
||||
|
||||
#endif /* AOS_VERSION_H */
|
||||
|
||||
195
Living_SDK/include/aos/vfs.h
Normal file
195
Living_SDK/include/aos/vfs.h
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_VFS_H
|
||||
#define AOS_VFS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <aos/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int d_ino; /* file number */
|
||||
uint8_t d_type; /* type of file */
|
||||
char d_name[]; /* file name */
|
||||
} aos_dirent_t;
|
||||
|
||||
typedef struct {
|
||||
int dd_vfs_fd;
|
||||
int dd_rsv;
|
||||
} aos_dir_t;
|
||||
|
||||
/**
|
||||
* Open the file or device by its path.
|
||||
*
|
||||
* @param[in] path the path of the file or device to open.
|
||||
* @param[in] flags the mode of open operation.
|
||||
*
|
||||
* @return the new file descriptor, negative error on failure.
|
||||
*/
|
||||
int aos_open(const char *path, int flags);
|
||||
|
||||
/**
|
||||
* Close the file or device by its file descriptor.
|
||||
*
|
||||
* @param[in] fd the file descriptor of the file or device.
|
||||
*
|
||||
* @return 0 on success, negative error on failure.
|
||||
*/
|
||||
int aos_close(int fd);
|
||||
|
||||
/**
|
||||
* Read the contents of a file or device into a buffer.
|
||||
*
|
||||
* @param[in] fd the file descriptor of the file or device.
|
||||
* @param[in] nbytes the number of bytes to read.
|
||||
* @param[out] buf the buffer to read in to.
|
||||
*
|
||||
* @return The number of bytes read, 0 at end of file, negative error on failure.
|
||||
*/
|
||||
ssize_t aos_read(int fd, void *buf, size_t nbytes);
|
||||
|
||||
/**
|
||||
* Write the contents of a buffer to file or device.
|
||||
*
|
||||
* @param[in] fd the file descriptor of the file or device.
|
||||
* @param[in] nbytes the number of bytes to write.
|
||||
* @param[in] buf the buffer to write from.
|
||||
*
|
||||
* @return The number of bytes written, negative error on failure.
|
||||
*/
|
||||
ssize_t aos_write(int fd, const void *buf, size_t nbytes);
|
||||
|
||||
/**
|
||||
* This is a wildcard API for sending controller specific commands.
|
||||
*
|
||||
* @param[in] fd the file descriptior of the file or device.
|
||||
* @param[in] cmd A controller specific command.
|
||||
* @param[in] arg Argument to the command, interpreted according to the command.
|
||||
*
|
||||
* @return any return from the command.
|
||||
*/
|
||||
int aos_ioctl(int fd, int cmd, unsigned long arg);
|
||||
|
||||
/**
|
||||
* A mechanism to multiplex input/output over a set of file descriptors.
|
||||
* For every file descriptor provided, poll() examines it for any events registered for that particular file descriptor.
|
||||
*
|
||||
* @param[in] fds a point to the array of pollfd struct carrying a file descriptor and bitmasks of events.
|
||||
* @param[in] nfhs number of file descriptors.
|
||||
* @param[in] timeout timer value to timeout or -1 for loop forever.
|
||||
*
|
||||
* @return number of file descriptors selected (for which revents is non-zero). 0 if timed out with nothing selected. -1 for error.
|
||||
*/
|
||||
int aos_poll(struct pollfd *fds, int nfds, int timeout);
|
||||
|
||||
/**
|
||||
* Performs one of the operations described below on the open file descriptor, The operation is determined by cmd.
|
||||
*
|
||||
* @param[in] fd the file descriptor of the file or device.
|
||||
* @param[in] cmd the operation of the file or device.
|
||||
* @param[in] val it depends on whether cmd need params.
|
||||
*
|
||||
* @return 0 on success, negative error on failure.
|
||||
*/
|
||||
int aos_fcntl(int fd, int cmd, int val);
|
||||
|
||||
/**
|
||||
* Move the file position to a given offset from a given location.
|
||||
*
|
||||
* @param[in] fd the file descriptor of the file.
|
||||
* @param[in] offset The offset from whence to move to.
|
||||
* @param[in] whence The start of where to seek.
|
||||
* SEEK_SET to start from beginning of file.
|
||||
* SEEK_CUR to start from current position in file.
|
||||
* SEEK_END to start from end of file.
|
||||
*
|
||||
* @return The new offset of the file.
|
||||
*/
|
||||
off_t aos_lseek(int fd, off_t offset, int whence);
|
||||
|
||||
/**
|
||||
* Flush any buffers associated with the file.
|
||||
*
|
||||
* @param[in] fd the file descriptor of the file.
|
||||
*
|
||||
* @return 0 on success, negative error code on failure.
|
||||
*/
|
||||
int aos_sync(int fd);
|
||||
|
||||
/**
|
||||
* Store information about the file in a stat structure.
|
||||
*
|
||||
* @param[in] path The path of the file to find information about.
|
||||
* @param[out] st The stat buffer to write to.
|
||||
*
|
||||
* @return 0 on success, negative error code on failure.
|
||||
*/
|
||||
int aos_stat(const char *path, struct stat *st);
|
||||
|
||||
/**
|
||||
* Remove a file from the filesystem.
|
||||
*
|
||||
* @param[in] path The path of the file to remove.
|
||||
*
|
||||
* @return 0 on success, negative error code on failure.
|
||||
*/
|
||||
int aos_unlink(const char *path);
|
||||
|
||||
/**
|
||||
* Rename a file in the filesystem.
|
||||
*
|
||||
* @param[in] oldpath The path of the file to rename.
|
||||
* @param[in] newpath The path to rename it to.
|
||||
*
|
||||
* @return 0 on success, negative error code on failure.
|
||||
*/
|
||||
int aos_rename(const char *oldpath, const char *newpath);
|
||||
|
||||
/**
|
||||
* Open a directory on the filesystem.
|
||||
*
|
||||
* @param[in] path the path of the directory to open.
|
||||
*
|
||||
* @return a point of directory stream on success, NULL on failure.
|
||||
*/
|
||||
aos_dir_t *aos_opendir(const char *path);
|
||||
|
||||
/**
|
||||
* Close a directory.
|
||||
*
|
||||
* @param[in] dir the handle of the directory to close.
|
||||
*
|
||||
* @return 0 on success, negative error code on failure.
|
||||
*/
|
||||
int aos_closedir(aos_dir_t *dir);
|
||||
|
||||
/**
|
||||
* Read the next directory entry.
|
||||
*
|
||||
* @param[in] dir the handle of the directory to read.
|
||||
*
|
||||
* @return a pointer to a dirent structure.
|
||||
*/
|
||||
aos_dirent_t *aos_readdir(aos_dir_t *dir);
|
||||
|
||||
/**
|
||||
* Create the directory, if they do not already exist.
|
||||
*
|
||||
* @param[in] path the path of the directory.
|
||||
*
|
||||
* @return 0 on success, negative error code on failure.
|
||||
*/
|
||||
int aos_mkdir(const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_VFS_H */
|
||||
|
||||
248
Living_SDK/include/aos/yloop.h
Normal file
248
Living_SDK/include/aos/yloop.h
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef AOS_YLOOP_H
|
||||
#define AOS_YLOOP_H
|
||||
|
||||
#include <aos/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <aos/internal/event_type_code.h>
|
||||
|
||||
#ifndef AOS_DOXYGEN_MODE
|
||||
|
||||
/* special event filter */
|
||||
#define EV_ALL 0
|
||||
#define EV_FLAG_URGENT 0x8000
|
||||
|
||||
/* system event */
|
||||
#define EV_SYS 0x0001
|
||||
#define CODE_SYS_ON_STARTING 1
|
||||
#define CODE_SYS_ON_START_COMPLETED 2
|
||||
#define CODE_SYS_ON_START_FAILED 4
|
||||
#define CODE_SYS_ON_IDLE 3
|
||||
#define CODE_SYS_ON_START_FOTA 5
|
||||
#define CODE_SYS_ON_ALINK_ONLINE 6
|
||||
#define CODE_SYS_ON_ALINK_OFFLINE 7
|
||||
#define CODE_SYS_ON_MQTT_READ 8
|
||||
#define CODE_SYS_ON_COAP_AUTHED 9
|
||||
|
||||
/* WiFi event */
|
||||
#define EV_WIFI 0x0002
|
||||
#define CODE_WIFI_CMD_RECONNECT 1
|
||||
#define CODE_WIFI_ON_CONNECTED 2
|
||||
#define CODE_WIFI_ON_DISCONNECT 3
|
||||
#define CODE_WIFI_ON_PRE_GOT_IP 4
|
||||
#define CODE_WIFI_ON_GOT_IP 5
|
||||
#define CODE_WIFI_ON_CONNECT_FAILED 6
|
||||
|
||||
/* Mesh event */
|
||||
#define EV_MESH 0x0003
|
||||
|
||||
/* user app start 0x1000 - 0x7fff */
|
||||
#define EV_USER 0x1000
|
||||
|
||||
/** uData event */
|
||||
#define EV_UDATA 0x0004
|
||||
#define CODE_UDATA_DEV_READ 1
|
||||
#define CODE_UDATA_DEV_IOCTL 2
|
||||
#define CODE_UDATA_DEV_OPEN 3
|
||||
#define CODE_UDATA_DEV_CLOSE 4
|
||||
#define CODE_UDATA_DEV_ENABLE 5
|
||||
#define CODE_UDATA_DEV_DISABLE 6
|
||||
#define CODE_UDATA_SERVICE_SUBSRIBE 7 /* for external component */
|
||||
#define CODE_UDATA_SERVICE_UNSUBSRIBE 8 /* for external component */
|
||||
#define CODE_UDATA_SERVICE_PROCESS 9
|
||||
#define CODE_UDATA_SERVICE_IOCTL 10
|
||||
#define CODE_UDATA_REPORT_PUBLISH 11
|
||||
|
||||
/* linkkit event */
|
||||
#define EV_LINKKIT 0x0005
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
/* The time event is generated, auto filled by aos event system */
|
||||
uint32_t time;
|
||||
/* Event type, value < 0x1000 are used by aos system */
|
||||
uint16_t type;
|
||||
/* Defined according to type */
|
||||
uint16_t code;
|
||||
/* Defined according to type/code */
|
||||
unsigned long value;
|
||||
/* Defined according to type/code */
|
||||
unsigned long extra;
|
||||
} input_event_t;
|
||||
|
||||
/* Event callback */
|
||||
typedef void (*aos_event_cb)(input_event_t *event, void *private_data);
|
||||
/* Delayed execution callback */
|
||||
typedef void (*aos_call_t)(void *arg);
|
||||
/* Delayed execution callback */
|
||||
typedef void (*aos_poll_call_t)(int fd, void *arg);
|
||||
|
||||
/**
|
||||
* Register system event filter callback.
|
||||
*
|
||||
* @param[in] type event type interested.
|
||||
* @param[in] cb system event callback.
|
||||
* @param[in] priv private data past to cb.
|
||||
*
|
||||
* @return the operation status, 0 is OK, others is error.
|
||||
*/
|
||||
int aos_register_event_filter(uint16_t type, aos_event_cb cb, void *priv);
|
||||
|
||||
/**
|
||||
* Unregister native event callback.
|
||||
*
|
||||
* @param[in] type event type interested.
|
||||
* @param[in] cb system event callback.
|
||||
* @param[in] priv private data past to cb.
|
||||
*
|
||||
* @return the operation status, 0 is OK, others is error.
|
||||
*/
|
||||
int aos_unregister_event_filter(uint16_t type, aos_event_cb cb, void *priv);
|
||||
|
||||
/**
|
||||
* Post local event.
|
||||
*
|
||||
* @param[in] type event type.
|
||||
* @param[in] code event code.
|
||||
* @param[in] value event value.
|
||||
*
|
||||
* @return the operation status, 0 is OK,others is error.
|
||||
*/
|
||||
int aos_post_event(uint16_t type, uint16_t code, unsigned long value);
|
||||
|
||||
/**
|
||||
* Register a poll event in main loop.
|
||||
*
|
||||
* @param[in] fd poll fd.
|
||||
* @param[in] action action to be executed.
|
||||
* @param[in] param private data past to action.
|
||||
*
|
||||
* @return the operation status, 0 is OK,others is error.
|
||||
*/
|
||||
int aos_poll_read_fd(int fd, aos_poll_call_t action, void *param);
|
||||
|
||||
/**
|
||||
* Cancel a poll event to be executed in main loop.
|
||||
*
|
||||
* @param[in] fd poll fd.
|
||||
* @param[in] action action to be executed.
|
||||
* @param[in] param private data past to action.
|
||||
*/
|
||||
void aos_cancel_poll_read_fd(int fd, aos_poll_call_t action, void *param);
|
||||
|
||||
/**
|
||||
* Post a delayed action to be executed in main loop.
|
||||
*
|
||||
* @param[in] ms milliseconds to wait.
|
||||
* @param[in] action action to be executed.
|
||||
* @param[in] arg private data past to action.
|
||||
*
|
||||
* @return the operation status, 0 is OK,others is error.
|
||||
*/
|
||||
int aos_post_delayed_action(int ms, aos_call_t action, void *arg);
|
||||
|
||||
/**
|
||||
* Cancel a delayed action to be executed in main loop.
|
||||
*
|
||||
* @param[in] ms milliseconds to wait, -1 means don't care.
|
||||
* @param[in] action action to be executed.
|
||||
* @param[in] arg private data past to action.
|
||||
*/
|
||||
void aos_cancel_delayed_action(int ms, aos_call_t action, void *arg);
|
||||
|
||||
/**
|
||||
* Cancel a delayed action to be executed in main loop.
|
||||
*
|
||||
* @param[in] ms milliseconds to wait, -1 means don't care.
|
||||
* @param[in] action action to be executed.
|
||||
*/
|
||||
void aos_cancel_delayed_action_loose(int ms, aos_call_t action);
|
||||
/**
|
||||
* Schedule a callback in next event loop.
|
||||
* Unlike aos_post_delayed_action,
|
||||
* this function can be called from non-aos-main-loop context.
|
||||
|
||||
* @param[in] action action to be executed.
|
||||
* @param[in] arg private data past to action.
|
||||
*
|
||||
* @return the operation status, <0 is error,others is OK.
|
||||
*/
|
||||
int aos_schedule_call(aos_call_t action, void *arg);
|
||||
|
||||
typedef void *aos_loop_t;
|
||||
|
||||
/**
|
||||
* Init a per-task event loop.
|
||||
*
|
||||
* @return the handler of aos_loop_t,NULL failure,others success.
|
||||
*/
|
||||
aos_loop_t aos_loop_init(void);
|
||||
|
||||
/**
|
||||
* Get current event loop.
|
||||
*
|
||||
* @return default event loop.
|
||||
*/
|
||||
aos_loop_t aos_current_loop(void);
|
||||
|
||||
/**
|
||||
* Start event loop.
|
||||
*/
|
||||
void aos_loop_run(void);
|
||||
|
||||
/**
|
||||
* Exit event loop, aos_loop_run() will return.
|
||||
*/
|
||||
void aos_loop_exit(void);
|
||||
|
||||
/**
|
||||
* Free event loop resources.
|
||||
*/
|
||||
void aos_loop_destroy(void);
|
||||
|
||||
/**
|
||||
* Schedule a callback specified event loop.
|
||||
*
|
||||
* @param[in] loop event loop to be scheduled, NULL for default main loop.
|
||||
* @param[in] action action to be executed.
|
||||
* @param[in] arg private data past to action.
|
||||
*
|
||||
* @return the operation status, <0 is error,others is OK.
|
||||
*/
|
||||
int aos_loop_schedule_call(aos_loop_t *loop, aos_call_t action, void *arg);
|
||||
|
||||
/**
|
||||
* Schedule a work to be executed in workqueue.
|
||||
*
|
||||
* @param[in] ms milliseconds to delay before execution, 0 means immediately.
|
||||
* @param[in] action action to be executed.
|
||||
* @param[in] arg1 private data past to action.
|
||||
* @param[in] fini_cb finish callback to be executed after action is done in current event loop.
|
||||
* @param[in] arg2 data past to fini_cb.
|
||||
*
|
||||
* @return work handle,NULL failure,others is OK.
|
||||
*/
|
||||
void *aos_loop_schedule_work(int ms, aos_call_t action, void *arg1,
|
||||
aos_call_t fini_cb, void *arg2);
|
||||
|
||||
/**
|
||||
* Cancel a work.
|
||||
*
|
||||
* @param[in] work work to be cancelled.
|
||||
* @param[in] action action to be executed.
|
||||
* @param[in] arg1 private data past to action.
|
||||
*/
|
||||
void aos_cancel_work(void *work, aos_call_t action, void *arg1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AOS_YLOOP_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue