2 * This file is part of INAV.
4 * INAV is free software. You can redistribute this software
5 * and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * INAV is distributed in the hope that they will be
11 * useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
24 #include <arpa/inet.h>
25 #include <sys/socket.h>
26 #include <netinet/in.h>
29 #include "drivers/serial.h"
31 #define BASE_IP_ADDRESS 5760
32 #define TCP_BUFFER_SIZE 2048
33 #define TCP_MAX_PACKET_SIZE 65535
37 serialPort_t serialPort
;
39 uint8_t rxBuffer
[TCP_BUFFER_SIZE
];
43 pthread_mutex_t receiveMutex
;
44 pthread_t receiveThread
;
47 struct sockaddr_storage sockAddress
;
48 struct sockaddr_storage clientAddress
;
49 bool isClientConnected
;
53 serialPort_t
*tcpOpen(USART_TypeDef
*USARTx
, serialReceiveCallbackPtr callback
, void *rxCallbackData
, uint32_t baudRate
, portMode_t mode
, portOptions_t options
);
55 extern void tcpSend(tcpPort_t
*port
);
56 extern int tcpReceive(tcpPort_t
*port
);
57 extern void tcpReceiveBytesEx( int portIndex
, const uint8_t* buffer
, ssize_t recvSize
);
58 extern uint32_t tcpRXBytesFree(int portIndex
);