Added esp_spp_vfs_unregister() to free memory allocated by esp_spp_vfs_register()

This commit is contained in:
xiongweichao
2022-04-26 17:24:51 +08:00
parent 84ab32b4ef
commit 4a702a2011
4 changed files with 124 additions and 22 deletions
@@ -90,6 +90,8 @@ typedef enum {
ESP_SPP_WRITE_EVT = 33, /*!< When SPP write operation completes, the event comes, only for ESP_SPP_MODE_CB */
ESP_SPP_SRV_OPEN_EVT = 34, /*!< When SPP Server connection open, the event comes */
ESP_SPP_SRV_STOP_EVT = 35, /*!< When SPP server stopped, the event comes */
ESP_SPP_VFS_REGISTER_EVT = 36, /*!< When SPP VFS register, the event comes */
ESP_SPP_VFS_UNREGISTER_EVT = 37, /*!< When SPP VFS unregister, the event comes */
} esp_spp_cb_event_t;
@@ -208,6 +210,20 @@ typedef union {
uint32_t handle; /*!< The connection handle */
bool cong; /*!< TRUE, congested. FALSE, uncongested */
} cong; /*!< SPP callback param of ESP_SPP_CONG_EVT */
/**
* @brief ESP_SPP_VFS_REGISTER_EVT
*/
struct spp_vfs_register_evt_param {
esp_spp_status_t status; /*!< status */
} vfs_register; /*!< SPP callback param of ESP_SPP_VFS_REGISTER_EVT */
/**
* @brief ESP_SPP_VFS_UNREGISTER_EVT
*/
struct spp_vfs_unregister_evt_param {
esp_spp_status_t status; /*!< status */
} vfs_unregister; /*!< SPP callback param of ESP_SPP_VFS_UNREGISTER_EVT */
} esp_spp_cb_param_t; /*!< SPP callback parameter union type */
/**
@@ -388,6 +404,8 @@ esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data);
/**
* @brief This function is used to register VFS.
* For now, SPP only supports write, read and close.
* When the operation is completed, the callback function will be called with ESP_SPP_VFS_REGISTER_EVT.
* This function must be called after esp_spp_init()/esp_spp_enhanced_init() successful and before esp_spp_deinit().
*
* @return
* - ESP_OK: success
@@ -395,6 +413,17 @@ esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data);
*/
esp_err_t esp_spp_vfs_register(void);
/**
* @brief This function is used to unregister VFS.
* When the operation is completed, the callback function will be called with ESP_SPP_VFS_UNREGISTER_EVT.
* This function must be called after esp_spp_vfs_register() successful and before esp_spp_deinit().
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_spp_vfs_unregister(void);
#ifdef __cplusplus
}
#endif