You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.6 KiB
65 lines
1.6 KiB
/*
|
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
|
|
Unless required by applicable law or agreed to in writing, this
|
|
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
CONDITIONS OF ANY KIND, either express or implied.
|
|
*/
|
|
#pragma once
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "ble_parse_data.h"
|
|
#include "driver/uart.h"
|
|
#include "esp_bt.h"
|
|
#include "esp_bt_defs.h"
|
|
#include "esp_bt_main.h"
|
|
#include "esp_gap_ble_api.h"
|
|
#include "esp_gatts_api.h"
|
|
#include "esp_log.h"
|
|
#include "esp_system.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/event_groups.h"
|
|
#include "freertos/task.h"
|
|
#include "nvs_flash.h"
|
|
|
|
/*
|
|
* DEFINES
|
|
****************************************************************************************
|
|
*/
|
|
//#define SUPPORT_HEARTBEAT
|
|
//#define SPP_DEBUG_MODE
|
|
|
|
#define spp_sprintf(s, ...) sprintf((char *)(s), ##__VA_ARGS__)
|
|
#define SPP_DATA_MAX_LEN (512)
|
|
#define SPP_CMD_MAX_LEN (20)
|
|
#define SPP_STATUS_MAX_LEN (20)
|
|
#define SPP_DATA_BUFF_MAX_LEN (2 * 1024)
|
|
/// Attributes State Machine
|
|
enum {
|
|
SPP_IDX_SVC,
|
|
|
|
SPP_IDX_SPP_DATA_NOTIFY_CHAR,
|
|
SPP_IDX_SPP_DATA_NTY_VAL,
|
|
SPP_IDX_SPP_DATA_NTF_CFG,
|
|
|
|
SPP_IDX_SPP_DATA_RECV_CHAR,
|
|
SPP_IDX_SPP_DATA_RECV_VAL,
|
|
|
|
SPP_IDX_SPP_COMMAND_CHAR,
|
|
SPP_IDX_SPP_COMMAND_VAL,
|
|
|
|
SPP_IDX_SPP_STATUS_CHAR,
|
|
SPP_IDX_SPP_STATUS_VAL,
|
|
SPP_IDX_SPP_STATUS_CFG,
|
|
|
|
#ifdef SUPPORT_HEARTBEAT
|
|
SPP_IDX_SPP_HEARTBEAT_CHAR,
|
|
SPP_IDX_SPP_HEARTBEAT_VAL,
|
|
SPP_IDX_SPP_HEARTBEAT_CFG,
|
|
#endif
|
|
|
|
SPP_IDX_NB,
|
|
};
|
|
void ble_spp_server_demo_app_main(bluetooth_processer_t *bluetooth_processer);
|