fix:修改UDP通讯中,取电变化上报机制

1、问题点:当RCU网络状态异常的情况下,网络还处于协商状态下,还未进入正常通讯环节时,取电变化不会进行判断。这会导致取电变化上报与实际产生取电状态时间点对不上。
2、将BLV_C1F_Module代码上传至Gitea,之前代码修改记录请查看 .\BasicCode\Readme.txt
This commit is contained in:
caocong
2026-01-23 09:23:12 +08:00
commit 95916b9995
622 changed files with 1336094 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : devinfoservice.h
* Author : WCH
* Version : V1.0
* Date : 2018/12/11
* Description :
*******************************************************************************/
#ifndef DEVINFOSERVICE_H
#define DEVINFOSERVICE_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
/*********************************************************************
* CONSTANTS
*/
// Device Information Service Parameters
#define DEVINFO_SYSTEM_ID 0
#define DEVINFO_MODEL_NUMBER 1
#define DEVINFO_SERIAL_NUMBER 2
#define DEVINFO_FIRMWARE_REV 3
#define DEVINFO_HARDWARE_REV 4
#define DEVINFO_SOFTWARE_REV 5
#define DEVINFO_MANUFACTURER_NAME 6
#define DEVINFO_11073_CERT_DATA 7
#define DEVINFO_PNP_ID 8
// IEEE 11073 authoritative body values
#define DEVINFO_11073_BODY_EMPTY 0
#define DEVINFO_11073_BODY_IEEE 1
#define DEVINFO_11073_BODY_CONTINUA 2
#define DEVINFO_11073_BODY_EXP 254
// System ID length
#define DEVINFO_SYSTEM_ID_LEN 8
// PnP ID length
#define DEVINFO_PNP_ID_LEN 7
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* MACROS
*/
/*********************************************************************
* Profile Callbacks
*/
/*********************************************************************
* API FUNCTIONS
*/
/*
* DevInfo_AddService- Initializes the Device Information service by registering
* GATT attributes with the GATT server.
*
*/
extern bStatus_t DevInfo_AddService( void );
/*********************************************************************
* @fn DevInfo_SetParameter
*
* @brief Set a Device Information parameter.
*
* @param param - Profile parameter ID
* @param len - length of data to right
* @param value - pointer to data to write. This is dependent on
* the parameter ID and WILL be cast to the appropriate
* data type (example: data type of uint16 will be cast to
* uint16 pointer).
*
* @return bStatus_t
*/
bStatus_t DevInfo_SetParameter( uint8 param, uint8 len, void *value );
/*
* DevInfo_GetParameter - Get a Device Information parameter.
*
* param - Profile parameter ID
* value - pointer to data to write. This is dependent on
* the parameter ID and WILL be cast to the appropriate
* data type (example: data type of uint16 will be cast to
* uint16 pointer).
*/
extern bStatus_t DevInfo_GetParameter( uint8 param, void *value );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* DEVINFOSERVICE_H */

View File

@@ -0,0 +1,226 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : gattprofile.h
* Author : WCH
* Version : V1.0
* Date : 2018/12/11
* Description :
*******************************************************************************/
#ifndef GATTPROFILE_H
#define GATTPROFILE_H
#include "CONFIG.h"
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
/*********************************************************************
* CONSTANTS
*/
// Profile Parameters
#define SIMPLEPROFILE_CHAR1 0 // RW uint8 - Profile Characteristic 1 value
#define SIMPLEPROFILE_CHAR2 1 // RW uint8 - Profile Characteristic 2 value
#define SIMPLEPROFILE_CHAR3 2 // RW uint8 - Profile Characteristic 3 value
#define SIMPLEPROFILE_CHAR4 3 // RW uint8 - Profile Characteristic 4 value
#define SIMPLEPROFILE_CHAR5 4 // RW uint8 - Profile Characteristic 4 value
// Simple Profile Service UUID
#define SIMPLEPROFILE_SERV_UUID 0xFFE0
// Key Pressed UUID
#define SIMPLEPROFILE_CHAR1_UUID 0xFFE1
#define SIMPLEPROFILE_CHAR2_UUID 0xFFE2
#define SIMPLEPROFILE_CHAR3_UUID 0xFFE3
#define SIMPLEPROFILE_CHAR4_UUID 0xFFE4
#define SIMPLEPROFILE_CHAR5_UUID 0xFFE5
// Simple Keys Profile Services bit fields
#define SIMPLEPROFILE_SERVICE 0x00000001
// Length of characteristic in bytes ( Default MTU is 23 )
#define SIMPLEPROFILE_CHAR1_LEN BLE_BUFF_MAX_LEN-4
#define SIMPLEPROFILE_CHAR2_LEN 4
//#define SIMPLEPROFILE_CHAR3_LEN 1
#define SIMPLEPROFILE_CHAR4_LEN BLE_BUFF_MAX_LEN-4
#define SIMPLEPROFILE_CHAR5_LEN 1
#define BLE_DEVICE_NAME_LEN (GAP_DEVICE_NAME_LEN - 1) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD>
#define BLE_INFO_NUM 5 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define SRAM_BLE_RECEIVE_START 0x031000 //BLE<4C><45><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
#define SRAM_BLE_RECEIVE_END (0x031000 + BLE_BUFF_MAX_LEN*BLE_INFO_NUM -1) //BLE<4C><45><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
#define SRAM_BLE_SEND_START (SRAM_BLE_RECEIVE_END+1) //BLE<4C><45><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
#define SRAM_BLE_SEND_END (SRAM_BLE_SEND_START+BLE_BUFF_MAX_LEN-1) //BLE<4C><45><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
#define SRAM_BLE_SAVE_START (SRAM_BLE_SEND_END+ 1) //BLE<4C><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
#define SRAM_BLE_END 0x0313FF //BLE<4C><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
typedef struct DEVICE_CONFIG* DEVICE_CONFIG_Ptr; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣָ<CFA2><D6B8>
typedef struct DEVICE_CONFIG{
uint8 device_type; //<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD>
uint8 device_addr; //<2F><EFBFBD><E8B1B8>ַ
uint8 ble_type:1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>0:<3A><><EFBFBD><EFBFBD>/1:<3A>ӻ<EFBFBD>
uint8 connect_sta:1; //<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC> 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0<><30>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
uint8 uuid_type:1; //UUID<49><44><EFBFBD>ͣ<EFBFBD>1:128bit<69><74> 0:16bit
uint8 connecting:1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><D3B1>ǣ<EFBFBD> 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0<><30>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
uint8 addr_type:3; //<2F><><EFBFBD><EFBFBD>mac<61><63>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>
uint8 mac[6]; //<2F><>Ӧ<EFBFBD><D3A6>mac<61><63>ַ
uint16 server_uuid; //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>uuid
uint16 char_uuid; //<2F><><EFBFBD><EFBFBD>uuid
uint8 uuid_128bit[16]; //128bit UUID,<2C><>uuid<69><64><EFBFBD><EFBFBD>Ϊ128bitʱʹ<CAB1><CAB9>
DEVICE_CONFIG_Ptr next; //<2F><>һ<EFBFBD><D2BB><EFBFBD>ڵ<EFBFBD>
}__attribute__ ((__packed__))BLE_DEVICE_CONFIG; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
#define BLE_TYPE_CENTRAL 0 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define BLE_TYPE_PERIPHERAL 1 //<2F><><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD>
#define UUID_TYPE_16BIT 0 //16bit UUID
#define UUID_TYPE_128BIT 1 //128bit UUID
#define BLE_DATA_TYPE_DATA 0 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define BLE_DATA_TYPE_CMD 1 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//typedef struct{
//
// uint8 ble_type:1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>/<2F>ӻ<EFBFBD>
// uint8
// uint8 addr:5; //<2F><EFBFBD><E8B1B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// uint16 server_uuid; //<2F><><EFBFBD><EFBFBD>uuid
// uint16 char_uuid; //<2F><><EFBFBD><EFBFBD>uuid
//
//}BLE_DEVICE_INFO;
typedef enum{
BLE_ERR_SUCCESS = 0, //<2F><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
BLE_ERR_WAITING_CONNECT = 1, //<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>
BLE_ERR_WAITING_SEND = 2, //<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>
BLE_ERR_CONNECT_FAIL = 3, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
BLE_ERR_DEVICE_Not_EXIST = 4, //<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BLE_ERR_FAIL = 5, //<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
BLE_ERR_INVALID = 6, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
}BLE_STA;
#pragma pack(1)
typedef struct{
uint8 ble_type:1; //Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>0:<3A><><EFBFBD><EFBFBD>/1:<3A>ӻ<EFBFBD>
uint8 send_flg:1; //<2F><><EFBFBD>ͱ<EFBFBD>־
uint8 wait_connected:1; //<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ӱ<EFBFBD>־ 1:<3A>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>
uint8 wait_send:1; //<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ͱ<EFBFBD>־ 1:<3A>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>
uint8 data_type:1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0:<3A><><EFBFBD><EFBFBD>; 1:<3A><><EFBFBD><EFBFBD>򿪹رմӻ<D5B4> NOTIFY<46><59>
uint8 send_state:3; //<2F><><EFBFBD><EFBFBD>״̬
uint16 wait_count; //<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD> <20><><EFBFBD><EFBFBD>ֻ<EFBFBD>ܵ<EFBFBD>
uint8 device_type; //<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD>
uint8 device_addr; //<2F><EFBFBD><E8B1B8>ַ
// uint8 sendDATA[BLE_BUFF_MAX_LEN]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>
// uint8 sendLEN; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
uint16 server_handle; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
uint16 char_handle; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
uint8 notify_id:4; //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>id(<28><><EFBFBD><EFBFBD>)
uint8 write_id:4; //д<><D0B4><EFBFBD><EFBFBD>id(<28><><EFBFBD><EFBFBD>)
uint32 BLE_SendAddr; //<2F><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>ַ
uint32 BLE_WriteAddr; //<2F><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD>д<EFBFBD><D0B4>ַ
uint32 BLE_ReadAddr; //<2F><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
}BLE_SEND_INFO;
#pragma pack()
extern BLE_SEND_INFO ble_send_info;
extern BLE_DEVICE_CONFIG* Ble_Device_Info_Ptr;
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* MACROS
*/
/*********************************************************************
* Profile Callbacks
*/
// Callback when a characteristic value has changed
typedef void (*simpleProfileChange_t)( uint8 paramID );
typedef struct
{
simpleProfileChange_t pfnSimpleProfileChange; // Called when characteristic value changes
} simpleProfileCBs_t;
extern unsigned char attDeviceName[BLE_DEVICE_NAME_LEN];
/*********************************************************************
* API FUNCTIONS
*/
/*
* SimpleProfile_AddService- Initializes the Simple GATT Profile service by registering
* GATT attributes with the GATT server.
*
* @param services - services to add. This is a bit map and can
* contain more than one service.
*/
extern bStatus_t SimpleProfile_AddService( uint32 services );
/*
* SimpleProfile_RegisterAppCBs - Registers the application callback function.
* Only call this function once.
*
* appCallbacks - pointer to application callbacks.
*/
extern bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks );
/*
* SimpleProfile_SetParameter - Set a Simple GATT Profile parameter.
*
* param - Profile parameter ID
* len - length of data to right
* value - pointer to data to write. This is dependent on
* the parameter ID and WILL be cast to the appropriate
* data type (example: data type of uint16 will be cast to
* uint16 pointer).
*/
extern bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value );
/*
* SimpleProfile_GetParameter - Get a Simple GATT Profile parameter.
*
* param - Profile parameter ID
* value - pointer to data to write. This is dependent on
* the parameter ID and WILL be cast to the appropriate
* data type (example: data type of uint16 will be cast to
* uint16 pointer).
*/
extern bStatus_t SimpleProfile_GetParameter( uint8 param, void *value );
/*
* simpleProfile_Notify - Send notification.
*
* connHandle - connect handle
* pNoti - pointer to structure to notify.
*/
extern bStatus_t simpleProfile_Notify( uint16 connHandle, attHandleValueNoti_t *pNoti );
/*********************************************************************
*********************************************************************/
void Ble_Parameter_Init(void);
void Ble_Recive_Task(void);
#ifdef __cplusplus
}
#endif
#endif