2016-11-24 17:58:26 +00:00
|
|
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-11-16 14:11:59 +00:00
|
|
|
#ifndef __ESP_BLUFI_API_H__
|
|
|
|
#define __ESP_BLUFI_API_H__
|
|
|
|
|
|
|
|
#include "esp_bt_defs.h"
|
|
|
|
#include "esp_gatt_defs.h"
|
|
|
|
#include "esp_err.h"
|
|
|
|
|
2016-12-08 06:26:19 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-11-28 13:59:04 +00:00
|
|
|
#define ESP_BLUFI_RECV_DATA_LEN_MAX (64+1)
|
2016-11-16 14:11:59 +00:00
|
|
|
|
2016-12-11 08:36:47 +00:00
|
|
|
typedef enum {
|
|
|
|
ESP_BLUFI_EVENT_INIT_FINISH = 0,
|
|
|
|
ESP_BLUFI_EVENT_DEINIT_FINISH = 1,
|
|
|
|
ESP_BLUFI_EVENT_RECV_DATA = 2,
|
|
|
|
} esp_blufi_cb_event_t;
|
2016-11-16 14:11:59 +00:00
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// BLUFI config status
|
2016-11-16 14:11:59 +00:00
|
|
|
typedef enum {
|
2016-11-24 18:10:15 +00:00
|
|
|
ESP_BLUFI_CONFIG_OK = 0,
|
|
|
|
ESP_BLUFI_CONFIG_FAILED,
|
2016-11-16 14:11:59 +00:00
|
|
|
} esp_blufi_config_state_t;
|
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// BLUFI init status
|
2016-11-16 14:11:59 +00:00
|
|
|
typedef enum {
|
2016-11-24 18:10:15 +00:00
|
|
|
ESP_BLUFI_INIT_OK = 0,
|
|
|
|
ESP_BLUFI_INIT_FAILED = 0,
|
2016-11-16 14:11:59 +00:00
|
|
|
} esp_blufi_init_state_t;
|
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// BLUFI deinit status
|
2016-11-16 14:11:59 +00:00
|
|
|
typedef enum {
|
2016-11-24 18:10:15 +00:00
|
|
|
ESP_BLUFI_DEINIT_OK = 0,
|
|
|
|
ESP_BLUFI_DEINIT_FAILED = 0,
|
2016-11-16 14:11:59 +00:00
|
|
|
} esp_blufi_deinit_state_t;
|
|
|
|
|
2016-11-29 07:32:29 +00:00
|
|
|
/**
|
|
|
|
* @brief BLUFI callback parameters union
|
|
|
|
*/
|
2016-11-16 14:11:59 +00:00
|
|
|
typedef union {
|
2016-11-29 07:32:29 +00:00
|
|
|
/**
|
|
|
|
* @brief ESP_BLUFI_EVENT_INIT_FINISH
|
|
|
|
*/
|
2016-11-24 18:10:15 +00:00
|
|
|
struct blufi_init_finish_evt_param {
|
2016-11-28 13:59:04 +00:00
|
|
|
esp_blufi_init_state_t state; /*!< Initial status */
|
|
|
|
} init_finish; /*!< Blufi callback param of ESP_BLUFI_EVENT_INIT_FINISH */
|
|
|
|
|
2016-11-29 07:32:29 +00:00
|
|
|
/**
|
|
|
|
* @brief ESP_BLUFI_EVENT_DEINIT_FINISH
|
|
|
|
*/
|
2016-11-24 18:10:15 +00:00
|
|
|
struct blufi_deinit_finish_evt_param {
|
2016-11-28 13:59:04 +00:00
|
|
|
esp_blufi_deinit_state_t state; /*!< De-initial status */
|
|
|
|
} deinit_finish; /*!< Blufi callback param of ESP_BLUFI_EVENT_DEINIT_FINISH */
|
|
|
|
|
2016-11-29 07:32:29 +00:00
|
|
|
/**
|
|
|
|
* @brief ESP_BLUFI_EVENT_RECV_DATA
|
|
|
|
*/
|
2016-11-24 18:10:15 +00:00
|
|
|
struct blufi_recv_evt_param {
|
2016-11-28 13:59:04 +00:00
|
|
|
uint8_t data[ESP_BLUFI_RECV_DATA_LEN_MAX]; /*!< Blufi receive data */
|
|
|
|
uint8_t data_len; /*!< Blufi receive data length */
|
|
|
|
} recv_data; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_DATA */
|
2016-11-16 14:11:59 +00:00
|
|
|
} esp_blufi_cb_param_t;
|
|
|
|
|
2016-12-11 08:36:47 +00:00
|
|
|
/**
|
|
|
|
* @brief BLUFI callback function type
|
|
|
|
* @param event : Event type
|
|
|
|
* @param param : Point to callback parameter, currently is union type
|
|
|
|
*/
|
|
|
|
typedef void (* esp_blufi_cb_t)(esp_blufi_cb_event_t event, esp_blufi_cb_param_t *param);
|
|
|
|
|
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief This function is called to receive blufi callback event
|
|
|
|
*
|
|
|
|
* @param[in] callback: callback function
|
|
|
|
*
|
|
|
|
* @return ESP_OK - success, other - failed
|
|
|
|
*
|
|
|
|
*/
|
2016-12-11 08:36:47 +00:00
|
|
|
esp_err_t esp_blufi_register_callback(esp_blufi_cb_t callback);
|
2016-11-16 14:11:59 +00:00
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief This function is called to send config state to phone
|
|
|
|
*
|
|
|
|
* @param[in] state: blufi config OK or not
|
|
|
|
*
|
|
|
|
* @return ESP_OK - success, other - failed
|
|
|
|
*
|
|
|
|
*/
|
2016-11-16 14:11:59 +00:00
|
|
|
esp_err_t esp_blufi_send_config_state(esp_blufi_config_state_t state);
|
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief This function is called to initialize blufi_profile
|
|
|
|
*
|
|
|
|
* @return ESP_OK - success, other - failed
|
|
|
|
*
|
|
|
|
*/
|
2016-11-16 14:11:59 +00:00
|
|
|
esp_err_t esp_blufi_profile_init(void);
|
|
|
|
|
2016-12-01 12:55:08 +00:00
|
|
|
/**
|
2016-12-01 10:58:54 +00:00
|
|
|
*
|
|
|
|
* @brief This function is called to de-initialize blufi_profile
|
|
|
|
*
|
|
|
|
* @return ESP_OK - success, other - failed
|
|
|
|
*
|
|
|
|
*/
|
2016-11-16 14:11:59 +00:00
|
|
|
esp_err_t esp_blufi_profile_deinit(void);
|
|
|
|
|
2016-12-08 06:26:19 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2016-11-16 14:11:59 +00:00
|
|
|
|
|
|
|
#endif /* _ESP_BLUFI_API_ */
|