tcp test
This commit is contained in:
51
include/lwipopts.h
Normal file
51
include/lwipopts.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef LWIPOPTS_H
|
||||
#define LWIPOPTS_H
|
||||
|
||||
// lwIP configuration for Raspberry Pi Pico W (CYW43 + lwIP).
|
||||
// This is a sane baseline for pico_cyw43_arch_lwip_threadsafe_background.
|
||||
// example
|
||||
|
||||
#define NO_SYS 1
|
||||
#define LWIP_SOCKET 0
|
||||
#define LWIP_NETCONN 0
|
||||
|
||||
#define MEM_ALIGNMENT 4
|
||||
#define MEM_SIZE 4000
|
||||
|
||||
#define MEMP_NUM_TCP_SEG 32
|
||||
#define MEMP_NUM_ARP_QUEUE 10
|
||||
#define PBUF_POOL_SIZE 24
|
||||
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_ICMP 1
|
||||
#define LWIP_RAW 1
|
||||
#define LWIP_DHCP 1
|
||||
#define LWIP_IPV4 1
|
||||
#define LWIP_TCP 1
|
||||
#define LWIP_UDP 1
|
||||
#define LWIP_DNS 1
|
||||
|
||||
#define TCP_MSS 1460
|
||||
#define TCP_WND (8 * TCP_MSS)
|
||||
#define TCP_SND_BUF (8 * TCP_MSS)
|
||||
#define TCP_SND_QUEUELEN ((4 * TCP_SND_BUF + TCP_MSS - 1) / TCP_MSS)
|
||||
|
||||
#define MEMP_NUM_TCP_PCB 5
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 8
|
||||
#define MEMP_NUM_SYS_TIMEOUT 10
|
||||
|
||||
#define LWIP_NETIF_STATUS_CALLBACK 1
|
||||
#define LWIP_NETIF_LINK_CALLBACK 1
|
||||
#define LWIP_NETIF_HOSTNAME 1
|
||||
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
#define LWIP_SO_RCVTIMEO 1
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
|
||||
// Use system-provided timeval definition.
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
|
||||
#define LWIP_CHKSUM_ALGORITHM 3
|
||||
|
||||
#endif // LWIPOPTS_H
|
||||
29
include/net/net.h
Normal file
29
include/net/net.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef NET_H
|
||||
#define NET_H
|
||||
|
||||
// net.h
|
||||
// Includes
|
||||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/cyw43_arch.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
char ssid[32];
|
||||
char password[64];
|
||||
} net_creds_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t port;
|
||||
uint16_t maxClients;
|
||||
void (*onConnect)(int clientId);
|
||||
void (*onDisconnect)(int clientId);
|
||||
void (*onData)(int clientId, const uint8_t* data, size_t len);
|
||||
} net_server_t;
|
||||
|
||||
net_server_t* Net_Init(net_creds_t* creds);
|
||||
bool Net_Listen(net_server_t* server);
|
||||
void Net_Destroy(net_server_t* server);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user