46e7570dcd
- the first characteristic is used to receive data from client. - the second characteristic is used to notify data to client. - the third characteristic is used to receive command from client, user can add code to process the command. - the fourth characteristic is used to notify status to client. - the fifth characteristic is used to keep ble connection
57 lines
1.5 KiB
C
57 lines
1.5 KiB
C
// 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.
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.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_RECV_CHAR,
|
|
SPP_IDX_SPP_DATA_RECV_VAL,
|
|
|
|
SPP_IDX_SPP_DATA_NOTIFY_CHAR,
|
|
SPP_IDX_SPP_DATA_NTY_VAL,
|
|
SPP_IDX_SPP_DATA_NTF_CFG,
|
|
|
|
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,
|
|
};
|