/********************************** (C) COPYRIGHT *******************************
 * File Name          : peripheral.h
 * Author             : WCH
 * Version            : V1.0
 * Date               : 2018/12/11
 * Description        :
 *********************************************************************************
 * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
 * Attention: This software (modified or not) and binary are used for 
 * microcontroller manufactured by Nanjing Qinheng Microelectronics.
 *******************************************************************************/

#ifndef PERIPHERAL_H
#define PERIPHERAL_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************************************************************
 * INCLUDES
 */

/*********************************************************************
 * CONSTANTS
 */

// Peripheral Task Events
#define SBP_START_DEVICE_EVT    0x0001
#define SBP_PERIODIC_EVT        0x0002
#define SBP_READ_RSSI_EVT       0x0004
#define SBP_PARAM_UPDATE_EVT    0x0008
#define SBP_PHY_UPDATE_EVT      0x0010

#define SBP_MTU_DELAY_EVT       0x0020      //YYW,20250917，MTU协商事件
#define SBP_PRINTF_BLE_EVT      0x0040      //YYW,20251008，跳转OTA事件


/* OTA 升级标志 */
#define IMAGE_IAP_FLAG       0x03

/* 存放在DataFlash地址，不能占用蓝牙的位置 */
#define OTA_DATAFLASH_ADD      0x0003A000
/*********************************************************************
 * MACROS
 */
typedef struct
{
    uint16_t connHandle; // Connection handle of current connection
    uint16_t connInterval;
    uint16_t connSlaveLatency;
    uint16_t connTimeout;
} peripheralConnItem_t;

/*********************************************************************
 * FUNCTIONS
 */
extern uint8_t BLE_OTA_flag;
/*
 * Task Initialization for the BLE Application
 */
extern void Peripheral_Init(void);
extern void Ble_Printfln(int DbgOptBit, const char *cmd, ...);
extern void Ble_Buff_Print(uint8_t *pValue, uint16_t len);
/*
 * Task Event Processor for the BLE Application
 */
extern uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events);
void Jump_OTA(void);  //YYW,20251009
gapRole_States_t Peripheral_GetBLEState(void);
/*********************************************************************
*********************************************************************/

#ifdef __cplusplus
}
#endif

#endif
