mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2025-07-31 19:31:05 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
28
Living_SDK/kernel/protocols/mesh/include/ip/lwip_adapter.h
Normal file
28
Living_SDK/kernel/protocols/mesh/include/ip/lwip_adapter.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef UR_LWIP_ADAPTER_H
|
||||
#define UR_LWIP_ADAPTER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "lwip/ip.h"
|
||||
|
||||
ur_error_t ur_adapter_interface_init(void);
|
||||
|
||||
ur_error_t ur_adapter_interface_up(void);
|
||||
ur_error_t ur_adapter_interface_down(void);
|
||||
ur_error_t ur_adapter_interface_update(void);
|
||||
struct netif *ur_adapter_get_netif(void);
|
||||
const void *ur_adapter_get_default_ipaddr(void);
|
||||
const void *ur_adapter_get_mcast_ipaddr(void);
|
||||
ur_error_t ur_adapter_resolve_ip(const void *ip, ur_addr_t *addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UR_LWIP_ADAPTER_H */
|
||||
50
Living_SDK/kernel/protocols/mesh/include/umesh.h
Normal file
50
Living_SDK/kernel/protocols/mesh/include/umesh.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef UMESH_MESH_H
|
||||
#define UMESH_MESH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "umesh_config.h"
|
||||
#include "umesh_types.h"
|
||||
|
||||
ur_error_t umesh_output_sid(struct pbuf *buf, uint16_t netid, uint16_t sid);
|
||||
ur_error_t umesh_output_uuid(struct pbuf *buf, uint8_t *uuid);
|
||||
|
||||
/* for mesh layer */
|
||||
ur_error_t umesh_init(node_mode_t mode);
|
||||
ur_error_t umesh_start(void);
|
||||
bool umesh_is_initialized(void);
|
||||
ur_error_t umesh_stop(void);
|
||||
ur_error_t umesh_register_callback(ur_adapter_callback_t *callback);
|
||||
|
||||
/* per device API */
|
||||
uint8_t umesh_get_device_state(void);
|
||||
uint8_t umesh_get_mode(void);
|
||||
ur_error_t umesh_set_mode(uint8_t mode);
|
||||
|
||||
const mac_address_t *umesh_get_mac_address(media_type_t type);
|
||||
uint16_t umesh_get_meshnetid(void);
|
||||
uint16_t umesh_get_sid(void);
|
||||
uint16_t umesh_get_meshnetsize(void);
|
||||
|
||||
slist_t *umesh_get_nbrs(media_type_t type);
|
||||
|
||||
bool umesh_is_mcast_subscribed(const ur_ip6_addr_t *addr);
|
||||
|
||||
void umesh_get_extnetid(umesh_extnetid_t *extnetid);
|
||||
ur_error_t umesh_set_extnetid(const umesh_extnetid_t *extnetid);
|
||||
|
||||
/* cli */
|
||||
typedef void (*cmd_cb_t)(char *buf, int len, void *priv);
|
||||
void umesh_cli_cmd(char *buf, int len, cmd_cb_t cb, void *priv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UMESH_MESH_H */
|
||||
43
Living_SDK/kernel/protocols/mesh/include/umesh_80211.h
Normal file
43
Living_SDK/kernel/protocols/mesh/include/umesh_80211.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef UMESH_80211_H
|
||||
#define UMESH_80211_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <umesh_hal.h>
|
||||
|
||||
#define MESH_DATA_OFF 32
|
||||
|
||||
#define OFF_DST 4
|
||||
#define OFF_SRC 10
|
||||
#define OFF_BSS 16
|
||||
|
||||
typedef struct {
|
||||
uint8_t version: 2;
|
||||
uint8_t type: 2;
|
||||
uint8_t subtype: 4;
|
||||
uint8_t tods: 1;
|
||||
uint8_t fromds: 1;
|
||||
uint8_t morefrag: 1;
|
||||
uint8_t retry: 1;
|
||||
uint8_t pwrmgt: 1;
|
||||
uint8_t moredata: 1;
|
||||
uint8_t wep: 1;
|
||||
uint8_t order: 1;
|
||||
} __attribute__((packed)) mac80211_fctl_t;
|
||||
|
||||
int umesh_80211_make_frame(umesh_hal_module_t *module, frame_t *frame, mac_address_t *dest, void *fpkt);
|
||||
bool umesh_80211_filter_frame(umesh_hal_module_t *module, uint8_t *pkt, int count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UMESH_80211_H */
|
||||
27
Living_SDK/kernel/protocols/mesh/include/umesh_config.h
Normal file
27
Living_SDK/kernel/protocols/mesh/include/umesh_config.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef UMESH_CONFIG_H
|
||||
#define UMESH_CONFIG_H
|
||||
|
||||
#define MAX_NEIGHBORS_NUM 32
|
||||
|
||||
#define ATTACH_REQUEST_RETRY_TIMES 2
|
||||
#define ATTACH_REQUEST_INTERVAL 1000
|
||||
|
||||
#ifdef CONFIG_AOS_MESH_LOWPOWER
|
||||
#define SCHEDULE_SLOTS_SIZE 3
|
||||
#define SCHEDULE_SLOT_INTERVAL 6000
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_AOS_MESH_AUTH
|
||||
#define AUTH_REQUEST_RETRY_TIMES 2
|
||||
#define AUTH_RELAY_RETRY_TIMES 2
|
||||
|
||||
#define ID2_LISTEN_PORT 1234
|
||||
#define ID2_SERVER_PORT 2345
|
||||
#define ID2_SERVER_ADDR "192.168.16.188" // testbed sp server ip
|
||||
#endif
|
||||
|
||||
#endif
|
||||
408
Living_SDK/kernel/protocols/mesh/include/umesh_hal.h
Normal file
408
Living_SDK/kernel/protocols/mesh/include/umesh_hal.h
Normal file
|
|
@ -0,0 +1,408 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef UMESH_HAL_H
|
||||
#define UMESH_HAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "umesh_types.h"
|
||||
|
||||
struct umesh_hal_module_s;
|
||||
|
||||
/**
|
||||
* Callback function when ucast frame send done
|
||||
*
|
||||
* @param[out] context The context
|
||||
* @param[in] frame The frame that has been sent
|
||||
* @param[out] error The error code for this sent frame
|
||||
*/
|
||||
typedef void (*umesh_handle_sent_ucast_t)(void *context,
|
||||
frame_t *frame, int error);
|
||||
|
||||
/**
|
||||
* Callback function when bcast frame send done
|
||||
*
|
||||
* @param[out] context The context
|
||||
* @param[in] frame The frame that has been sent
|
||||
* @param[out] error The error code for this sent frame
|
||||
*/
|
||||
typedef void (*umesh_handle_sent_bcast_t)(void *context,
|
||||
frame_t *frame, int error);
|
||||
|
||||
/**
|
||||
* Callback function when frame received
|
||||
*
|
||||
* @param[out] context The context
|
||||
* @param[in] frame The received frame
|
||||
* @param[out] frame_info The frame info that needs by uppder layer
|
||||
* @param[out] error The error code for this received data frame
|
||||
*/
|
||||
typedef void (*umesh_handle_received_frame_t)(void *context, frame_t *frame,
|
||||
frame_info_t *frame_info,
|
||||
int error);
|
||||
|
||||
/**
|
||||
* Callback function when received commands
|
||||
*
|
||||
* @param[in] buf The received commands
|
||||
* @param[in] length The commands length
|
||||
*/
|
||||
typedef void (*umesh_cli_input_t)(const uint8_t *buf, uint16_t length);
|
||||
|
||||
typedef struct umesh_hal_module_s {
|
||||
struct {
|
||||
dlist_t list;
|
||||
int magic;
|
||||
const char *name;
|
||||
void *priv_dev; /* Driver may want to describe it */
|
||||
} base;
|
||||
media_type_t type;
|
||||
umesh_handle_received_frame_t receiver;
|
||||
|
||||
int (*umesh_hal_init)(struct umesh_hal_module_s *module, void *config);
|
||||
int (*umesh_hal_enable)(struct umesh_hal_module_s *module);
|
||||
int (*umesh_hal_disable)(struct umesh_hal_module_s *module);
|
||||
|
||||
/* send ucast frame */
|
||||
int (*umesh_hal_send_ucast_request)(struct umesh_hal_module_s *module,
|
||||
frame_t *frame, mac_address_t *dest,
|
||||
umesh_handle_sent_ucast_t sent,
|
||||
void *context);
|
||||
/* send bcast frame */
|
||||
int (*umesh_hal_send_bcast_request)(struct umesh_hal_module_s *module,
|
||||
frame_t *frame,
|
||||
umesh_handle_sent_bcast_t sent,
|
||||
void *context);
|
||||
|
||||
/* register call back when received packet */
|
||||
int (*umesh_hal_register_receiver)(struct umesh_hal_module_s *module,
|
||||
umesh_handle_received_frame_t received, void *context);
|
||||
|
||||
/* request low layer to transmit beacons intervally*/
|
||||
int (*umesh_hal_get_bcast_mtu)(struct umesh_hal_module_s *module);
|
||||
int (*umesh_hal_get_ucast_mtu)(struct umesh_hal_module_s *module);
|
||||
|
||||
int (*umesh_hal_set_channel)(struct umesh_hal_module_s *module, uint8_t channel);
|
||||
int (*umesh_hal_get_channel)(struct umesh_hal_module_s *module);
|
||||
int (*umesh_hal_get_chnlist)(struct umesh_hal_module_s *module, const uint8_t **chnlist);
|
||||
|
||||
int (*umesh_hal_set_txpower)(struct umesh_hal_module_s *module, int8_t txpower);
|
||||
int (*umesh_hal_get_txpower)(struct umesh_hal_module_s *module);
|
||||
|
||||
int (*umesh_hal_set_extnetid)(struct umesh_hal_module_s *module,
|
||||
const umesh_extnetid_t *extnetid);
|
||||
void (*umesh_hal_get_extnetid)(struct umesh_hal_module_s *module,
|
||||
umesh_extnetid_t *extnetid);
|
||||
const mac_address_t *(*umesh_hal_get_mac_address)(
|
||||
struct umesh_hal_module_s *module);
|
||||
|
||||
int (*umesh_hal_radio_wakeup)(struct umesh_hal_module_s *module);
|
||||
int (*umesh_hal_radio_sleep)(struct umesh_hal_module_s *module);
|
||||
|
||||
const frame_stats_t *(*umesh_hal_get_stats)(struct umesh_hal_module_s *module);
|
||||
} umesh_hal_module_t;
|
||||
|
||||
/**
|
||||
* Initialize all registed HAL modules.
|
||||
*
|
||||
* @return
|
||||
* Initalization result, 0 if success, nonzero if fail
|
||||
*/
|
||||
int hal_umesh_init(void);
|
||||
|
||||
/**
|
||||
* Get the defaut umesh HAL
|
||||
*
|
||||
* The system may have more than 1 mesh HAL instances.
|
||||
*
|
||||
* @return
|
||||
* Instance pointer or NULL
|
||||
*/
|
||||
umesh_hal_module_t *hal_umesh_get_default_module(void);
|
||||
|
||||
/**
|
||||
* Get the next umesh HAL
|
||||
*
|
||||
* The system may have more than 1 mesh HAL instances.
|
||||
*
|
||||
* @return
|
||||
* Instance pointer or NULL
|
||||
*/
|
||||
umesh_hal_module_t *hal_umesh_get_next_module(umesh_hal_module_t *cur);
|
||||
|
||||
/**
|
||||
* Register one or more mesh instances to HAL.
|
||||
*
|
||||
* @param[in] module The HAL module to be registered
|
||||
*/
|
||||
void hal_umesh_register_module(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Enable a umesh HAL module, which usually powers on its hardware
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* Enable result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_enable(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Disable a umesh HAL module, which usually power off its hardware
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* Disable result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_disable(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Send HAL ucast frame request
|
||||
*
|
||||
* @param[in] module The HAL module to send data to; if NULL, the default module will be used
|
||||
* @param[in] frame The frame buffer that contains the data
|
||||
* @param[in] dest The destination of this frame.
|
||||
* @param[in] sent The callback function to be called after hardware send data finish
|
||||
* @param[in] context The context
|
||||
*
|
||||
* @return
|
||||
* Send frame request result, 0 if success, -1 if fail, -2 if drop
|
||||
*/
|
||||
int hal_umesh_send_ucast_request(umesh_hal_module_t *module,
|
||||
frame_t *frame, mac_address_t *dest,
|
||||
umesh_handle_sent_ucast_t sent, void *context);
|
||||
|
||||
/**
|
||||
* Send HAL bcast frame request
|
||||
*
|
||||
* @param[in] module The HAL module to send data to; if NULL, the default module will be used
|
||||
* @param[in] frame The frame buffer that contains the data
|
||||
* @param[in] sent The callback function to be called after hardware send data finish
|
||||
* @param[in] context The context
|
||||
*
|
||||
* @return
|
||||
* Send frame request result, 0 if success, -1 if fail, -2 if drop
|
||||
*/
|
||||
int hal_umesh_send_bcast_request(umesh_hal_module_t *module,
|
||||
frame_t *frame,
|
||||
umesh_handle_sent_bcast_t sent, void *context);
|
||||
|
||||
/**
|
||||
* Register data frame receiver callback function
|
||||
*
|
||||
* @param[in] module The HAL module to receive data from; if NULL, the default module will be used
|
||||
* @param[in] received The callback function to be called after hardware received data
|
||||
* @param[in] context The context
|
||||
*
|
||||
* @return
|
||||
* Register receiver result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_register_receiver(umesh_hal_module_t *module,
|
||||
umesh_handle_received_frame_t received, void *context);
|
||||
|
||||
/**
|
||||
* Request HAL to send beacons
|
||||
*
|
||||
* @param[in] module The HAL module to send data to; if NULL, the default module will be used
|
||||
* @param[in] frame The frame buffer that contains the data and config information
|
||||
* @param[in] dest The destination of this frame.
|
||||
* @param[in] max_interval The max interval that low layer needs to transmit beacon
|
||||
*
|
||||
* @return
|
||||
* The result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_start_beacons(umesh_hal_module_t *module,
|
||||
frame_t *frame, mac_address_t *dest,
|
||||
uint16_t max_interval);
|
||||
|
||||
/**
|
||||
* Stop HAL to send beacons
|
||||
*
|
||||
* @param[in] module The HAL module to send data to; if NULL, the default module will be used
|
||||
*
|
||||
* @return
|
||||
* The result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_stop_beacons(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Set HAL broadcast MTU, MTU is normally decided by HAL.
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
* @param[in] mtu The MTU to be set
|
||||
*
|
||||
* @return
|
||||
* Set media configuration result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_set_bcast_mtu(umesh_hal_module_t *module, uint16_t mtu);
|
||||
|
||||
/**
|
||||
* Get HAL broadcast MTU
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* The MTU, -1 if fail
|
||||
*/
|
||||
int hal_umesh_get_bcast_mtu(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Set HAL unicast MTU, MTU is normally decided by HAL.
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
* @param[in] mtu The MTU to be set
|
||||
*
|
||||
* @return
|
||||
* Set media configuration result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_set_ucast_mtu(umesh_hal_module_t *module, uint16_t mtu);
|
||||
|
||||
/**
|
||||
* Get HAL unicast MTU
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* The MTU, -1 if fail
|
||||
*/
|
||||
int hal_umesh_get_ucast_mtu(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Set channel
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
* @param[in] channel The channel to be set
|
||||
*
|
||||
* @return
|
||||
* Set media configuration result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_set_channel(umesh_hal_module_t *module, uint8_t channel);
|
||||
|
||||
/**
|
||||
* Get channel
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* The channel, -1 if fail
|
||||
*/
|
||||
int hal_umesh_get_channel(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Get channel list
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
* @param[in] chnlist Pointer to store the unicast channel list
|
||||
*
|
||||
* @return
|
||||
* The number of unicast channels, -1 if fail
|
||||
*/
|
||||
int hal_umesh_get_chnlist(umesh_hal_module_t *module, const uint8_t **chnlist);
|
||||
|
||||
/**
|
||||
* Set transmit power
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
* @param[in] txpower The transmit power to be set
|
||||
*
|
||||
* @return
|
||||
* Set media configuration result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_set_txpower(umesh_hal_module_t *module, int8_t txpower);
|
||||
|
||||
/**
|
||||
* Get transmit power
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* The transmit power, -1 if fail
|
||||
*/
|
||||
int hal_umesh_get_txpower(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Set extension meshnetid
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
* @param[in] extnetid The extension meshnetid to be set
|
||||
*
|
||||
* @return
|
||||
* Set media configuration result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_set_extnetid(umesh_hal_module_t *module,
|
||||
const umesh_extnetid_t *extnetid);
|
||||
|
||||
/**
|
||||
* Get extension meshnetid
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
* @param[in] extnetid The extension meshnetid to be get
|
||||
*
|
||||
*/
|
||||
void hal_umesh_get_extnetid(umesh_hal_module_t *module,
|
||||
umesh_extnetid_t *extnetid);
|
||||
|
||||
/**
|
||||
* Set HAL mac address.
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
* @param[in] addr The mac address to be set
|
||||
*
|
||||
* @return
|
||||
* Set media configuration result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_set_mac_address(umesh_hal_module_t *module,
|
||||
const mac_address_t *addr);
|
||||
|
||||
/**
|
||||
* Get HAL mac address.
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* The mac address, NULL if fail
|
||||
*/
|
||||
const mac_address_t *hal_umesh_get_mac_address(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Put umesh radio in wakeup state.
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* Set result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_radio_wakeup(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Sleep umesh radio sleep state.
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* Set result, 0 if success, -1 if fail
|
||||
*/
|
||||
int hal_umesh_radio_sleep(umesh_hal_module_t *module);
|
||||
|
||||
/**
|
||||
* Read umesh HAL frame stats.
|
||||
*
|
||||
* @param[in] module The HAL module to be operated; if NULL, the default module will be operated
|
||||
*
|
||||
* @return
|
||||
* The HAL frame stats, NULL if fail
|
||||
*/
|
||||
const frame_stats_t *hal_umesh_get_stats(umesh_hal_module_t *module);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UMESH_HAL_H */
|
||||
248
Living_SDK/kernel/protocols/mesh/include/umesh_types.h
Normal file
248
Living_SDK/kernel/protocols/mesh/include/umesh_types.h
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef UMESH_TYPES_H
|
||||
#define UMESH_TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "aos/list.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
MESH_VERSION_1 = 1,
|
||||
};
|
||||
|
||||
typedef enum ur_error_s {
|
||||
UR_ERROR_NONE = 0,
|
||||
UR_ERROR_FAIL = 1,
|
||||
UR_ERROR_BUSY = 2,
|
||||
UR_ERROR_DROP = 3,
|
||||
UR_ERROR_MEM = 4,
|
||||
UR_ERROR_ROUTE = 5,
|
||||
UR_ERROR_PARSE = 6,
|
||||
UR_ERROR_ADDRESS_QUERY = 7,
|
||||
UR_ERROR_BUFFER = 8,
|
||||
} ur_error_t;
|
||||
|
||||
typedef enum media_type_s {
|
||||
MEDIA_TYPE_DFL = 0,
|
||||
MEDIA_TYPE_WIFI = 1,
|
||||
MEDIA_TYPE_BLE = 2,
|
||||
MEDIA_TYPE_15_4 = 3,
|
||||
} media_type_t;
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
|
||||
enum {
|
||||
UR_IP6_ADDR_SIZE = 16,
|
||||
MESH_IP4_ADDR_SIZE = 4,
|
||||
};
|
||||
|
||||
enum {
|
||||
SHORT_ADDR_SIZE = 2,
|
||||
EXT_ADDR_SIZE = 8,
|
||||
EXT_NETID_SIZE = 6,
|
||||
};
|
||||
|
||||
typedef struct ur_ip6_addr_s {
|
||||
union {
|
||||
uint8_t m8[UR_IP6_ADDR_SIZE];
|
||||
uint16_t m16[UR_IP6_ADDR_SIZE / sizeof(uint16_t)];
|
||||
uint32_t m32[UR_IP6_ADDR_SIZE / sizeof(uint32_t)];
|
||||
};
|
||||
} __attribute__((packed)) ur_ip6_addr_t;
|
||||
|
||||
typedef struct ur_ip4_addr_s {
|
||||
union {
|
||||
uint8_t m8[MESH_IP4_ADDR_SIZE];
|
||||
uint16_t m16[MESH_IP4_ADDR_SIZE / sizeof(uint16_t)];
|
||||
uint32_t m32;
|
||||
};
|
||||
} __attribute__((packed)) ur_ip4_addr_t;
|
||||
|
||||
typedef struct ur_ip6_prefix_s {
|
||||
ur_ip6_addr_t prefix;
|
||||
uint8_t length;
|
||||
} __attribute__((packed)) ur_ip6_prefix_t;
|
||||
|
||||
enum {
|
||||
UR_IP6_HLEN = 40,
|
||||
MESH_IP4_HLEN = 20,
|
||||
UR_UDP_HLEN = 8,
|
||||
};
|
||||
|
||||
typedef struct mac_address_s {
|
||||
union {
|
||||
uint64_t value;
|
||||
uint16_t short_addr;
|
||||
uint8_t addr[EXT_ADDR_SIZE];
|
||||
};
|
||||
uint8_t len;
|
||||
} mac_address_t;
|
||||
|
||||
typedef struct ur_addr_s {
|
||||
mac_address_t addr;
|
||||
uint16_t netid;
|
||||
} ur_addr_t;
|
||||
|
||||
typedef struct umesh_extnetid_s {
|
||||
uint8_t netid[EXT_NETID_SIZE];
|
||||
uint8_t len;
|
||||
} umesh_extnetid_t;
|
||||
|
||||
typedef struct frame_s {
|
||||
uint8_t *data;
|
||||
uint16_t len;
|
||||
uint8_t key_index;
|
||||
} frame_t;
|
||||
|
||||
typedef struct frame_info_s {
|
||||
mac_address_t peer;
|
||||
uint8_t channel;
|
||||
int8_t rssi;
|
||||
int8_t key_index;
|
||||
} frame_info_t;
|
||||
|
||||
typedef struct channel_s {
|
||||
uint16_t channel;
|
||||
uint16_t wifi_channel;
|
||||
uint16_t hal_ucast_channel;
|
||||
uint16_t hal_bcast_channel;
|
||||
} channel_t;
|
||||
|
||||
struct pbuf;
|
||||
typedef ur_error_t (* adapter_input_t)(struct pbuf *buf);
|
||||
typedef ur_error_t (* adapter_interface_up_t)(void);
|
||||
typedef ur_error_t (* adapter_interface_down_t)(void);
|
||||
typedef ur_error_t (* adapter_interface_update_t)(void);
|
||||
typedef struct ur_adapter_callback_s {
|
||||
slist_t next;
|
||||
adapter_input_t input;
|
||||
adapter_interface_up_t interface_up;
|
||||
adapter_interface_down_t interface_down;
|
||||
adapter_interface_update_t interface_update;
|
||||
} ur_adapter_callback_t;
|
||||
|
||||
typedef struct frame_stats_s {
|
||||
uint32_t in_frames;
|
||||
uint32_t out_frames;
|
||||
} frame_stats_t;
|
||||
|
||||
typedef struct ur_link_stats_s {
|
||||
uint32_t in_frames;
|
||||
uint32_t in_command;
|
||||
uint32_t in_data;
|
||||
uint32_t in_filterings;
|
||||
uint32_t in_drops;
|
||||
|
||||
uint32_t out_frames;
|
||||
uint32_t out_command;
|
||||
uint32_t out_data;
|
||||
uint32_t out_errors;
|
||||
|
||||
uint16_t send_queue_size;
|
||||
uint16_t recv_queue_size;
|
||||
|
||||
bool sending;
|
||||
uint16_t sending_timeouts;
|
||||
} ur_link_stats_t;
|
||||
|
||||
enum {
|
||||
UMESH_1, // 0
|
||||
MESH_FORWARDER_1, // 1
|
||||
MESH_FORWARDER_2, // 2
|
||||
MESH_FORWARDER_3, // 3
|
||||
MESH_MGMT_1, // 4
|
||||
MESH_MGMT_2, // 5
|
||||
MESH_MGMT_3, // 6
|
||||
MESH_MGMT_4, // 7
|
||||
MESH_MGMT_5, // 8
|
||||
MESH_MGMT_6, // 9
|
||||
MESH_MGMT_7, // 10
|
||||
ADDRESS_MGMT_1, // 11
|
||||
ADDRESS_MGMT_2, // 12
|
||||
ADDRESS_MGMT_3, // 13
|
||||
ADDRESS_MGMT_4, // 14
|
||||
NETWORK_MGMT_1, // 15
|
||||
NETWORK_MGMT_2, // 16
|
||||
LOWPAN6_2, // 18
|
||||
LINK_MGMT_1, // 19
|
||||
LINK_MGMT_2, // 20
|
||||
LINK_MGMT_3, // 21
|
||||
ROUTER_MGR_1, // 22
|
||||
DIAGS_1, // 23
|
||||
DIAGS_2, // 24
|
||||
UT_MSG, // 25
|
||||
UMESH_2, // 26
|
||||
MSG_DEBUG_INFO_SIZE, // 27
|
||||
};
|
||||
|
||||
typedef struct ur_message_stats_s {
|
||||
int16_t num;
|
||||
int16_t queue_fulls;
|
||||
int16_t mem_fails;
|
||||
int16_t pbuf_fails;
|
||||
int16_t size;
|
||||
|
||||
int16_t debug_info[MSG_DEBUG_INFO_SIZE];
|
||||
} ur_message_stats_t;
|
||||
|
||||
typedef struct ur_mem_stats_s {
|
||||
int32_t num;
|
||||
} ur_mem_stats_t;
|
||||
|
||||
enum {
|
||||
WHITELIST_ENTRY_NUM = 16,
|
||||
};
|
||||
|
||||
typedef enum node_mode_s {
|
||||
MODE_NONE = 0x00, // this is for testing that not joining net
|
||||
MODE_MOBILE = 0x01,
|
||||
MODE_LOW_MASK = 0x0f,
|
||||
MODE_RX_ON = 0x10,
|
||||
MODE_SUPER = 0x20,
|
||||
MODE_LEADER = 0x40,
|
||||
MODE_HI_MASK = 0xf0,
|
||||
} node_mode_t;
|
||||
|
||||
typedef enum node_state_s {
|
||||
DEVICE_STATE_DISABLED = 0,
|
||||
DEVICE_STATE_DETACHED = 1,
|
||||
DEVICE_STATE_ATTACHED = 2,
|
||||
DEVICE_STATE_LEAF = 3,
|
||||
DEVICE_STATE_LEADER = 4,
|
||||
DEVICE_STATE_SUPER_ROUTER = 5,
|
||||
DEVICE_STATE_ROUTER = 6,
|
||||
} node_state_t;
|
||||
|
||||
typedef struct whitelist_entry_s {
|
||||
mac_address_t address;
|
||||
int8_t rssi;
|
||||
bool valid;
|
||||
bool constant_rssi;
|
||||
} whitelist_entry_t;
|
||||
|
||||
/* mesh events code */
|
||||
#define CODE_MESH_STARTED 1
|
||||
#define CODE_MESH_ATTACHED 2
|
||||
#define CODE_MESH_DETACHED 3
|
||||
#define CODE_MESH_CONNECTED 4
|
||||
#define CODE_MESH_DISCONNECTED 5
|
||||
#define CODE_MESH_DATA_RECV 6
|
||||
#define CODE_MESH_PSCHED_UP 7
|
||||
#define CODE_MESH_ASCHED_UP 8
|
||||
#define CODE_MESH_SCHED_DOWN 9
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UMESH_TYPES_H */
|
||||
BIN
Living_SDK/kernel/protocols/mesh/lib/arm968es/libmesh.a
Normal file
BIN
Living_SDK/kernel/protocols/mesh/lib/arm968es/libmesh.a
Normal file
Binary file not shown.
BIN
Living_SDK/kernel/protocols/mesh/lib/cortex-m4/libmesh.a
Normal file
BIN
Living_SDK/kernel/protocols/mesh/lib/cortex-m4/libmesh.a
Normal file
Binary file not shown.
BIN
Living_SDK/kernel/protocols/mesh/lib/linux/libmesh.a
Normal file
BIN
Living_SDK/kernel/protocols/mesh/lib/linux/libmesh.a
Normal file
Binary file not shown.
BIN
Living_SDK/kernel/protocols/mesh/lib/xtensa/libmesh.a
Normal file
BIN
Living_SDK/kernel/protocols/mesh/lib/xtensa/libmesh.a
Normal file
Binary file not shown.
19
Living_SDK/kernel/protocols/mesh/mesh.mk
Normal file
19
Living_SDK/kernel/protocols/mesh/mesh.mk
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
NAME := mesh
|
||||
|
||||
$(NAME)_TYPE := kernel
|
||||
GLOBAL_INCLUDES += include
|
||||
GLOBAL_DEFINES += CONFIG_AOS_MESH
|
||||
|
||||
ifeq ($(HOST_ARCH), linux)
|
||||
LIB_DIR := linux
|
||||
else ifeq ($(HOST_ARCH), ARM968E-S)
|
||||
LIB_DIR := arm968es
|
||||
else ifeq ($(HOST_ARCH), xtensa)
|
||||
LIB_DIR := xtensa
|
||||
else ifeq ($(HOST_ARCH), Cortex-M4)
|
||||
LIB_DIR := cortex-m4
|
||||
else
|
||||
$(error "not find correct platform!")
|
||||
endif
|
||||
|
||||
$(NAME)_PREBUILT_LIBRARY := lib/$(LIB_DIR)/libmesh.a
|
||||
Loading…
Add table
Add a link
Reference in a new issue