drv_wifi.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Copyright (C) 2019 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DRV_WIFI_
  13. #define _DRV_WIFI_
  14. #include "osi_compiler.h"
  15. OSI_EXTERN_C_BEGIN
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. #define WIFI_CHANNEL_MAX 13
  19. typedef struct drv_wifi drvWifi_t;
  20. /**
  21. * @brief WIFI AP information
  22. */
  23. typedef struct
  24. {
  25. uint32_t bssid_low; ///< mac address low
  26. uint16_t bssid_high; ///< mac address high
  27. uint8_t channel; ///< channel id
  28. int8_t rssival; ///< signal strength
  29. } wifiApInfo_t;
  30. typedef struct
  31. {
  32. uint32_t max; ///< set by caller, must room count for store aps
  33. uint32_t found; ///< set by wifi, actual found ap count
  34. uint32_t maxtimeout; ///< max timeout in milliseconds for each channel
  35. wifiApInfo_t *aps; ///< room for aps
  36. } wifiScanRequest_t;
  37. /**
  38. * \brief function type, will be call in IRQ.
  39. * report new scanned ap information
  40. * \param[out] info wifi ap info
  41. */
  42. typedef void (*wifiScanAsyncCb_t)(const wifiApInfo_t *info, void *ctx);
  43. /**
  44. * \brief open wifi
  45. *
  46. * \return
  47. * - NULL if fail else wifi context
  48. */
  49. drvWifi_t *drvWifiOpen(void);
  50. /**
  51. * \brief close wifi
  52. *
  53. * \param d wifi context
  54. */
  55. void drvWifiClose(drvWifi_t *d);
  56. /**
  57. * \brief scan all channels, this API is deprecated
  58. *
  59. * \param d wifi context
  60. * \param req wifi scan request context
  61. * \param round scan all channel for \round times
  62. * \return
  63. * - true on succeed else fail
  64. */
  65. bool drvWifiScanAllChannel(drvWifi_t *d, wifiScanRequest_t *req, uint32_t round) __attribute__((deprecated));
  66. /**
  67. * \brief scan a specific channel
  68. *
  69. * \param d wifi context
  70. * \param req wifi scan request context
  71. * \param ch the channel id
  72. * \return
  73. * - true on succeed else fail
  74. */
  75. bool drvWifiScanChannel(drvWifi_t *d, wifiScanRequest_t *req, uint32_t ch);
  76. /**
  77. * \brief start scan a channel and capture the result by cb
  78. * this API is asynchornous and not stop scan before call `drvWifiScanAsyncStop`
  79. * \note the `cb` maybe called in ISR, do not do time-consuming operations
  80. *
  81. * \param d wifi device
  82. * \param cb the scan callback
  83. * \param ctx caller context
  84. * \return
  85. * - true on success else fail
  86. */
  87. bool drvWifiScanAsyncStart(drvWifi_t *d, uint32_t ch, wifiScanAsyncCb_t cb, void *ctx);
  88. /**
  89. * \brief stop the async scan
  90. *
  91. * \param d wifi device
  92. */
  93. void drvWifiScanAsyncStop(drvWifi_t *d);
  94. OSI_EXTERN_C_END
  95. #endif