ua_architecture.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  3. *
  4. * Copyright 2016-2017 (c) Julius Pfrommer, Fraunhofer IOSB
  5. * Copyright 2017-2018 (c) Stefan Profanter, fortiss GmbH
  6. */
  7. #ifdef UA_ARCHITECTURE_ARDUINO
  8. #ifndef PLUGINS_ARCH_ARDUINO_UA_ARCHITECTURE_H_
  9. #define PLUGINS_ARCH_ARDUINO_UA_ARCHITECTURE_H_
  10. #define UA_THREAD_LOCAL
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #define LWIP_TIMEVAL_PRIVATE 0
  14. //#define LWIP_COMPAT_MUTEX 0
  15. #define LWIP_POSIX_SOCKETS_IO_NAMES 0
  16. #ifdef LWIP_COMPAT_SOCKETS
  17. #undef LWIP_COMPAT_SOCKETS
  18. #endif
  19. #define LWIP_COMPAT_SOCKETS 0
  20. //#define __USE_W32_SOCKETS 1 //needed to avoid redefining of select in sys/select.h
  21. #include <lwip/tcpip.h>
  22. #include <lwip/netdb.h>
  23. #define sockaddr_storage sockaddr
  24. #ifdef BYTE_ORDER
  25. # undef BYTE_ORDER
  26. #endif
  27. #define UA_sleep_ms(X) vTaskDelay(pdMS_TO_TICKS(X))
  28. #define OPTVAL_TYPE int
  29. #include <unistd.h> // read, write, close
  30. #define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
  31. #define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
  32. #define UA_access access
  33. #define UA_IPV6 0
  34. #define UA_SOCKET int
  35. #define UA_INVALID_SOCKET -1
  36. #define UA_ERRNO errno
  37. #define UA_INTERRUPTED EINTR
  38. #define UA_AGAIN EAGAIN
  39. #define UA_EAGAIN EAGAIN
  40. #define UA_WOULDBLOCK EWOULDBLOCK
  41. #define UA_ERR_CONNECTION_PROGRESS EINPROGRESS
  42. // No log colors on Arduino
  43. // #define UA_ENABLE_LOG_COLORS
  44. #define UA_send lwip_send
  45. #define UA_recv lwip_recv
  46. #define UA_close lwip_close
  47. #define UA_select lwip_select
  48. #define UA_shutdown lwip_shutdown
  49. #define UA_socket lwip_socket
  50. #define UA_bind lwip_bind
  51. #define UA_listen lwip_listen
  52. #define UA_accept lwip_accept
  53. #define UA_connect lwip_connect
  54. #define UA_getsockopt lwip_getsockopt
  55. #define UA_setsockopt lwip_setsockopt
  56. #define UA_freeaddrinfo lwip_freeaddrinfo
  57. #define UA_gethostname gethostname_freertos
  58. #define UA_getaddrinfo lwip_getaddrinfo
  59. #define UA_free free
  60. #define UA_malloc malloc
  61. #define UA_calloc calloc
  62. #define UA_realloc realloc
  63. #include <stdio.h>
  64. #define UA_snprintf snprintf
  65. int gethostname_freertos(char* name, size_t len);
  66. #define UA_LOG_SOCKET_ERRNO_WRAP(LOG) { \
  67. char *errno_str = ""; \
  68. LOG; \
  69. }
  70. #define UA_LOG_SOCKET_ERRNO_GAI_WRAP UA_LOG_SOCKET_ERRNO_WRAP
  71. #include "../ua_architecture_functions.h"
  72. #endif /* PLUGINS_ARCH_ARDUINO_UA_ARCHITECTURE_H_ */
  73. #endif /* UA_ARCHITECTURE_ARDUINO */