123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /**
- * Copyright (c) 2019 Kalycito Infotech Private Limited
- * @file
- * @brief Includes/supports the types/calls required by the MQTT-C client.
- *
- * @note This is the \em only file included in mqtt.h, and mqtt.c. It is therefore
- * responsible for including/supporting all the required types and calls.
- *
- * @defgroup pal Platform abstraction layer
- * @brief Documentation of the types and calls required to port MQTT-C to a new platform.
- *
- * mqtt_pal.h is the \em only header file included in mqtt.c. Therefore, to port MQTT-C to a
- * new platform the following types, functions, constants, and macros must be defined in
- * mqtt_pal.h:
- * - Types:
- * - \c size_t, \c ssize_t
- * - \c uint8_t, \c uint16_t, \c uint32_t
- * - \c va_list
- * - \c mqtt_pal_time_t : return type of \c MQTT_PAL_TIME()
- * - \c mqtt_pal_mutex_t : type of the argument that is passed to \c MQTT_PAL_MUTEX_LOCK and
- * \c MQTT_PAL_MUTEX_RELEASE
- * - Functions:
- * - \c memcpy, \c strlen
- * - \c va_start, \c va_arg, \c va_end
- * - Constants:
- * - \c INT_MIN
- *
- * Additionally, three macro's are required:
- * - \c MQTT_PAL_HTONS(s) : host-to-network endian conversion for uint16_t.
- * - \c MQTT_PAL_NTOHS(s) : network-to-host endian conversion for uint16_t.
- * - \c MQTT_PAL_TIME() : returns [type: \c mqtt_pal_time_t] current time in seconds.
- * - \c MQTT_PAL_MUTEX_LOCK(mtx_pointer) : macro that locks the mutex pointed to by \c mtx_pointer.
- * - \c MQTT_PAL_MUTEX_RELEASE(mtx_pointer) : macro that unlocks the mutex pointed to by
- * \c mtx_pointer.
- *
- * Lastly, \ref mqtt_pal_sendall and \ref mqtt_pal_recvall, must be implemented in mqtt_pal.c
- * for sending and receiving data using the platforms socket calls.
- */
- /* UNIX-like platform support */
-
-
-
-
-
-
- /*
-
- typedef BIO* mqtt_pal_socket_handle;
-
- typedef int mqtt_pal_socket_handle;
-
-
-
-
-
- typedef time_t mqtt_pal_time_t;
- typedef pthread_mutex_t mqtt_pal_mutex_t;
-
-
-
- struct my_custom_socket_handle {
- void* client;
- void* connection;
- uint16_t timeout;
- };
-
- typedef struct my_custom_socket_handle* mqtt_pal_socket_handle;
- /**
- * @brief Sends all the bytes in a buffer.
- * @ingroup pal
- *
- * @param[in] fd The file-descriptor (or handle) of the socket.
- * @param[in] buf A pointer to the first byte in the buffer to send.
- * @param[in] len The number of bytes to send (starting at \p buf).
- * @param[in] flags Flags which are passed to the underlying socket.
- *
- * @returns The number of bytes sent if successful, an \ref MQTTErrors otherwise.
- */
- ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags);
- /**
- * @brief Non-blocking receive all the byte available.
- * @ingroup pal
- *
- * @param[in] fd The file-descriptor (or handle) of the socket.
- * @param[in] buf A pointer to the receive buffer.
- * @param[in] bufsz The max number of bytes that can be put into \p buf.
- * @param[in] flags Flags which are passed to the underlying socket.
- *
- * @returns The number of bytes received if successful, an \ref MQTTErrors otherwise.
- */
- ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags);
|