Skip to content

Commit

Permalink
added lwip doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ghazanhaider committed Oct 10, 2023
1 parent c646552 commit b668c1e
Show file tree
Hide file tree
Showing 4 changed files with 706 additions and 0 deletions.
58 changes: 58 additions & 0 deletions _posts/2023-10-09-lwip-tcp.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
layout: post
title: "LwIP TCP API"
date: 2023-10-09 00:00:00 -0400
---

# Minimal LwIP TCP API (as used on a Raspberry PI pico-w)

### tcp_new()
```
struct tcp_pcb* tcp_new ( void )
struct tcp_pcb* tcp_new_ip_type ( u8_t type )
```
Creates a new TCP protocol control block but doesn't place it on any of the TCP PCB lists until binding using tcp_bind().

Parameters
- IPADDR_TYPE_ANY|
Returns
- a new tcp_pcb that initially is in state CLOSED

### tcp_bind()

### tcp_connect()
```
err_t tcp_connect ( struct tcp_pcb * pcb, const ip_addr_t * ipaddr, u16_t port, tcp_connected_fn connected)
```
Parameters
- pcb the tcp_pcb used to establish the connection
- ipaddr the remote ip address to connect to
- port the remote tcp port to connect to
- connected callback function to call when connected (on error, the err calback will be called)
Returns
- ERR_VAL if invalid arguments are given ERR_OK if connect request has been sent other err_t values if connect request couldn't be sent

### tcp_write()
```
err_t tcp_write ( struct tcp_pcb * pcb, const void * arg, u16_t len, u8_t apiflags)
```
Parameters
- pcb Protocol control block for the TCP connection to enqueue data for.
- arg Pointer to the data to be enqueued for sending.
- len Data length in bytes
- apiflags combination of following flags :
- TCP_WRITE_FLAG_COPY (0x01) data will be copied into memory belonging to the stack
- TCP_WRITE_FLAG_MORE (0x02) for TCP connection, PSH flag will not be set on last segment sent,
Returns
- ERR_OK if enqueued, another err_t on error

### tcp_output()
```
err_t tcp_output ( struct tcp_pcb * pcb )
```
Parameters
- pcb Protocol control block for the TCP connection to send data
Returns
- ERR_OK if data has been sent or nothing to send another err_t on error


Loading

0 comments on commit b668c1e

Please sign in to comment.