bot_platform.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) 2020-2021 Alibaba Group Holding Limited
  3. */
  4. #ifndef __BOT_PLATFORM_H
  5. #define __BOT_PLATFORM_H
  6. #include <stdio.h>
  7. #include <stdbool.h>
  8. #include <string.h>
  9. #include <stdlib.h>
  10. #include <stdarg.h>
  11. #include <sys/time.h>
  12. #include <time.h>
  13. #include "lfs.h"
  14. #include "errno.h"
  15. #include "sockets.h"
  16. #include "netdb.h"
  17. #include "FreeRTOS.h"
  18. #include "queue.h"
  19. #include "semphr.h"
  20. #include "luat_fs.h"
  21. #include "netdb.h"
  22. #define BOT_FS_USER_DIR "\bot" ///< bot storage folder
  23. #define BOT_UT_MAL_CELL_PDP_OFF
  24. #define BOT_O_RDONLY LFS_O_RDONLY ///< open file as read-only
  25. #define BOT_O_WRONLY LFS_O_WRONLY ///< open the file for writing only
  26. #define BOT_O_RDWR LFS_O_RDWR ///< Open the file for reading and writing. The above three flags are mutually exclusive, that is, they cannot be used at the same time, but they can be combined with the following flags using the OR (|) operator.
  27. #define BOT_O_APPEND LFS_O_APPEND ///< When reading and writing a file, it will move from the end of the file, that is, the written data will be added to the back of the file in an additional way.
  28. #define BOT_O_CREAT LFS_O_CREAT ///< If the file to be opened does not exist, it will be created automatically.
  29. #define BOT_O_TRUNC LFS_O_TRUNC ///< If the file exists and is opened in a writable mode, this flag will clear the file length to 0, and the data originally stored in the file will also disappear.
  30. /* micro defination about file system, used for bot_fseek()'s/bot_seek()'s whence */
  31. #define BOT_SEEK_SET LFS_SEEK_SET ///< beginning of file
  32. #define BOT_SEEK_CUR LFS_SEEK_CUR ///< current position
  33. #define BOT_SEEK_END LFS_SEEK_END ///< end of file
  34. #define LUAT_RTOS_PRIORITY_HIGH 95
  35. #define LUAT_RTOS_PRIORITY_ABOVE_NORMAL 75
  36. #define LUAT_RTOS_PRIORITY_NORMAL 55
  37. #define LUAT_RTOS_PRIORITY_BELOW_NORMAL 35
  38. #define LUAT_RTOS_PRIORITY_LOW 15
  39. /* bot error code defination */
  40. #define BOT_E_EINTR EINTR ///< 4, Interrupted system call
  41. #define BOT_E_EAGAIN EAGAIN ///< 11, Try again
  42. #define BOT_E_EPIPE EPIPE ///< 32, Broken pipe
  43. #define BOT_E_EWOULDBLOCK EWOULDBLOCK ///< like, EAGAIN, Operation would block
  44. #define BOT_E_ECONNRESET ECONNRESET ///< 104, FConnection reset by peer
  45. // /* socket macros */
  46. #define BOT_AF_UNSPEC AF_UNSPEC ///< AF_UNSPEC
  47. #define BOT_SOCK_STREAM SOCK_STREAM ///< Stream sockets
  48. #define BOT_SOCK_DGRAM SOCK_DGRAM ///< Datagram sockets
  49. #define BOT_IPPROTO_TCP IPPROTO_TCP ///< TCP protocol
  50. #define BOT_IPPROTO_UDP IPPROTO_UDP ///< UDP protocol
  51. #endif /* __BOT_PLATFORM_H */