forked from xuos/xiuos
Adjust directory structure
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 xs_adapter.h
|
||||
* @brief Adapter interface
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.22
|
||||
*/
|
||||
|
||||
#ifndef XS_ADAPTER_N
|
||||
#define XS_ADAPTER_N
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <xs_klist.h>
|
||||
#include <xs_adapter_def.h>
|
||||
|
||||
|
||||
|
||||
enum AdapterType {
|
||||
ADAPTER_LORA = 0, /* Lora */
|
||||
ADAPTER_4G , /* 4G */
|
||||
ADAPTER_NBIOT , /* NBIot */
|
||||
ADAPTER_WIFI , /* WIFI */
|
||||
ADAPTER_ETHERNET , /* ETHERNET */
|
||||
ADAPTER_BLUETOOTH , /* BLUETOOTH */
|
||||
ADAPTER_ZIGBEE , /* ZIGBEE */
|
||||
ADAPTER_5G , /* 5G */
|
||||
};
|
||||
enum MeshType{
|
||||
NET_P2P = 0,
|
||||
NET_ADHOC_SINGLE_GROUP,
|
||||
NET_ADHOC_MULTI_GROUP,
|
||||
};
|
||||
|
||||
enum NetRoleType{
|
||||
ROLE_TYPE_SLAVE = 1,
|
||||
ROLE_TYPE_MASTER,
|
||||
ROLE_TYPE_NONE,
|
||||
};
|
||||
|
||||
struct Adapter;
|
||||
struct AdapterDone {
|
||||
void (*NetAiitClose)(struct Adapter *padapter);
|
||||
int (*NetAiitOpen)(struct Adapter *padapter);
|
||||
int (*NetAiitJoin)(struct Adapter *padapter, int dev_type, char* net_id);
|
||||
int (*NetAiitSend)(struct Adapter *padapter, const char* data, int len, bool block, int time_out, int delay, send_success cb, void* param, void* reserved);
|
||||
int (*NetAiitReceive)(struct Adapter *padapter, char* rev_buffer, int buffer_len,int time_out, bool block, void* reserved);
|
||||
int (*NetAiitIoctl)(struct Adapter *padapter, int cmd, void *arg);
|
||||
};
|
||||
|
||||
struct Adapter
|
||||
{
|
||||
enum AdapterType type; /* type of adapter, such as lora adapter */
|
||||
enum NetRoleType net_role_type;
|
||||
enum MeshType mesh_type;
|
||||
struct AdapterDone done; /* socket-like APIs for data transferring */
|
||||
struct SysDoubleLinklistNode link; /* link list node */
|
||||
};
|
||||
typedef struct Adapter *adapter_t;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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 xs_adapter_at.h
|
||||
* @brief AdapterAT interface
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.22
|
||||
*/
|
||||
|
||||
#ifndef XS_ADAPTER_AT_H
|
||||
#define XS_ADAPTER_AT_H
|
||||
|
||||
#include "xs_adapter.h"
|
||||
#include <xs_adapter_at_agent.h>
|
||||
|
||||
#define SOCKET_STATUS_UNUSED (0)
|
||||
#define SOCKET_STATUS_INIT (1)
|
||||
#define SOCKET_STATUS_CONNECT (2)
|
||||
|
||||
#define SOCKET_TYPE_DGRAM (0)
|
||||
#define SOCKET_TYPE_STREAM (1)
|
||||
|
||||
#define SOCKET_PROTOCOL_TCP (6)
|
||||
#define SOCKET_PROTOCOL_UDP (17)
|
||||
|
||||
#define NET_TYPE_AF_INET (0)
|
||||
#define NET_TYPE_AF_INET6 (1)
|
||||
|
||||
#define SOCKET_MAX 8
|
||||
|
||||
struct Socket
|
||||
{
|
||||
uint8_t fd;
|
||||
uint8_t status ;
|
||||
struct AddressIpv4 src_ip;
|
||||
uint16_t src_port;
|
||||
struct AddressIpv4 dst_ip;
|
||||
uint16_t dst_port;
|
||||
uint8_t type;
|
||||
uint8_t af_type;
|
||||
uint8_t protocal;
|
||||
uint8 is_client;
|
||||
};
|
||||
|
||||
struct AdapterAT;
|
||||
struct ATDone
|
||||
{
|
||||
int (*ATOperateUp)(struct AdapterAT *adapterAT);
|
||||
int (*ATOperateDown)(struct AdapterAT *adapterAT);
|
||||
int (*ATOperateAddr)(struct AdapterAT *adapterAT, uint ip, uint gateway, uint netmask);
|
||||
int (*ATOperateDns)(struct AdapterAT *adapterAT, struct AddressIpv4 *dns_addr, uint8 dns_count);
|
||||
int (*ATOperateDHCP)(struct AdapterAT *adapterAT, bool enable);
|
||||
int (*ATPing)(struct AdapterAT *adapterAT, const char *destination, struct PingResult *ping_resp);
|
||||
int (*ATNetstat)(struct AdapterAT *adapterAT);
|
||||
int (*ATOperateDefault)(struct AdapterAT *adapterAT);
|
||||
|
||||
int (*ATSocketCreate)(struct AdapterAT *adapterAT , uint8_t socket_fd , uint8_t type , uint8_t af_type );
|
||||
int (*ATSocketConnect)(struct AdapterAT *adapterAT , uint8_t socket_fd , struct AddressIpv4 dst_ip , uint16_t dst_port, uint8 is_client);
|
||||
int (*ATSocketClose)(struct AdapterAT *adapterAT , uint8_t socket_fd );
|
||||
};
|
||||
|
||||
struct AdapterAT {
|
||||
struct Adapter parent;
|
||||
struct ATAgent *agent;
|
||||
struct AddressIpv4 ip;
|
||||
struct AddressIpv4 netmask;
|
||||
struct AddressIpv4 gateway;
|
||||
struct AddressIpv4 dns[DNS_COUNT];
|
||||
uint32 at_adapter_id;
|
||||
struct Socket socket[SOCKET_MAX];
|
||||
uint8 hardware_address_len;
|
||||
uint8 hardware_address[HW_MAX];
|
||||
uint16 flags;
|
||||
uint16 mtu;
|
||||
|
||||
void (*change_cb )(struct AdapterAT *adapterAT, enum CbType type, enum ChangeType ch_type_);
|
||||
|
||||
struct ATDone atdone;
|
||||
|
||||
struct SysDoubleLinklistNode link;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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 xs_adapter_at_agent.h
|
||||
* @brief AT proxy, auto receive AT reply and transparency data
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.22
|
||||
*/
|
||||
|
||||
#ifndef XS_ADAPTER_AT_CLIENT_H
|
||||
#define XS_ADAPTER_AT_CLIENT_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <bus_serial.h>
|
||||
|
||||
enum ReceiveMode
|
||||
{
|
||||
ENTM_MODE = 1,
|
||||
AT_MODE = 2,
|
||||
};
|
||||
|
||||
struct ATReply
|
||||
{
|
||||
char *reply_buffer;
|
||||
uint32 reply_max_len;
|
||||
uint32 reply_len;
|
||||
};
|
||||
typedef struct ATReply *ATReplyType;
|
||||
|
||||
struct ATAgent
|
||||
{
|
||||
char agent_name[NAME_NUM_MAX];
|
||||
int fd;
|
||||
|
||||
char *maintain_buffer;
|
||||
uint32 maintain_len;
|
||||
uint32 maintain_max;
|
||||
|
||||
int32 lock;
|
||||
|
||||
ATReplyType reply;
|
||||
int rsp_sem;
|
||||
|
||||
int32 at_handler;
|
||||
|
||||
#define ENTM_RECV_MAX 256
|
||||
char entm_recv_buf[ENTM_RECV_MAX];
|
||||
uint32 entm_recv_len;
|
||||
enum ReceiveMode receive_mode;
|
||||
int entm_rx_notice;
|
||||
};
|
||||
typedef struct ATAgent *ATAgentType;
|
||||
|
||||
int EntmSend(ATAgentType agent, const char *data, int len);
|
||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out);
|
||||
char *GetReplyText(ATReplyType reply);
|
||||
ATReplyType CreateATReply(uint32 reply_max_len);
|
||||
uint IpTint(char *ipstr);
|
||||
void SwapStr(char *str, int begin, int end);
|
||||
char* IpTstr(uint ipint);
|
||||
ATAgentType GetATAgent(const char *agent_name);
|
||||
int InitATAgent(const char *agent_name, const char *device_name, uint32 maintain_max, struct SerialCfgParam* pserial_cfg);
|
||||
int ParseATReply(char* str, const char *format, ...);
|
||||
void DeleteATReply(ATReplyType reply);
|
||||
int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char *cmd_expr, ...);
|
||||
|
||||
#define REPLY_TIME_OUT 3000
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 xs_adapter_at_ethernet.h
|
||||
* @brief Structure and function declarations of the connection ethernet
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.22
|
||||
*/
|
||||
|
||||
#ifndef XS_ADAPTER_AT_ETHERNET_H
|
||||
#define XS_ADAPTER_AT_ETHERNET_H
|
||||
|
||||
#include "xs_adapter.h"
|
||||
#include "xs_adapter_at.h"
|
||||
#include "xs_adapter_def.h"
|
||||
#include "xs_klist.h"
|
||||
|
||||
struct AdapterEthernet {
|
||||
struct AdapterAT parent; /* inherit from Adapter */
|
||||
|
||||
char vendor_name[NAME_LEN_MAX];
|
||||
char product_ID_ethernet[NAME_LEN_MAX];
|
||||
|
||||
struct SingleLinklistNode link;
|
||||
};
|
||||
|
||||
void EthernetClose(struct Adapter *padapter);
|
||||
int EthernetOpen(struct Adapter *padapter);
|
||||
int EthernetSend(struct Adapter *padapter, const char *data, int len, bool block, int time_out, int delay, send_success cb, void *param, void *p);
|
||||
int EthernetReceive(struct Adapter *padapter, char *rev_buffer, int buffer_len, int time_out, bool block, void *p);
|
||||
|
||||
int EthernetSetUp(struct AdapterAT *adapterAT);
|
||||
int EthernetDHCP(struct AdapterAT *adapterAT, bool enable);
|
||||
int EthernetPing(struct AdapterAT *adapterAT, const char *destination, struct PingResult *ping_resp);
|
||||
int EthernetNetstat(struct AdapterAT *adapterAT);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 xs_adapter_at_nbiot.h
|
||||
* @brief Structure and function declarations of the connection NBIoT
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.22
|
||||
*/
|
||||
|
||||
#ifndef XS_ADAPTER_AT_NBIOT_H
|
||||
#define XS_ADAPTER_AT_NBIOT_H
|
||||
|
||||
#include "xs_adapter.h"
|
||||
#include "xs_adapter_at.h"
|
||||
#include "xs_adapter_at_agent.h"
|
||||
#include "xs_adapter_def.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <user_api.h>
|
||||
|
||||
#define MAX_SOCKET_NUM 8
|
||||
|
||||
#define SOCKET_STATUS_UNUSED (0)
|
||||
#define SOCKET_STATUS_INIT (1)
|
||||
#define SOCKET_STATUS_CONNECT (2)
|
||||
|
||||
struct AdapterNBIoT {
|
||||
struct AdapterAT parent; /* inherit from Adapter */
|
||||
|
||||
char vendor_name[NAME_LEN_MAX];
|
||||
char product_ID_ethernet[NAME_LEN_MAX];
|
||||
|
||||
struct SingleLinklistNode link;
|
||||
};
|
||||
|
||||
int NbiotOpen(struct Adapter *padapter);
|
||||
|
||||
int NbiotSend(struct Adapter *padapter, const char* data, int len, bool block, int time_out, int delay, send_success cb, void* param, void* reserved);
|
||||
int NBIotRecv(struct Adapter *padapter, char *rev_buffer, int buffer_len, int time_out, bool block);
|
||||
|
||||
int NBIoTSocketConnect(struct AdapterAT *adapterAT , uint8_t socket_fd , struct AddressIpv4 dst_ip , uint16_t dst_port, uint8 is_client);
|
||||
int NBIoTSocketCreate(struct AdapterAT *adapterAT, uint8_t socket_fd, uint8_t type, uint8_t af_type );
|
||||
int NBIoTSocketClose(struct AdapterAT *adapterAT, uint8_t socket_fd );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 xs_adapter_at_wifi.h
|
||||
* @brief Structure and function declarations of the connection wifi
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.22
|
||||
*/
|
||||
|
||||
#ifndef XS_ADAPTER_AT_WIFI_H
|
||||
#define XS_ADAPTER_AT_WIFI_H
|
||||
|
||||
#include "xs_adapter.h"
|
||||
#include "xs_adapter_at.h"
|
||||
#include "xs_adapter_def.h"
|
||||
#include "xs_klist.h"
|
||||
|
||||
struct Adapterwifi {
|
||||
struct AdapterAT parent; /* inherit from Adapter */
|
||||
|
||||
char vendor_name[NAME_LEN_MAX];
|
||||
char product_id_wifi[NAME_LEN_MAX];
|
||||
|
||||
struct SingleLinklistNode link;
|
||||
};
|
||||
|
||||
void WifiClose(struct Adapter *padapter);
|
||||
int WifiOpen(struct Adapter *padapter);
|
||||
int WifiSend(struct Adapter *padapter, const char *data, int len, bool block, int time_out, int delay, send_success cb, void *param, void *p);
|
||||
int WifiReceive(struct Adapter *padapter, char *rev_buffer, int buffer_len, int time_out, bool block, void *p);
|
||||
|
||||
int WifiSetUp(struct AdapterAT *adapter_at);
|
||||
int WifiSetDown(struct AdapterAT *adapter_at);
|
||||
int WifiSetAddr(struct AdapterAT *adapter_at, uint ip, uint gateway, uint netmask);
|
||||
int WifiDHCP(struct AdapterAT *adapter_at, bool enable);
|
||||
int WifiPing(struct AdapterAT *adapter_at, const char *destination,struct PingResult *ping_resp);
|
||||
int WifiNetstat(struct AdapterAT *adapter_at);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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: xs_adapter_bluetooth.h
|
||||
* @brief: head file
|
||||
* @version: 1.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2021/4/25
|
||||
*
|
||||
*/
|
||||
#ifndef XS_ADAPTER_BLUETOOTH_H
|
||||
#define XS_ADAPTER_BLUETOOTH_H
|
||||
#include "xs_adapter.h"
|
||||
|
||||
struct AdapterBluetooth {
|
||||
struct Adapter parent; /* inherit from Adapter */
|
||||
const char * name; /* name of the adapter instance */
|
||||
|
||||
const char * device_type; /* type of the adapter instance */
|
||||
|
||||
|
||||
};
|
||||
typedef struct AdapterBluetooth *AdapterBluetooth_t;
|
||||
|
||||
int BluetoothOpen(struct Adapter *padapter);
|
||||
int BluetoothSend(struct Adapter *padapter, const char* data, int len, bool block, int time_out, int delay, send_success cb, void* param, void* reserved);
|
||||
int BluetoothReceive(struct Adapter *padapter, char* rev_buffer, int buffer_len,int time_out, bool block, void* reserved);
|
||||
void BluetoothClose(struct Adapter *padapter);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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 xs_adapter_def.h
|
||||
* @brief defines about adapter
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.22
|
||||
*/
|
||||
|
||||
#ifndef __XS_ADAPTER_DEF_H__
|
||||
#define __XS_ADAPTER_DEF_H__
|
||||
|
||||
#include "stdbool.h"
|
||||
|
||||
typedef void(*send_success)(void* param);
|
||||
|
||||
#define NAME_LEN_MAX 32
|
||||
|
||||
#define IPV6__ADDRESS_COUNT 3U
|
||||
#define DNS_COUNT 2U
|
||||
#define HW_MAX 8U
|
||||
|
||||
enum CbType
|
||||
{
|
||||
CB_ADDR_IP, /* IP address */
|
||||
CB_ADDR_NETMASK, /* subnet mask */
|
||||
CB_ADDR_GATEWAY, /* netmask */
|
||||
CB_ADDR_DNS_SERVER, /* dns server */
|
||||
CB_STATUS_UP, /* changed to 'up' */
|
||||
CB_STATUS_DOWN, /* changed to 'down' */
|
||||
CB_STATUS_LINK_UP, /* changed to 'link up' */
|
||||
CB_STATUS_LINK_DOWN, /* changed to 'link down' */
|
||||
CB_STATUS_INTERNET_UP, /* changed to 'internet up' */
|
||||
CB_STATUS_INTERNET_DOWN, /* changed to 'internet down' */
|
||||
CB_STATUS_DHCP_ENABLE, /* enable DHCP capability */
|
||||
CB_STATUS_DHCP_DISABLE, /* disable DHCP capability */
|
||||
};
|
||||
|
||||
enum ChangeType
|
||||
{
|
||||
ADDR_CHANGE,
|
||||
STATUS_CHANGE,
|
||||
};
|
||||
|
||||
struct AddressIpv4
|
||||
{
|
||||
uint32 ipv4;
|
||||
};
|
||||
|
||||
struct PingResult
|
||||
{
|
||||
struct AddressIpv4 ip_addr; /* response IP address */
|
||||
uint16 data_len; /* response data length */
|
||||
uint16 ttl; /* time to live */
|
||||
uint32 ticks; /* response time, unit tick */
|
||||
void *user_data; /* user-specific data */
|
||||
};
|
||||
|
||||
#define NBIOT_ADAPTER_ID 0x02U
|
||||
#define ETHERNET_ADAPTER_ID 0x03U
|
||||
#define WIFI_ADAPTER_ID 0x04U
|
||||
#define fourG_ADAPTER_ID 0x05U
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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 xs_adapterLora.h
|
||||
* @brief lora adhoc logic
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.22
|
||||
*/
|
||||
|
||||
#ifndef XS_ADAPTER_LORA_H
|
||||
#define XS_ADAPTER_LORA_H
|
||||
|
||||
#include "xs_adapter.h"
|
||||
|
||||
#define DEVNAME_LEN_MAX 32
|
||||
#define NETNAME_LEN_MAX 32
|
||||
#define CONNECTED_CLIENTS_MAX 512
|
||||
|
||||
#define CLIENT_SEND_CELL_LEN 120
|
||||
|
||||
|
||||
struct AdapterLora {
|
||||
struct Adapter parent; /* inherit from Adapter */
|
||||
const char * name; /* name of the adapter instance */
|
||||
|
||||
const char *deve_ui; /* Lora specific value */
|
||||
const char *app_key; /* Lora specific value */
|
||||
|
||||
int spi_lora_fd;
|
||||
};
|
||||
typedef struct AdapterLora *AdapterLoraT;
|
||||
|
||||
int LoraAdapterOpen(adapter_t padapter);
|
||||
void LoraAdapterCose(struct Adapter *padapter);
|
||||
int LoraAdapterSend(struct Adapter *padapter, const char* data, int len, bool block, int time_out, int delay, void *p);
|
||||
int LoraAdapterReceive(adapter_t padapter, char* rev_buffer, int buffer_len,int time_out, bool block, void *p);
|
||||
int LoraAdapterJoin(adapter_t sadapter, int dev_type, char* net_id);
|
||||
int LoraAdapterSendc2g(adapter_t padapter, const char *data, int len, bool block, int time_out, int delay, send_success cb, void* param, void *p);
|
||||
|
||||
// Client state machine
|
||||
enum LoraClientStatus
|
||||
{
|
||||
LORA_CLIENT_IDLE = 0,
|
||||
LORA_CLIENT_LOOKING4GATEWAY,
|
||||
LORA_CLIENT_CONNECTING2GATEWAY,
|
||||
LORA_CLIENT_CONNECTED,
|
||||
LORA_CLIENT_WAITTING_FOR_DISCONNECTED,
|
||||
LORA_CLIENT_DISCONNECTED,
|
||||
};
|
||||
|
||||
struct LoraClientStatusInfo
|
||||
{
|
||||
enum LoraClientStatus status;
|
||||
int user_id;
|
||||
char gateway_name[DEVNAME_LEN_MAX];
|
||||
char client_name[DEVNAME_LEN_MAX];
|
||||
};
|
||||
|
||||
enum LoraOpcode
|
||||
{
|
||||
LORA_OPCODE_START = 0xFFF0,
|
||||
LORA_JOIN_REQ = 0xFFF1,
|
||||
LORA_JOIN_RSP = 0xFFF2,
|
||||
LORA_HANDSHAKE_REQ = 0xFFF3,
|
||||
LORA_HANDSHAKE_RSP = 0xFFF4,
|
||||
LORA_C2G_DATA_REQ = 0xFFF5,
|
||||
LORA_C2G_DATA_RSP = 0xFFF6,
|
||||
LORA_CLOSE_REQ = 0xFFF7,
|
||||
LORA_CLOSE_RSP = 0xFFF8,
|
||||
LORA_OPCODE_END,
|
||||
};
|
||||
|
||||
enum WorkThreadStatus
|
||||
{
|
||||
WORK_THREAD_RX = 1,
|
||||
WORK_THREAD_TX,
|
||||
};
|
||||
|
||||
// pkg header
|
||||
typedef struct
|
||||
{
|
||||
int op_code;
|
||||
int length;
|
||||
}LoraHeader;
|
||||
|
||||
// Network access, handshake function protocol
|
||||
typedef struct
|
||||
{
|
||||
char net_id[NETNAME_LEN_MAX];
|
||||
}LoraProtoJoinReq;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char net_id[NETNAME_LEN_MAX];
|
||||
char gateway_name[DEVNAME_LEN_MAX];
|
||||
int signal_strength;
|
||||
int error_code;
|
||||
}LoraProtoJoinRsp;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char client_name[DEVNAME_LEN_MAX];
|
||||
char gateway_name[DEVNAME_LEN_MAX];
|
||||
}LoraProtoHandshakeReq;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char client_name[DEVNAME_LEN_MAX];
|
||||
char gateway_name[DEVNAME_LEN_MAX];
|
||||
int user_id;
|
||||
int error_code;
|
||||
}LoraProtoHandshakeRsp;
|
||||
|
||||
|
||||
// Data transmission protocol
|
||||
typedef struct
|
||||
{
|
||||
int user_id;
|
||||
int pkg_id;
|
||||
int data_len;
|
||||
int crc;
|
||||
}LoraProtoC2GDataReq;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int user_id;
|
||||
int ack_id;
|
||||
int data_len;
|
||||
int crc;
|
||||
}LoraProtoC2GDataRsp;
|
||||
|
||||
// Client active disconnect
|
||||
typedef struct
|
||||
{
|
||||
int user_id;
|
||||
}LoraProtoCloseReq;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int user_id;
|
||||
int error_code;
|
||||
}LoraProtoCloseRsp;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* data;
|
||||
int len;
|
||||
bool* prsp_flag;
|
||||
adapter_t padapter;
|
||||
}CheckRspParam;
|
||||
|
||||
typedef void(*send_success)(void* param);
|
||||
typedef struct
|
||||
{
|
||||
bool has_data;
|
||||
int crc;
|
||||
int pkg_id;
|
||||
char data[CLIENT_SEND_CELL_LEN];
|
||||
int data_len;
|
||||
send_success callback;
|
||||
void* param;
|
||||
}ClientSendCell;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char user_name[DEVNAME_LEN_MAX];
|
||||
int user_id;
|
||||
DoubleLinklistType link;
|
||||
}OnlineUser;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 xs_adapter_manager.h
|
||||
* @brief manager adapter list
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.22
|
||||
*/
|
||||
|
||||
#ifndef ADAPTER_MANAGER_H_
|
||||
#define ADAPTER_MANAGER_H_
|
||||
#include "xs_adapter.h"
|
||||
#include <xs_adapter_at.h>
|
||||
|
||||
void LoraAdapterInit();
|
||||
void LoraAdapterRegister(adapter_t padapter);
|
||||
void* LoraAdapterFind(char* name);
|
||||
|
||||
|
||||
void ATAdapterInit();
|
||||
void ATAdapterRegister(struct AdapterAT* at_adapter);
|
||||
void* ATAdapterFind(uint32 adapter_id);
|
||||
|
||||
void ZigbeeAdapterInit();
|
||||
void ZigbeeAdapterRegister(adapter_t padapter);
|
||||
void* ZigbeeAdapterFind(char* name);
|
||||
|
||||
void BluetoothAdapterInit();
|
||||
void BluetoothAdapterRegister(adapter_t padapter);
|
||||
void* BluetoothAdapterFind(char* name);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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: xs_adapter_zigbee.h
|
||||
* @brief: head file
|
||||
* @version: 1.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2021/4/25
|
||||
*
|
||||
*/
|
||||
#ifndef XS_ADAPTER_ZIGBEE_H
|
||||
#define XS_ADAPTER_ZIGBEE_H
|
||||
#include "xs_adapter.h"
|
||||
|
||||
struct AdapterZigbee {
|
||||
struct Adapter parent; /* inherit from Adapter */
|
||||
const char * name; /* name of the adapter instance */
|
||||
|
||||
const char * device_type; /* type of the adapter instance */
|
||||
|
||||
|
||||
};
|
||||
typedef struct AdapterZigbee *adapterZigbee_t;
|
||||
|
||||
int ZigbeeOpen(struct Adapter *padapter);
|
||||
int ZigbeeSend(struct Adapter *padapter, const char* data, int len, bool block, int time_out, int delay, send_success cb, void* param, void* reserved);
|
||||
int ZigbeeReceive(struct Adapter *padapter, char* rev_buffer, int buffer_len,int time_out, bool block, void* reserved);
|
||||
void ZigbeeClose(struct Adapter *padapter);
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user