added socket test command on nuttx

This commit is contained in:
wlyu
2022-09-26 14:24:19 +08:00
parent 3bc1cffa33
commit dcc91fd4a9
5 changed files with 83 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
#ifdef ADD_NUTTX_FETURES
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "stdio.h"
#endif
@@ -218,6 +219,17 @@ SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) |
#ifdef ADD_NUTTX_FETURES
void tcp_set_ip(char *ip_str)
{
char ip[4] = {0};
if(sscanf(ip_str, "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], &ip[3]))
{
printf("config ip %s\n", ip_str);
memcpy(tcp_socket_ip, ip, 4);
}
}
void tcp_recv_demo(void)
{
TCPSocketRecvTask(NULL);

View File

@@ -196,6 +196,16 @@ SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) |
#endif
#ifdef ADD_NUTTX_FETURES
void udp_set_ip(char *ip_str)
{
char ip[4] = {0};
if(sscanf(ip_str, "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], &ip[3]))
{
printf("config ip %s\n", ip_str);
memcpy(udp_socket_ip, ip, 4);
}
}
void udp_recv_demo(void)
{
UdpSocketRecvTask(NULL);