forked from xuos/xiuos
add connection function
This commit is contained in:
parent
4510a95e90
commit
d41517ab90
|
@ -11,11 +11,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file: xs_klist.h
|
* @file: list.h
|
||||||
* @brief: function declaration and structure defintion of list
|
* @brief: function declaration and structure defintion of list
|
||||||
* @version: 1.0
|
* @version: 1.0
|
||||||
* @author: AIIT XUOS Lab
|
* @author: AIIT XUOS Lab
|
||||||
* @date: 2020/3/2
|
* @date: 2021/6/23
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := adapter_4G.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file adapter_4G.c
|
||||||
|
* @brief Implement the connection 4G adapter function
|
||||||
|
* @version 1.1
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.25
|
||||||
|
*/
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := adapter_5G.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file adapter_5G.c
|
||||||
|
* @brief Implement the connection 5G adapter function
|
||||||
|
* @version 1.1
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.25
|
||||||
|
*/
|
||||||
|
|
|
@ -1,3 +1,61 @@
|
||||||
menuconfig SUPPORT_CONNECTION_FRAMEWORK
|
menuconfig SUPPORT_CONNECTION_FRAMEWORK
|
||||||
bool "support connection framework"
|
bool "support connection framework"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
if SUPPORT_CONNECTION_FRAMEWORK
|
||||||
|
menuconfig ADAPTER_LORA
|
||||||
|
bool "Using lora adapter device"
|
||||||
|
default n
|
||||||
|
if ADAPTER_LORA
|
||||||
|
source "$APP_DIR/Framework/connection/lora/Kconfig"
|
||||||
|
endif
|
||||||
|
|
||||||
|
menuconfig ADAPTER_4G
|
||||||
|
bool "Using 4G adapter device"
|
||||||
|
default n
|
||||||
|
if ADAPTER_4G
|
||||||
|
source "$APP_DIR/Framework/connection/4G/Kconfig"
|
||||||
|
endif
|
||||||
|
|
||||||
|
menuconfig ADAPTER_NB
|
||||||
|
bool "Using nbiot adapter device"
|
||||||
|
default n
|
||||||
|
if ADAPTER_NB
|
||||||
|
source "$APP_DIR/Framework/connection/nbiot/Kconfig"
|
||||||
|
endif
|
||||||
|
|
||||||
|
menuconfig ADAPTER_WIFI
|
||||||
|
bool "Using wifi adapter device"
|
||||||
|
default n
|
||||||
|
if ADAPTER_WIFI
|
||||||
|
source "$APP_DIR/Framework/connection/wifi/Kconfig"
|
||||||
|
endif
|
||||||
|
|
||||||
|
menuconfig ADAPTER_ETHERNET
|
||||||
|
bool "Using ethernet adapter device"
|
||||||
|
default n
|
||||||
|
if ADAPTER_ETHERNET
|
||||||
|
source "$APP_DIR/Framework/connection/ethernet/Kconfig"
|
||||||
|
endif
|
||||||
|
|
||||||
|
menuconfig ADAPTER_BLUETOOTH
|
||||||
|
bool "Using bluetooth adapter device"
|
||||||
|
default n
|
||||||
|
if ADAPTER_BLUETOOTH
|
||||||
|
source "$APP_DIR/Framework/connection/bluetooth/Kconfig"
|
||||||
|
endif
|
||||||
|
|
||||||
|
menuconfig ADAPTER_ZIGBEE
|
||||||
|
bool "Using zigbee adapter device"
|
||||||
|
default n
|
||||||
|
if ADAPTER_ZIGBEE
|
||||||
|
source "$APP_DIR/Framework/connection/zigbee/Kconfig"
|
||||||
|
endif
|
||||||
|
|
||||||
|
menuconfig ADAPTER_5G
|
||||||
|
bool "Using 5G adapter device"
|
||||||
|
default n
|
||||||
|
if ADAPTER_5G
|
||||||
|
source "$APP_DIR/Framework/connection/5G/Kconfig"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
|
@ -1,3 +1,35 @@
|
||||||
SRC_FILES := adapter.c
|
SRC_FILES := adapter.c
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADAPTER_LORA),y)
|
||||||
|
SRC_DIR += lora
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADAPTER_4G),y)
|
||||||
|
SRC_DIR += 4G
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADAPTER_NB),y)
|
||||||
|
SRC_DIR += nbiot
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADAPTER_WIFI),y)
|
||||||
|
SRC_DIR += wifi
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADAPTER_ETHERNET),y)
|
||||||
|
SRC_DIR += ethernet
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADAPTER_BLUETOOTH),y)
|
||||||
|
SRC_DIR += bluetooth
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADAPTER_ZIGBEE),y)
|
||||||
|
SRC_DIR += zigbee
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADAPTER_5G),y)
|
||||||
|
SRC_DIR += 5G
|
||||||
|
endif
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file adapter.c
|
* @file adapter.c
|
||||||
* @brief Implement the communication adapter framework management and API
|
* @brief Implement the connection adapter framework management and API
|
||||||
* @version 1.0
|
* @version 1.1
|
||||||
* @author AIIT XUOS Lab
|
* @author AIIT XUOS Lab
|
||||||
* @date 2021.05.10
|
* @date 2021.05.10
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +46,7 @@ int AdapterFrameworkInit(void)
|
||||||
* @param name - name string
|
* @param name - name string
|
||||||
* @return adapter device pointer
|
* @return adapter device pointer
|
||||||
*/
|
*/
|
||||||
struct Adapter *AdapterDeviceFindByName(const char *name)
|
AdapterType AdapterDeviceFindByName(const char *name)
|
||||||
{
|
{
|
||||||
struct Adapter *ret = NULL;
|
struct Adapter *ret = NULL;
|
||||||
struct DoublelistNode *node;
|
struct DoublelistNode *node;
|
||||||
|
@ -87,6 +87,8 @@ int AdapterDeviceRegister(struct Adapter *adapter)
|
||||||
AppDoubleListInsertNodeAfter(&adapter_list, &adapter->link);
|
AppDoubleListInsertNodeAfter(&adapter_list, &adapter->link);
|
||||||
PrivMutexAbandon(&adapter_list_lock);
|
PrivMutexAbandon(&adapter_list_lock);
|
||||||
|
|
||||||
|
adapter->adapter_status = REGISTERED;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +105,8 @@ int AdapterDeviceUnregister(struct Adapter *adapter)
|
||||||
AppDoubleListRmNode(&adapter->link);
|
AppDoubleListRmNode(&adapter->link);
|
||||||
PrivMutexAbandon(&adapter_list_lock);
|
PrivMutexAbandon(&adapter_list_lock);
|
||||||
|
|
||||||
|
adapter->adapter_status = UNREGISTERED;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +120,11 @@ int AdapterDeviceOpen(struct Adapter *adapter)
|
||||||
if (!adapter)
|
if (!adapter)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (INSTALL == adapter->adapter_status) {
|
||||||
|
printf("Device %s has already been opened. Just return\n", adapter->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
struct IpProtocolDone *ip_done = NULL;
|
struct IpProtocolDone *ip_done = NULL;
|
||||||
|
@ -131,7 +140,8 @@ int AdapterDeviceOpen(struct Adapter *adapter)
|
||||||
result = priv_done->open(adapter);
|
result = priv_done->open(adapter);
|
||||||
if (0 == result) {
|
if (0 == result) {
|
||||||
printf("Device %s open success.\n", adapter->name);
|
printf("Device %s open success.\n", adapter->name);
|
||||||
}else{
|
adapter->adapter_status = INSTALL;
|
||||||
|
} else {
|
||||||
if (adapter->fd) {
|
if (adapter->fd) {
|
||||||
PrivClose(adapter->fd);
|
PrivClose(adapter->fd);
|
||||||
adapter->fd = 0;
|
adapter->fd = 0;
|
||||||
|
@ -148,7 +158,8 @@ int AdapterDeviceOpen(struct Adapter *adapter)
|
||||||
result = ip_done->open(adapter);
|
result = ip_done->open(adapter);
|
||||||
if (0 == result) {
|
if (0 == result) {
|
||||||
printf("Device %s open success.\n", adapter->name);
|
printf("Device %s open success.\n", adapter->name);
|
||||||
}else{
|
adapter->adapter_status = INSTALL;
|
||||||
|
} else {
|
||||||
if (adapter->fd) {
|
if (adapter->fd) {
|
||||||
PrivClose(adapter->fd);
|
PrivClose(adapter->fd);
|
||||||
adapter->fd = 0;
|
adapter->fd = 0;
|
||||||
|
@ -174,6 +185,11 @@ int AdapterDeviceClose(struct Adapter *adapter)
|
||||||
if (!adapter)
|
if (!adapter)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (UNINSTALL == adapter->adapter_status) {
|
||||||
|
printf("Device %s has already been closed. Just return\n", adapter->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
struct IpProtocolDone *ip_done = NULL;
|
struct IpProtocolDone *ip_done = NULL;
|
||||||
|
@ -187,10 +203,12 @@ int AdapterDeviceClose(struct Adapter *adapter)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
result = priv_done->close(adapter);
|
result = priv_done->close(adapter);
|
||||||
if (0 == result)
|
if (0 == result) {
|
||||||
printf("%s successfully closed.\n", adapter->name);
|
printf("%s successfully closed.\n", adapter->name);
|
||||||
else
|
adapter->adapter_status = UNINSTALL;
|
||||||
|
} else {
|
||||||
printf("Closed %s failure.\n", adapter->name);
|
printf("Closed %s failure.\n", adapter->name);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -200,10 +218,12 @@ int AdapterDeviceClose(struct Adapter *adapter)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
result = ip_done->close(adapter);
|
result = ip_done->close(adapter);
|
||||||
if (0 == result)
|
if (0 == result) {
|
||||||
printf("%s successfully closed.\n", adapter->name);
|
printf("%s successfully closed.\n", adapter->name);
|
||||||
else
|
adapter->adapter_status = UNINSTALL;
|
||||||
|
} else {
|
||||||
printf("Closed %s failure.\n", adapter->name);
|
printf("Closed %s failure.\n", adapter->name);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -214,13 +234,13 @@ int AdapterDeviceClose(struct Adapter *adapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Read data from adapter
|
* @description: Receice data from adapter
|
||||||
* @param adapter - adapter device pointer
|
* @param adapter - adapter device pointer
|
||||||
* @param dst - buffer to save data
|
* @param dst - buffer to save data
|
||||||
* @param len - buffer length
|
* @param len - buffer length
|
||||||
* @return gotten data length
|
* @return gotten data length
|
||||||
*/
|
*/
|
||||||
ssize_t AdapterDeviceRead(struct Adapter *adapter, void *dst, size_t len)
|
ssize_t AdapterDeviceRecv(struct Adapter *adapter, void *dst, size_t len)
|
||||||
{
|
{
|
||||||
if (!adapter)
|
if (!adapter)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -240,19 +260,19 @@ ssize_t AdapterDeviceRead(struct Adapter *adapter, void *dst, size_t len)
|
||||||
|
|
||||||
return ip_done->recv(adapter->socket, dst, len);
|
return ip_done->recv(adapter->socket, dst, len);
|
||||||
} else {
|
} else {
|
||||||
printf("AdapterDeviceRead net_protocol %d not support\n", adapter->net_protocol);
|
printf("AdapterDeviceRecv net_protocol %d not support\n", adapter->net_protocol);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Write data to adapter
|
* @description: Send data to adapter
|
||||||
* @param adapter - adapter device pointer
|
* @param adapter - adapter device pointer
|
||||||
* @param src - data buffer
|
* @param src - data buffer
|
||||||
* @param len - data length
|
* @param len - data length
|
||||||
* @return length of data written
|
* @return length of data written
|
||||||
*/
|
*/
|
||||||
ssize_t AdapterDeviceWrite(struct Adapter *adapter, const void *src, size_t len)
|
ssize_t AdapterDeviceSend(struct Adapter *adapter, const void *src, size_t len)
|
||||||
{
|
{
|
||||||
if (!adapter)
|
if (!adapter)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -272,13 +292,13 @@ ssize_t AdapterDeviceWrite(struct Adapter *adapter, const void *src, size_t len)
|
||||||
|
|
||||||
return ip_done->send(adapter->socket, src, len);
|
return ip_done->send(adapter->socket, src, len);
|
||||||
} else {
|
} else {
|
||||||
printf("AdapterDeviceWrite net_protocol %d not support\n", adapter->net_protocol);
|
printf("AdapterDeviceSend net_protocol %d not support\n", adapter->net_protocol);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Configure adapter
|
* @description: Configure adapter device
|
||||||
* @param adapter - adapter device pointer
|
* @param adapter - adapter device pointer
|
||||||
* @param cmd - command
|
* @param cmd - command
|
||||||
* @param args - command parameter
|
* @param args - command parameter
|
||||||
|
@ -308,3 +328,89 @@ int AdapterDeviceControl(struct Adapter *adapter, int cmd, void *args)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Connect to a certain ip net, only support IP_PROTOCOL
|
||||||
|
* @param adapter - adapter device pointer
|
||||||
|
* @param ip - connect ip
|
||||||
|
* @param port - connect port
|
||||||
|
* @param ip_type - ip type, IPV4 or IPV6
|
||||||
|
* @return success: 0 , failure: other
|
||||||
|
*/
|
||||||
|
int AdapterDeviceConnect(struct Adapter *adapter, const char *ip, const char *port, enum IpType ip_type)
|
||||||
|
{
|
||||||
|
if (!adapter)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
|
||||||
|
printf("AdapterDeviceConnect not suuport private_protocol, please use join\n");
|
||||||
|
return -1;
|
||||||
|
} else if (IP_PROTOCOL == adapter->net_protocol) {
|
||||||
|
struct IpProtocolDone *ip_done = (struct IpProtocolDone *)adapter->done;
|
||||||
|
|
||||||
|
if (NULL == ip_done->connect)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return ip_done->connect(adapter, ip, port, ip_type);
|
||||||
|
} else {
|
||||||
|
printf("AdapterDeviceConnect net_protocol %d not support\n", adapter->net_protocol);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Join to a certain private net, only support PRIVATE_PROTOCOL
|
||||||
|
* @param adapter - adapter device pointer
|
||||||
|
* @param priv_net_group - private net group
|
||||||
|
* @return success: 0 , failure: other
|
||||||
|
*/
|
||||||
|
int AdapterDeviceJoin(struct Adapter *adapter, const char *priv_net_group)
|
||||||
|
{
|
||||||
|
if (!adapter)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
|
||||||
|
struct PrivProtocolDone *priv_done = (struct PrivProtocolDone *)adapter->done;
|
||||||
|
|
||||||
|
if (NULL == priv_done->join)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return priv_done->join(adapter, priv_net_group);
|
||||||
|
} else if (IP_PROTOCOL == adapter->net_protocol) {
|
||||||
|
printf("AdapterDeviceJoin not suuport ip_protocol, please use connect\n");
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
printf("AdapterDeviceJoin net_protocol %d not support\n", adapter->net_protocol);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Adapter disconnect from ip net or private net group
|
||||||
|
* @param adapter - adapter device pointer
|
||||||
|
* @return success: 0 , failure: other
|
||||||
|
*/
|
||||||
|
int AdapterDeviceDisconnect(struct Adapter *adapter)
|
||||||
|
{
|
||||||
|
if (!adapter)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
|
||||||
|
struct PrivProtocolDone *priv_done = (struct PrivProtocolDone *)adapter->done;
|
||||||
|
|
||||||
|
if (NULL == priv_done->disconnect)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return priv_done->disconnect(adapter);
|
||||||
|
} else if (IP_PROTOCOL == adapter->net_protocol) {
|
||||||
|
struct IpProtocolDone *ip_done = (struct IpProtocolDone *)adapter->done;
|
||||||
|
|
||||||
|
if (NULL == ip_done->disconnect)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return ip_done->disconnect(adapter->socket);
|
||||||
|
} else {
|
||||||
|
printf("AdapterDeviceDisconnect net_protocol %d not support\n", adapter->net_protocol);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file adapter.h
|
* @file adapter.h
|
||||||
* @brief Structure and function declarations of the communication adapter framework
|
* @brief Structure and function declarations of the connection adapter framework
|
||||||
* @version 1.0
|
* @version 1.1
|
||||||
* @author AIIT XUOS Lab
|
* @author AIIT XUOS Lab
|
||||||
* @date 2021.05.10
|
* @date 2021.05.10
|
||||||
*/
|
*/
|
||||||
|
@ -30,6 +30,10 @@
|
||||||
|
|
||||||
#define ADAPTER_BUFFSIZE 64
|
#define ADAPTER_BUFFSIZE 64
|
||||||
|
|
||||||
|
#define ADAPTER_AT_OPERATION 1
|
||||||
|
#define ADAPTER_LWIP_OPERATION 2
|
||||||
|
#define ADAPTER_RAWIP_OPERATION 3
|
||||||
|
|
||||||
#define ADAPTER_LORA_FUNC ((uint32_t)(1 << ATAPTER_LORA))
|
#define ADAPTER_LORA_FUNC ((uint32_t)(1 << ATAPTER_LORA))
|
||||||
#define ADAPTER_4G_FUNC ((uint32_t)(1 << ADAPTER_4G))
|
#define ADAPTER_4G_FUNC ((uint32_t)(1 << ADAPTER_4G))
|
||||||
#define ADAPTER_NBIOT_FUNC ((uint32_t)(1 << ADAPTER_NBIOT))
|
#define ADAPTER_NBIOT_FUNC ((uint32_t)(1 << ADAPTER_NBIOT))
|
||||||
|
@ -40,6 +44,7 @@
|
||||||
#define ADAPTER_5G_FUNC ((uint32_t)(1 << ADAPTER_5G))
|
#define ADAPTER_5G_FUNC ((uint32_t)(1 << ADAPTER_5G))
|
||||||
|
|
||||||
struct Adapter;
|
struct Adapter;
|
||||||
|
typedef struct Adapter *AdapterType;
|
||||||
|
|
||||||
struct Socket
|
struct Socket
|
||||||
{
|
{
|
||||||
|
@ -73,6 +78,20 @@ enum NetRoleType
|
||||||
ROLE_NONE,
|
ROLE_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum AdapterStatus
|
||||||
|
{
|
||||||
|
REGISTERED = 1,
|
||||||
|
UNREGISTERED,
|
||||||
|
INSTALL,
|
||||||
|
UNINSTALL,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum IpType
|
||||||
|
{
|
||||||
|
IPV4 = 1,
|
||||||
|
IPV6,
|
||||||
|
};
|
||||||
|
|
||||||
struct AdapterProductInfo
|
struct AdapterProductInfo
|
||||||
{
|
{
|
||||||
uint32_t functions;
|
uint32_t functions;
|
||||||
|
@ -85,7 +104,7 @@ struct IpProtocolDone
|
||||||
int (*open)(struct Adapter *adapter);
|
int (*open)(struct Adapter *adapter);
|
||||||
int (*close)(struct Adapter *adapter);
|
int (*close)(struct Adapter *adapter);
|
||||||
int (*ioctl)(struct Adapter *adapter, int cmd, void *args);
|
int (*ioctl)(struct Adapter *adapter, int cmd, void *args);
|
||||||
int (*connect)(struct Adapter *adapter, const char *ip, const char *port, uint8_t ip_type);
|
int (*connect)(struct Adapter *adapter, const char *ip, const char *port, enum IpType ip_type);
|
||||||
int (*send)(struct Socket *socket, const void *buf, size_t len);
|
int (*send)(struct Socket *socket, const void *buf, size_t len);
|
||||||
int (*recv)(struct Socket *socket, void *buf, size_t len);
|
int (*recv)(struct Socket *socket, void *buf, size_t len);
|
||||||
int (*disconnect)(struct Socket *socket);
|
int (*disconnect)(struct Socket *socket);
|
||||||
|
@ -112,6 +131,7 @@ struct Adapter
|
||||||
|
|
||||||
enum NetProtocolType net_protocol;
|
enum NetProtocolType net_protocol;
|
||||||
enum NetRoleType net_role;
|
enum NetRoleType net_role;
|
||||||
|
enum AdapterStatus adapter_status;
|
||||||
|
|
||||||
char buffer[ADAPTER_BUFFSIZE];
|
char buffer[ADAPTER_BUFFSIZE];
|
||||||
|
|
||||||
|
@ -120,4 +140,40 @@ struct Adapter
|
||||||
struct DoublelistNode link;
|
struct DoublelistNode link;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*Init adapter framework*/
|
||||||
|
int AdapterFrameworkInit(void);
|
||||||
|
|
||||||
|
/*Find adapter device by name*/
|
||||||
|
AdapterType AdapterDeviceFindByName(const char *name);
|
||||||
|
|
||||||
|
/*Register the adapter to the linked list*/
|
||||||
|
int AdapterDeviceRegister(struct Adapter *adapter);
|
||||||
|
|
||||||
|
/*Unregister the adapter from the linked list*/
|
||||||
|
int AdapterDeviceUnregister(struct Adapter *adapter);
|
||||||
|
|
||||||
|
/*Open adapter device*/
|
||||||
|
int AdapterDeviceOpen(struct Adapter *adapter);
|
||||||
|
|
||||||
|
/*Close adapter device*/
|
||||||
|
int AdapterDeviceClose(struct Adapter *adapter);
|
||||||
|
|
||||||
|
/*Receice data from adapter*/
|
||||||
|
ssize_t AdapterDeviceRecv(struct Adapter *adapter, void *dst, size_t len);
|
||||||
|
|
||||||
|
/*Send data to adapter*/
|
||||||
|
ssize_t AdapterDeviceSend(struct Adapter *adapter, const void *src, size_t len);
|
||||||
|
|
||||||
|
/*Configure adapter device*/
|
||||||
|
int AdapterDeviceControl(struct Adapter *adapter, int cmd, void *args);
|
||||||
|
|
||||||
|
/*Connect to a certain ip net, only support IP_PROTOCOL*/
|
||||||
|
int AdapterDeviceConnect(struct Adapter *adapter, const char *ip, const char *port, enum IpType ip_type);
|
||||||
|
|
||||||
|
/*Join to a certain private net, only support PRIVATE_PROTOCOL*/
|
||||||
|
int AdapterDeviceJoin(struct Adapter *adapter, const char *priv_net_group);
|
||||||
|
|
||||||
|
/*Adapter disconnect from ip net or private net group*/
|
||||||
|
int AdapterDeviceDisconnect(struct Adapter *adapter);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := adapter_bluetooth.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file adapter_bluetooth.c
|
||||||
|
* @brief Implement the connection bluetooth adapter function
|
||||||
|
* @version 1.1
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.25
|
||||||
|
*/
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := adapter_ethernet.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file adapter_ethernet.c
|
||||||
|
* @brief Implement the connection ethernet adapter function
|
||||||
|
* @version 1.1
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.25
|
||||||
|
*/
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := adapter_lora.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file adapter_lora.c
|
||||||
|
* @brief Implement the connection lora adapter function
|
||||||
|
* @version 1.1
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.25
|
||||||
|
*/
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := adapter_nbiot.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file adapter_nbiot.c
|
||||||
|
* @brief Implement the connection nbiot adapter function
|
||||||
|
* @version 1.1
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.25
|
||||||
|
*/
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := adapter_wifi.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file adapter_wifi.c
|
||||||
|
* @brief Implement the connection wifi adapter function
|
||||||
|
* @version 1.1
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.25
|
||||||
|
*/
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := adapter_zigbee.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file adapter_zigbee.c
|
||||||
|
* @brief Implement the connection zigbee adapter function
|
||||||
|
* @version 1.1
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.25
|
||||||
|
*/
|
Loading…
Reference in New Issue