69 lines
2.4 KiB
C
69 lines
2.4 KiB
C
|
/****************************************************************************
|
||
|
|
||
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||
|
|
||
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||
|
be copied by any method or incorporated into another program without
|
||
|
the express written consent of Aerospace C.Power. This Information or any portion
|
||
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||
|
liability for its use in any way and conveys no license or title under
|
||
|
any patent or copyright and makes no representation or warranty that this
|
||
|
Information is free from patent or copyright infringement.
|
||
|
|
||
|
****************************************************************************/
|
||
|
|
||
|
#ifndef OS_SHIM_COMMUNICATOR_H
|
||
|
#define OS_SHIM_COMMUNICATOR_H
|
||
|
|
||
|
/* FreeRTOS includes */
|
||
|
#include "FreeRTOS.h"
|
||
|
#include "task.h"
|
||
|
|
||
|
#include "FreeRTOS_IP.h"
|
||
|
#include "FreeRTOS_Sockets.h"
|
||
|
#include "FreeRTOS_IP_Private.h"
|
||
|
/* os shim includes */
|
||
|
#include "os_types.h"
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
typedef Socket_t os_socket_t;
|
||
|
typedef struct freertos_sockaddr os_sock_addr;
|
||
|
|
||
|
#define RTOS_MAX_UDP_PAYLOAD 2*ipMAX_UDP_PAYLOAD_LENGTH
|
||
|
#define OS_INVALID_SOCKET FREERTOS_INVALID_SOCKET
|
||
|
#define OS_TICK pdMS_TO_TICKS
|
||
|
#define os_htons FreeRTOS_htons
|
||
|
#define os_ntoa( ulIPAddress, pucBuffer ) \
|
||
|
iot_sprintf( ( char * ) ( pucBuffer ), "%u.%u.%u.%u", \
|
||
|
( ( unsigned ) ( ( ulIPAddress ) & 0xffUL ) ), \
|
||
|
( ( unsigned ) ( ( ( ulIPAddress ) >> 8 ) & 0xffUL ) ), \
|
||
|
( ( unsigned ) ( ( ( ulIPAddress ) >> 16 ) & 0xffUL ) ),\
|
||
|
( ( unsigned ) ( ( ulIPAddress ) >> 24 ) ) )
|
||
|
|
||
|
|
||
|
typedef enum _sock_protocol {
|
||
|
UDP,
|
||
|
TCP
|
||
|
}sock_protocol_t;
|
||
|
|
||
|
os_socket_t os_udpsocket();
|
||
|
uint32_t os_setsock_recvtimeout_opt(os_socket_t socket, uint32_t timeout);
|
||
|
uint32_t os_sock_bind(os_socket_t socket, os_sock_addr addr);
|
||
|
uint32_t os_close_socket(os_socket_t socket);
|
||
|
void get_local_address_configuration(uint32_t *ipaddress,
|
||
|
uint32_t *netmask, uint32_t *gateway, uint32_t *dnsserver);
|
||
|
int32_t os_recv_from(os_socket_t socket, void* buffer, size_t len,
|
||
|
uint32_t flags, os_sock_addr* sockaddr, uint32_t *addrlen);
|
||
|
int32_t os_sendto(os_socket_t socket, void* buffer, size_t len, uint32_t flags,
|
||
|
const os_sock_addr* destaddr, uint32_t addrlen);
|
||
|
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif /* OS_SHIM_COMMUNICATOR_H */
|