LPT26x-HSF-4MB-Hilink_14.2..../application/ws63/hsf/hfnet.h
2025-05-13 22:00:58 +08:00

100 lines
2.1 KiB
C
Executable File

#ifndef _HF_NET_H_
#define _HF_NET_H_
#include "lwip/sockets.h"
#define HFUART0 (hfuart_handle_t)(1)
#define HFUART1 (hfuart_handle_t)(2)
#define ASSIS_PORT 48899
typedef enum
{
HFNET_SOCKETA_DATA_READY=0,
HFNET_SOCKETA_CONNECTED=1,
HFNET_SOCKETA_DISCONNECTED,
HFNET_SOCKETB_DATA_READY,
HFNET_SOCKETB_CONNECTED,
HFNET_SOCKETB_DISCONNECTED,
HFNET_UART0_DATA_READY,
HFNET_UART1_DATA_READY,
HFNET_ASSIS_DATA_READY
}hfnet_event_id_t;
typedef struct _hfnet_stat
{
int hfnet_init_down;
int socketa_send_bytes;
int socketa_recv_bytes;
int socketa_connect_times;
int uart_send_bytes;
int uart_recv_bytes;
int socketb_send_bytes;
int socketb_recv_bytes;
int socketb_connect_times;
int uart_buffer_full_times;
int uart_irq_num;
int uart_thread_run;
int uart1_buffer_full_times;
int uart1_irq_num;
int uart1_thread_run;
int socketa_buffer_full_times;
int drop_arp_packet;
int drop_udp_broadcast_packet;
}hfnet_stat;
extern hfnet_stat g_hfnet_stat;
typedef int (*hfnet_callback_t)( uint32_t event,void *data,uint32_t len,uint32_t buf_len);
int hfnet_start_uart(uint32_t uxpriority, hfnet_callback_t p_callback);
int HSF_API hfnet_start_assis(uint16_t port);
int HSF_API hfnet_get_mac_address(char *mac_str);
int HSF_API hfnet_get_wan_ip(uint32_t * ip, uint32_t *mask, uint32_t *gw);
struct netif *hf_get_sta_netif(void);
int hfwifi_sta_is_connected(void);
int HSF_API hfnet_wifi_is_active(void);
int HSF_IAPI hfnet_send_assis_event(uint32_t event,void *data,uint32_t len,uint32_t buf_len);
/**
* @brief get ip address by domain name.
*
* @param[in] name: domain name
* addr: a pointer for using to store addr
* @return[out] HF_SUCCESS-successfully, other value is failed
* @see None.
* @note None.
*/
int HSF_API hfnet_gethostbyname(const char *name, ip_addr_t *addr);
/**
* @brief check string is ip address.
*
* @param[in] ipaddr: ip string
* @return[out] 1-ip address, other value is failed
* @see None.
* @note None.
*/
int HSF_API hfnet_is_ipaddress(const char * ipaddr);
#endif