forked from xuos/xiuos
support lcd and wifi and ethernet test on xidatong-arm32
This commit is contained in:
parent
a1ddea8e5e
commit
2b099b8bf5
|
@ -374,7 +374,7 @@ int test_lcd(int argc, FAR char *argv[])
|
|||
close(state.fd);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("2022-10-14 Mr. Wang commit LCD\n");
|
||||
printf("VideoInfo:\n");
|
||||
printf(" fmt: %u\n", state.vinfo.fmt);
|
||||
printf(" xres: %u\n", state.vinfo.xres);
|
||||
|
|
|
@ -181,6 +181,7 @@ static void TcpSocketSendTask(void *arg)
|
|||
int ret;
|
||||
char send_msg[128];
|
||||
|
||||
lw_print("2022-10-14 Mr. Wang commit TCP\n");
|
||||
lw_print("%s start\n", __func__);
|
||||
|
||||
memset(send_msg, 0, sizeof(send_msg));
|
||||
|
|
|
@ -169,7 +169,7 @@ int AdapterDeviceOpen(struct Adapter *adapter)
|
|||
|
||||
result = priv_done->open(adapter);
|
||||
if (0 == result) {
|
||||
printf("Device %s open success.\n", adapter->name);
|
||||
printf("Device %s %p open success.\n", adapter->name, adapter->adapter_param);
|
||||
adapter->adapter_status = INSTALL;
|
||||
} else {
|
||||
if (adapter->fd) {
|
||||
|
@ -187,7 +187,7 @@ int AdapterDeviceOpen(struct Adapter *adapter)
|
|||
|
||||
result = ip_done->open(adapter);
|
||||
if (0 == result) {
|
||||
printf("Device %s open success.\n", adapter->name);
|
||||
printf("Device %s param %p open success.\n", adapter->name, adapter->adapter_param);
|
||||
adapter->adapter_status = INSTALL;
|
||||
} else {
|
||||
if (adapter->fd) {
|
||||
|
|
|
@ -211,8 +211,7 @@ int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check)
|
|||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
printf("[reply result :\n");
|
||||
printf("%s]\n", result);
|
||||
printf("[reply result: %s]\n", result);
|
||||
if(!strstr(result, check)) {
|
||||
printf("%s %d check[%s] reply[%s] failed.\n",__func__,__LINE__,check,result);
|
||||
ret = -1;
|
||||
|
@ -522,7 +521,7 @@ static int ATAgentInit(ATAgentType agent)
|
|||
#ifdef ADD_NUTTX_FETURES
|
||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||
attr.priority = 18;
|
||||
attr.stacksize = 4096;
|
||||
attr.stacksize = 8192;
|
||||
|
||||
#else
|
||||
pthread_attr_t attr;
|
||||
|
|
|
@ -168,13 +168,13 @@ int AdapterWifiTest(void)
|
|||
|
||||
const char *wifi_msg = "Wifi Test";
|
||||
int len = strlen(wifi_msg);
|
||||
for(int i = 0;i < 10; ++i) {
|
||||
for(int i = 0; i < 10; ++i) {
|
||||
AdapterDeviceSend(adapter, wifi_msg, len);
|
||||
PrivTaskDelay(4000);
|
||||
}
|
||||
|
||||
char wifi_recv_msg[128];
|
||||
for(int j=0;j<10;++j){
|
||||
for(int j = 0; j < 10; ++j){
|
||||
AdapterDeviceRecv(adapter, wifi_recv_msg, 128);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ PRIV_SHELL_CMD_FUNCTION(WifiClose, a WiFi close sample, PRIV_SHELL_CMD_MAIN_ATTR
|
|||
int WifiSetup(int argc, char *argv[])
|
||||
{
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
struct WifiParam param;
|
||||
static struct WifiParam param;
|
||||
memset(¶m,0,sizeof(struct WifiParam));
|
||||
strncpy((char *)param.wifi_ssid, argv[1], strlen(argv[1]));
|
||||
strncpy((char *)param.wifi_pwd, argv[2], strlen(argv[2]));
|
||||
|
@ -292,7 +292,7 @@ enum
|
|||
APT_WIFI_PARAM_NUM
|
||||
};
|
||||
|
||||
#define APT_WIFI_PARAM_LEN 20
|
||||
#define APT_WIFI_PARAM_LEN 128
|
||||
|
||||
char wifi_param[APT_WIFI_PARAM_NUM][APT_WIFI_PARAM_LEN] = {0};
|
||||
|
||||
|
@ -301,6 +301,7 @@ ret = __func; \
|
|||
if(ret != 0){ \
|
||||
printf("%s %d failed\n", __func__, __LINE__); \
|
||||
AdapterDeviceClose(adapter); \
|
||||
free(adapter->adapter_param); \
|
||||
return ret; \
|
||||
};
|
||||
|
||||
|
@ -309,7 +310,16 @@ void AdapterWifiGetParam(int argc, char *argv[])
|
|||
int i, j;
|
||||
char *param_str[] = {"ip", "port", "ssid", "pwd", "gw", "server", "mask", "ping"};
|
||||
char *default_str[] =
|
||||
{"192.168.137.34", "12345", "test", "tttttttt", "192.168.137.71", "192.168.137.1", "255.255.255.0", "220.181.38.251"};
|
||||
{
|
||||
"192.168.137.34",
|
||||
"12345",
|
||||
"test",
|
||||
"tttttttt",
|
||||
"192.168.137.71",
|
||||
"192.168.137.1",
|
||||
"255.255.255.0",
|
||||
"220.181.38.251"
|
||||
};
|
||||
|
||||
for(i = 0; i < APT_WIFI_PARAM_NUM; i ++)
|
||||
{
|
||||
|
@ -342,17 +352,20 @@ int AdapterWifiTestWithParam(int argc, char *argv[])
|
|||
{
|
||||
int i, ret;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
AdapterWifiGetParam(argc, argv);
|
||||
|
||||
enum NetRoleType net_role = CLIENT;
|
||||
enum IpType ip_type = IPV4;
|
||||
struct WifiParam param;
|
||||
memset(¶m, 0, sizeof(struct WifiParam));
|
||||
strncpy((char *)param.wifi_ssid, wifi_param[APT_WIFI_PARAM_SSID], strlen(wifi_param[APT_WIFI_PARAM_SSID]));
|
||||
strncpy((char *)param.wifi_pwd, wifi_param[APT_WIFI_PARAM_PWD], strlen(wifi_param[APT_WIFI_PARAM_PWD]));
|
||||
|
||||
adapter->adapter_param = ¶m;
|
||||
adapter->adapter_param = malloc(sizeof(struct WifiParam));
|
||||
memset(adapter->adapter_param, 0, sizeof(struct WifiParam));
|
||||
struct WifiParam *apt_param = (struct WifiParam *)adapter->adapter_param;
|
||||
strcpy(apt_param->wifi_ssid, wifi_param[APT_WIFI_PARAM_SSID]);
|
||||
strcpy(apt_param->wifi_pwd, wifi_param[APT_WIFI_PARAM_PWD]);
|
||||
|
||||
printf("2022-10-14 Mr. Wang commit Wifi\n");
|
||||
printf("apt %p ssid %p %s\n", apt_param, apt_param->wifi_ssid);
|
||||
|
||||
CHECK_RET(AdapterDeviceOpen(adapter));
|
||||
CHECK_RET(AdapterDeviceSetUp(adapter));
|
||||
|
@ -373,8 +386,9 @@ int AdapterWifiTestWithParam(int argc, char *argv[])
|
|||
PrivTaskDelay(4000);
|
||||
}
|
||||
|
||||
char wifi_recv_msg[128];
|
||||
for(i = 0; i < 10; i ++)
|
||||
char wifi_recv_msg[APT_WIFI_PARAM_LEN];
|
||||
memset(wifi_recv_msg, 0, APT_WIFI_PARAM_LEN);
|
||||
for(i = 0; i < APT_WIFI_PARAM_NUM; i ++)
|
||||
{
|
||||
AdapterDeviceRecv(adapter, wifi_recv_msg, 128);
|
||||
PrivTaskDelay(1000);
|
||||
|
@ -385,6 +399,7 @@ int AdapterWifiTestWithParam(int argc, char *argv[])
|
|||
// CHECK_RET(AdapterDevicePing(adapter, wifi_param[APT_WIFI_PARAM_PING]));
|
||||
// AdapterDeviceDisconnect(adapter, NULL);
|
||||
ret = AdapterDeviceClose(adapter);
|
||||
free(adapter->adapter_param);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,39 +196,59 @@ static int Esp07sWifiSetUp(struct Adapter *adapter)
|
|||
return -1;
|
||||
}
|
||||
PrivTaskDelay(2000);
|
||||
|
||||
printf("%s check %d adapter %p wifi %p param %p\n", __func__, __LINE__, adapter, param,
|
||||
adapter->adapter_param);
|
||||
|
||||
/* config as softAP+station mode */
|
||||
ret = AtCmdConfigAndCheck(agent, "AT+CWMODE=3\r\n", "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[AT+CWMODE=3] config failed!\n",__func__,__LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// printf("%s check %d pwd %s\n", __func__, __LINE__, param->wifi_pwd);
|
||||
|
||||
PrivTaskDelay(2000);
|
||||
/* connect the router */
|
||||
memset(cmd,0,sizeof(cmd));
|
||||
strncpy(cmd,"AT+CWJAP=",strlen("AT+CWJAP="));
|
||||
strcpy(cmd,"AT+CWJAP=");//strlen("AT+CWJAP="));
|
||||
strncat(cmd,"\"",1);
|
||||
strncat(cmd,param->wifi_ssid,strlen(param->wifi_ssid));
|
||||
|
||||
// printf("%s check %d len %d\n", __func__, __LINE__, strlen(param->wifi_pwd));
|
||||
|
||||
strncat(cmd,param->wifi_ssid,128);
|
||||
|
||||
strncat(cmd,"\"",1);
|
||||
strncat(cmd,",",1);
|
||||
strncat(cmd,"\"",1);
|
||||
|
||||
// printf("%s check %d len %d\n", __func__, __LINE__, strlen(param->wifi_pwd));
|
||||
|
||||
strncat(cmd,param->wifi_pwd,strlen(param->wifi_pwd));
|
||||
|
||||
strncat(cmd,"\"",1);
|
||||
strcat(cmd,"\r\n");
|
||||
|
||||
printf("%s check %d\n", __func__, __LINE__);
|
||||
|
||||
ret = AtCmdConfigAndCheck(agent, cmd, "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] connect[%s] failed!\n",__func__,__LINE__,cmd,param->wifi_ssid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("%s check %d\n", __func__, __LINE__);
|
||||
|
||||
/* check the wifi ip address */
|
||||
ATReplyType reply = CreateATReply(256);
|
||||
if (NULL == reply) {
|
||||
printf("%s %d at_create_resp failed!\n",__func__,__LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("%s check %d\n", __func__, __LINE__);
|
||||
|
||||
ret = ATOrderSend(agent, REPLY_TIME_OUT, reply, "AT+CIFSR\r\n");
|
||||
if(ret < 0){
|
||||
printf("%s %d ATOrderSend AT+CIFSR failed.\n",__func__,__LINE__);
|
||||
|
|
|
@ -47,14 +47,24 @@ if ADD_XIZI_FETURES
|
|||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
if ARCH_BOARD_XIDATONG_ARM32
|
||||
config ADAPTER_E18_MODEPIN
|
||||
int "E18 MODE pin number"
|
||||
default "61"
|
||||
|
||||
config ADAPTER_E18_PIN_DRIVER
|
||||
string "E18 device pin driver path"
|
||||
default "/dev/gpio0"
|
||||
endif
|
||||
if ARCH_BOARD_XIDATONG_ARM32
|
||||
config ADAPTER_E18_MODE_PATH
|
||||
string "E18 MODE pin device"
|
||||
default "/dev/gpio2"
|
||||
|
||||
endif
|
||||
config ADAPTER_E18_DRIVER_EXTUART
|
||||
bool "Using extra uart to support zigbee"
|
||||
default y
|
||||
|
||||
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device uart driver path"
|
||||
default "/dev/ttyS1"
|
||||
|
|
|
@ -40,10 +40,35 @@ char *cmd_set_ch = "AT+CH=11"; /*set channel as 11*/
|
|||
#define E18_AS_HEX_MODE 0
|
||||
#define E18_AS_AT_MODE 1
|
||||
|
||||
|
||||
static int E18HardwareModeGet()
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#ifdef CONFIG_ARCH_BOARD_XIDATONG_ARM32
|
||||
int ret = 0;
|
||||
int pin_fd;
|
||||
|
||||
pin_fd = PrivOpen(ADAPTER_E18_PIN_DRIVER, O_RDWR);
|
||||
|
||||
struct PinStat pin_stat;
|
||||
pin_stat.pin = ADAPTER_E18_MODEPIN;
|
||||
|
||||
ret = PrivRead(pin_fd, &pin_stat, 1);
|
||||
|
||||
PrivTaskDelay(200);
|
||||
|
||||
PrivClose(pin_fd);
|
||||
|
||||
if(pin_stat.val == GPIO_HIGH) {
|
||||
printf(" E18 as AT mode\n");
|
||||
return E18_AS_AT_MODE;
|
||||
} else {
|
||||
printf(" E18 as HEX mode\n");
|
||||
return E18_AS_HEX_MODE;
|
||||
}
|
||||
#else
|
||||
return E18_AS_HEX_MODE;
|
||||
#endif
|
||||
#else
|
||||
int ret = 0;
|
||||
int pin_fd;
|
||||
|
@ -66,7 +91,41 @@ static int E18HardwareModeGet()
|
|||
printf(" E18 as HEX mode\n");
|
||||
return E18_AS_HEX_MODE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static int E18HardwareModeSet(void)
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#ifdef CONFIG_ARCH_BOARD_XIDATONG_ARM32
|
||||
int ret = 0;
|
||||
int pin_fd;
|
||||
|
||||
pin_fd = PrivOpen(ADAPTER_E18_PIN_DRIVER, O_RDWR);
|
||||
|
||||
struct PinStat pin_stat;
|
||||
pin_stat.pin = ADAPTER_E18_MODEPIN;
|
||||
pin_stat.val = GPIO_HIGH;
|
||||
|
||||
// ret = PrivWrite(pin_fd, &pin_stat, 1);
|
||||
|
||||
ioctl(pin_fd, GPIOC_WRITE, (unsigned long)0);
|
||||
|
||||
PrivTaskDelay(200);
|
||||
|
||||
ret = PrivRead(pin_fd, &pin_stat, 1);
|
||||
|
||||
PrivClose(pin_fd);
|
||||
|
||||
if(pin_stat.val == GPIO_HIGH) {
|
||||
printf(" E18 set AT mode\n");
|
||||
return E18_AS_AT_MODE;
|
||||
} else {
|
||||
printf(" E18 set HEX mode\n");
|
||||
return E18_AS_HEX_MODE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static int E18UartOpen(struct Adapter *adapter)
|
||||
|
@ -186,6 +245,8 @@ static int E18NetRoleConfig(struct Adapter *adapter)
|
|||
int ret = 0;
|
||||
int mode = -1;
|
||||
|
||||
printf("start %s\n", __func__);
|
||||
// E18HardwareModeSet();
|
||||
|
||||
if (NULL == adapter) {
|
||||
printf("%s %d adapter is null!\n",__func__,__LINE__);
|
||||
|
|
|
@ -364,12 +364,12 @@ int cmd_recvzigbee(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||
#endif
|
||||
|
||||
#if defined(CONFIG_ADAPTER_ESP07S_WIFI) && !defined(CONFIG_NSH_DISABLE_ADAPTER_WIFI_TEST)
|
||||
extern int AdapterWifiTest(int argc, char *argv[]);
|
||||
extern int AdapterWifiTestWithParam(int argc, char *argv[]);
|
||||
int cmd_AdapterWifiTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(vtbl, "Hello, world!\n");
|
||||
FrameworkInit();
|
||||
AdapterWifiTest(argc, argv);
|
||||
AdapterWifiTestWithParam(argc, argv);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue