forked from xuos/xiuos
connection/wifi/wifi verify
1.modify macros which can cause bugs 2.write macro control in xizi and rt-thread
This commit is contained in:
parent
50995f3c1f
commit
ec446bb44c
|
@ -22,6 +22,7 @@
|
|||
#include "adapter_wifi.h"
|
||||
#include <bus_pin.h>
|
||||
|
||||
|
||||
#ifdef ADAPTER_HFA21_WIFI
|
||||
extern AdapterProductInfoType Hfa21WifiAttach(struct Adapter *adapter);
|
||||
#endif
|
||||
|
@ -107,30 +108,30 @@ int AdapterwifiTest(void)
|
|||
|
||||
|
||||
#ifdef ADAPTER_HFA21_DRIVER_EXT_PORT
|
||||
// static BusType ch438_pin;
|
||||
// ch438_pin = PinBusInitGet();
|
||||
// struct PinParam pin_cfg;
|
||||
// int ret = 0;
|
||||
static BusType ch438_pin;
|
||||
ch438_pin = PinBusInitGet();
|
||||
struct PinParam pin_cfg;
|
||||
int ret = 0;
|
||||
|
||||
// struct BusConfigureInfo configure_info;
|
||||
// configure_info.configure_cmd = OPE_CFG;
|
||||
// configure_info.private_data = (void *)&pin_cfg;
|
||||
struct BusConfigureInfo configure_info;
|
||||
configure_info.configure_cmd = OPE_CFG;
|
||||
configure_info.private_data = (void *)&pin_cfg;
|
||||
|
||||
// pin_cfg.cmd = GPIO_CONFIG_MODE;
|
||||
// pin_cfg.pin = 22;
|
||||
// pin_cfg.mode = GPIO_CFG_OUTPUT;
|
||||
pin_cfg.cmd = GPIO_CONFIG_MODE;
|
||||
pin_cfg.pin = 22;
|
||||
pin_cfg.mode = GPIO_CFG_OUTPUT;
|
||||
|
||||
// ret = BusDrvConfigure(ch438_pin->owner_driver, &configure_info);
|
||||
ret = BusDrvConfigure(ch438_pin->owner_driver, &configure_info);
|
||||
|
||||
// struct PinStat pin_stat;
|
||||
// struct BusBlockWriteParam write_param;
|
||||
// struct BusBlockReadParam read_param;
|
||||
// write_param.buffer = (void *)&pin_stat;
|
||||
struct PinStat pin_stat;
|
||||
struct BusBlockWriteParam write_param;
|
||||
struct BusBlockReadParam read_param;
|
||||
write_param.buffer = (void *)&pin_stat;
|
||||
|
||||
// pin_stat.val = GPIO_HIGH;
|
||||
pin_stat.val = GPIO_HIGH;
|
||||
|
||||
// pin_stat.pin = 22;
|
||||
// BusDevWriteData(ch438_pin->owner_haldev, &write_param);
|
||||
pin_stat.pin = 22;
|
||||
BusDevWriteData(ch438_pin->owner_haldev, &write_param);
|
||||
|
||||
int pin_fd;
|
||||
pin_fd = PrivOpen("/dev/pin_dev", O_RDWR);
|
||||
|
@ -168,7 +169,7 @@ int AdapterwifiTest(void)
|
|||
enum IpType ip_type = IPV4;
|
||||
AdapterDeviceConnect(adapter, net_role, ip, port, ip_type);
|
||||
|
||||
const char *wifi_msg = "LiuKai Test";
|
||||
const char *wifi_msg = "Wifi Test";
|
||||
int len = strlen(wifi_msg);
|
||||
for(int i = 0;i < 10; ++i) {
|
||||
AdapterDeviceSend(adapter, wifi_msg, len);
|
||||
|
@ -176,12 +177,19 @@ int AdapterwifiTest(void)
|
|||
}
|
||||
|
||||
char wifi_recv_msg[128];
|
||||
while (1) {
|
||||
for(int j=0;j<10;++j){
|
||||
AdapterDeviceRecv(adapter, wifi_recv_msg, 128);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterwifiTest, AdapterwifiTest, show adapter wifi information);
|
||||
|
||||
#ifdef ADD_RTTHREAD_FETURES
|
||||
MSH_CMD_EXPORT(AdapterWifiTest,a wifi adpter sample);
|
||||
#endif
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterWifiTest, AdapterWifiTest, show adapter wifi information);
|
||||
#endif
|
||||
|
||||
int wifiopen(void)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
|
||||
#include <adapter.h>
|
||||
#include <at_agent.h>
|
||||
|
||||
#include <transform.h>
|
||||
#include <string.h>
|
||||
#define LEN_PARA_BUF 128
|
||||
|
||||
static int Hfa21WifiSetDown(struct Adapter *adapter_at);
|
||||
|
@ -28,10 +29,11 @@ static int Hfa21WifiSetDown(struct Adapter *adapter_at);
|
|||
/**
|
||||
* @description: enter AT command mode
|
||||
* @param at_agent - wifi device agent pointer
|
||||
* @return success: EOK
|
||||
* @return success: 0
|
||||
*/
|
||||
static int Hfa21WifiInitAtCmd(ATAgentType at_agent)
|
||||
{
|
||||
|
||||
ATOrderSend(at_agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
PrivTaskDelay(100);
|
||||
|
||||
|
@ -44,7 +46,7 @@ static int Hfa21WifiInitAtCmd(ATAgentType at_agent)
|
|||
/**
|
||||
* @description: Open wifi
|
||||
* @param adapter - wifi device pointer
|
||||
* @return success: EOK, failure: ENOMEMORY
|
||||
* @return success: 0, failure: 5
|
||||
*/
|
||||
static int Hfa21WifiOpen(struct Adapter *adapter)
|
||||
{
|
||||
|
@ -58,7 +60,7 @@ static int Hfa21WifiOpen(struct Adapter *adapter)
|
|||
/*step2: init AT agent*/
|
||||
if (!adapter->agent) {
|
||||
char *agent_name = "wifi_uart_client";
|
||||
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
|
||||
if (0 != InitATAgent(agent_name, adapter->fd, 512)) {
|
||||
printf("at agent init failed !\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -75,7 +77,7 @@ static int Hfa21WifiOpen(struct Adapter *adapter)
|
|||
/**
|
||||
* @description: Close wifi
|
||||
* @param adapter - wifi device pointer
|
||||
* @return success: EOK
|
||||
* @return success: 0
|
||||
*/
|
||||
static int Hfa21WifiClose(struct Adapter *adapter)
|
||||
{
|
||||
|
@ -87,11 +89,11 @@ static int Hfa21WifiClose(struct Adapter *adapter)
|
|||
* @param adapter - wifi device pointer
|
||||
* @param data - data buffer
|
||||
* @param data - data length
|
||||
* @return success: EOK
|
||||
* @return success: 0
|
||||
*/
|
||||
static int Hfa21WifiSend(struct Adapter *adapter, const void *data, size_t len)
|
||||
{
|
||||
x_err_t result = EOK;
|
||||
long result = 0;
|
||||
if (adapter->agent) {
|
||||
EntmSend(adapter->agent, (const char *)data, len);
|
||||
}else {
|
||||
|
@ -108,11 +110,11 @@ __exit:
|
|||
* @param adapter - wifi device pointer
|
||||
* @param data - data buffer
|
||||
* @param data - data length
|
||||
* @return success: EOK
|
||||
* @return success: 0
|
||||
*/
|
||||
static int Hfa21WifiReceive(struct Adapter *adapter, void *rev_buffer, size_t buffer_len)
|
||||
{
|
||||
x_err_t result = EOK;
|
||||
long result = 0;
|
||||
printf("hfa21 receive waiting ... \n");
|
||||
|
||||
if (adapter->agent) {
|
||||
|
@ -129,20 +131,19 @@ __exit:
|
|||
/**
|
||||
* @description: connnect wifi to internet
|
||||
* @param adapter - wifi device pointer
|
||||
* @return success: EOK
|
||||
* @return success: 0
|
||||
*/
|
||||
static int Hfa21WifiSetUp(struct Adapter *adapter)
|
||||
{
|
||||
uint8 wifi_ssid[LEN_PARA_BUF] = "AIIT-Guest";
|
||||
uint8 wifi_pwd[LEN_PARA_BUF] = "";
|
||||
char cmd[LEN_PARA_BUF];
|
||||
|
||||
|
||||
struct ATAgent *agent = adapter->agent;
|
||||
|
||||
|
||||
/* wait hfa21 device startup finish */
|
||||
PrivTaskDelay(5000);
|
||||
|
||||
Hfa21WifiInitAtCmd(agent);
|
||||
Hfa21WifiInitAtCmd(agent);//err
|
||||
|
||||
memset(cmd,0,sizeof(cmd));
|
||||
strcpy(cmd,"AT+FCLR\r");
|
||||
|
@ -181,7 +182,7 @@ static int Hfa21WifiSetUp(struct Adapter *adapter)
|
|||
/**
|
||||
* @description: disconnnect wifi from internet
|
||||
* @param adapter - wifi device pointer
|
||||
* @return success: EOK
|
||||
* @return success: 0
|
||||
*/
|
||||
static int Hfa21WifiSetDown(struct Adapter *adapter)
|
||||
{
|
||||
|
@ -199,7 +200,7 @@ static int Hfa21WifiSetDown(struct Adapter *adapter)
|
|||
* @param ip - ip address
|
||||
* @param gateway - gateway address
|
||||
* @param netmask - netmask address
|
||||
* @return success: EOK, failure: ENOMEMORY
|
||||
* @return success: 0, failure: 5
|
||||
*/
|
||||
static int Hfa21WifiSetAddr(struct Adapter *adapter, const char *ip, const char *gateway, const char *netmask)
|
||||
{
|
||||
|
@ -216,12 +217,12 @@ static int Hfa21WifiSetAddr(struct Adapter *adapter, const char *ip, const char
|
|||
|
||||
Hfa21WifiInitAtCmd(adapter->agent);
|
||||
|
||||
x_err_t result = EOK;
|
||||
long result = 0;
|
||||
|
||||
ATReplyType reply = CreateATReply(64);
|
||||
if (NULL == reply) {
|
||||
printf("at_create_resp failed ! \n");
|
||||
result = ENOMEMORY;
|
||||
result = 5;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
|
@ -253,12 +254,12 @@ __exit:
|
|||
* @description: wifi ping function
|
||||
* @param adapter - wifi device pointer
|
||||
* @param destination - domain name or ip address
|
||||
* @return success: EOK, failure: ENOMEMORY
|
||||
* @return success: 0, failure: 5
|
||||
*/
|
||||
static int Hfa21WifiPing(struct Adapter *adapter, const char *destination)
|
||||
{
|
||||
char *ping_result = NONE;
|
||||
char *dst = NONE;
|
||||
char *ping_result = (0);
|
||||
char *dst = (0);
|
||||
ping_result = (char *) PrivCalloc(1, 17);
|
||||
dst = (char *) PrivCalloc(1, 17);
|
||||
strcpy(dst, destination);
|
||||
|
@ -266,12 +267,12 @@ static int Hfa21WifiPing(struct Adapter *adapter, const char *destination)
|
|||
|
||||
Hfa21WifiInitAtCmd(adapter->agent);
|
||||
|
||||
uint32 result = EOK;
|
||||
uint32 result = 0;
|
||||
|
||||
ATReplyType reply = CreateATReply(64);
|
||||
if (NULL == reply) {
|
||||
printf("at_create_resp failed ! \n");
|
||||
result = ENOMEMORY;
|
||||
result = 5;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
|
@ -302,7 +303,7 @@ __exit:
|
|||
/**
|
||||
* @description: display wifi network configuration
|
||||
* @param adapter - wifi device pointer
|
||||
* @return success: EOK, failure: ENOMEMORY
|
||||
* @return success: 0, failure: 5
|
||||
*/
|
||||
static int Hfa21WifiNetstat(struct Adapter *adapter)
|
||||
{
|
||||
|
@ -334,7 +335,7 @@ static int Hfa21WifiNetstat(struct Adapter *adapter)
|
|||
|
||||
reply = CreateATReply(HFA21_NETSTAT_RESP_SIZE);
|
||||
if (reply == NULL) {
|
||||
result = ENOMEMORY;
|
||||
result = 5;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
|
@ -384,7 +385,7 @@ static int Hfa21WifiNetstat(struct Adapter *adapter)
|
|||
else
|
||||
printf("local ip: %s\nnetmask: %s\n", local_ipaddr, netmask);
|
||||
|
||||
return EOK;
|
||||
return 0;
|
||||
|
||||
__exit:
|
||||
if (reply)
|
||||
|
@ -410,15 +411,15 @@ __exit:
|
|||
*/
|
||||
static int Hfa21WifiConnect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||
{
|
||||
int result = EOK;
|
||||
ATReplyType reply = NONE;
|
||||
int result = 0;
|
||||
ATReplyType reply = (0);
|
||||
char cmd[LEN_PARA_BUF];
|
||||
struct ATAgent *agent = adapter->agent;
|
||||
|
||||
reply = CreateATReply(64);
|
||||
if (reply == NONE) {
|
||||
if (reply == (0)) {
|
||||
printf("no memory for reply struct.");
|
||||
return ENOMEMORY;
|
||||
return 5;
|
||||
}
|
||||
|
||||
Hfa21WifiInitAtCmd(adapter->agent);
|
||||
|
@ -505,7 +506,7 @@ static const struct IpProtocolDone hfa21_wifi_done =
|
|||
|
||||
/**
|
||||
* @description: Register wifi device hfa21
|
||||
* @return success: EOK, failure: ERROR
|
||||
* @return success: 0, failure: ERROR
|
||||
*/
|
||||
AdapterProductInfoType Hfa21WifiAttach(struct Adapter *adapter)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue