blob: e917efcfbf6096d2f20eef45542dd7579a1a66fb [file] [log] [blame]
/******************************************************************************
* @file ble_format.h
*
* @brief for TLSR chips
*
* @author public@telink-semi.com;
* @date Sep. 30, 2010
*
* @attention
*
* Copyright (C) 2019-2020 Telink Semiconductor (Shanghai) Co., 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.
*
*****************************************************************************/
#ifndef BLE_FORMAT_H
#define BLE_FORMAT_H
#if 1
typedef struct {
u8 type :4;
u8 rfu1 :1;
u8 chan_sel:1;
u8 txAddr :1;
u8 rxAddr :1;
}rf_adv_head_t;
typedef struct {
u8 llid :2;
u8 nesn :1;
u8 sn :1;
u8 md :1;
u8 rfu1 :3;
}rf_data_head_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
rf_adv_head_t header;
u8 rf_len; //LEN(6)_RFU(2)
u8 advA[6]; //address
u8 data[31]; //0-31 byte
}rf_packet_adv_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
rf_adv_head_t header; //RA(1)_TA(1)_RFU(2)_TYPE(4)
u8 rf_len; //LEN(6)_RFU(2)
u8 scanA[6]; //
u8 advA[6]; //
}rf_packet_scan_req_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
rf_adv_head_t header; //RA(1)_TA(1)_RFU(2)_TYPE(4)
u8 rf_len; //LEN(6)_RFU(2)
u8 advA[6]; //address
u8 data[31]; //0-31 byte
}rf_packet_scan_rsp_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type :4;
u8 rfu1 :1;
u8 chan_sel:1;
u8 txAddr :1;
u8 rxAddr :1;
u8 rf_len; //LEN(6)_RFU(2)
u8 initA[6]; //scanA
u8 advA[6]; //
u8 accessCode[4]; // access code
u8 crcinit[3];
u8 winSize;
u16 winOffset;
u16 interval;
u16 latency;
u16 timeout;
u8 chm[5];
u8 hop; //sca(3)_hop(5)
}rf_packet_connect_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
rf_adv_head_t header; //RA(1)_TA(1)_RFU(2)_TYPE(4): connect request PDU
u8 rf_len; //LEN(6)_RFU(2)
u8 scanA[6]; //
u8 advA[6]; //
u8 aa[4]; // access code
u8 crcinit[3];
u8 wsize;
u16 woffset;
u16 interval;
u16 latency;
u16 timeout;
u8 chm[5];
u8 hop; //sca(3)_hop(5)
}rf_packet_ll_init_t;
typedef struct {
u8 type;
u8 rf_len;
u8 opcode;
u8 winSize;
u16 winOffset;
u16 interval;
u16 latency;
u16 timeout;
u16 instant;
} rf_packet_ll_updateConnPara_t;
typedef struct{
u8 llid;
u8 rf_len;
u8 opcode;
u8 CtrData;
}rf_pkt_ll_unknown_rsp_t;
typedef struct{
rf_data_head_t header;
u8 rf_len;
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 data[1];
}rf_packet_l2cap_t;
typedef struct{
rf_data_head_t header;
u8 rf_len;
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 handle0;
u8 handle1;
u8 dat[20];
}rf_packet_att_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 data[1];
}rf_packet_l2cap_req_t;
typedef struct{
u32 dma_len;
u8 type;
u8 rf_len;
u16 l2capLen;
u16 chanId;
u8 code;
u8 id;
u16 dataLen;
u16 result;
}rf_pkt_l2cap_sig_connParaUpRsp_t;
typedef struct{
u8 type;
u8 rf_len;
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 data[1];
}rf_pkt_l2cap_req_t;
typedef struct{
u8 llid; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 id;
u16 data_len;
u16 min_interval;
u16 max_interval;
u16 latency;
u16 timeout;
}rf_packet_l2cap_connParaUpReq_t;
typedef struct{
u8 llid; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 id;
u16 data_len;
u16 result;
}rf_packet_l2cap_connParaUpRsp_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 errOpcode;
u16 errHandle;
u8 errReason;
}rf_packet_att_errRsp_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 startingHandle;
u8 startingHandle1;
u8 endingHandle;
u8 endingHandle1;
u8 attType[2]; //
}rf_packet_att_readByType_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 startingHandle;
u8 startingHandle1;
u8 endingHandle;
u8 endingHandle1;
u8 attType[2];
u8 attValue[2];
}rf_packet_att_findByTypeReq_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u16 data[1];
}rf_packet_att_findByTypeRsp_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 handle;
u8 handle1;
}rf_packet_att_read_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 handle;
u8 handle1;
u8 offset0;
u8 offset1;
}rf_packet_att_readBlob_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 value[22];
}rf_packet_att_readRsp_t;
typedef struct{
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 datalen;
u8 data[1]; // character_handle / property / value_handle / value
}rf_pkt_att_readByTypeRsp_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 datalen;
u8 data[1]; // character_handle / property / value_handle / value
}rf_packet_att_readByTypeRsp_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 datalen;
u8 data[3];
}rf_packet_att_readByGroupTypeRsp_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 format;
u8 data[1]; // character_handle / property / value_handle / value
}rf_packet_att_findInfoReq_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 flags;
}rf_packet_att_executeWriteReq_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 handle;
u8 handle1;
u8 value;
}rf_packet_att_write_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 handle[2];
u8 data;
}rf_packet_att_notification_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 mtu[2];
}rf_packet_att_mtu_t;
typedef struct{
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 mtu[2];
}rf_packet_att_mtu_exchange_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
}rf_packet_att_writeRsp_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RA(1)_TA(1)_RFU(2)_TYPE(4)
u8 rf_len; //LEN(6)_RFU(2)
u8 opcode;
u8 data[8];
}rf_packet_feature_rsp_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RA(1)_TA(1)_RFU(2)_TYPE(4)
u8 rf_len; //LEN(6)_RFU(2)
u8 opcode;
u8 mainVer;
u16 vendor;
u16 subVer;
}rf_packet_version_ind_t;
typedef struct{
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u8 opcode; //
u8 reason; //
}rf_packet_ll_terminate_t;
typedef struct{
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u8 opcode; //
u8 dat[1]; //
}rf_packet_ll_control_t;
typedef struct{
u32 dma_len; //won't be a fixed number as previous, should adjust with the mouse package number
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2cap;
u16 chanid;
u8 att;
u8 hl; // assigned by master
u8 hh; //
u8 dat[20];
}rf_packet_att_data_t;
typedef struct{
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 datalen;
u8 data[1]; // character_handle / property / value_handle / value
}att_readByTypeRsp_t;
typedef struct{
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 format;
u8 data[1]; // character_handle / property / value_handle / value
}att_findInfoRsp_t;
typedef struct{
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 value[22];
}att_readRsp_t;
typedef struct{
u8 type; //RFU(3)_MD(1)_SN(1)_NESN(1)-LLID(2)
u8 rf_len; //LEN(5)_RFU(3)
u16 l2capLen;
u16 chanId;
u8 opcode;
u8 handle;
u8 hh;
u8 value[1];
}att_notify_t;
typedef struct {
u8 type;
u8 address[BLE_ADDR_LEN];
} addr_t;
////////////////////////////////////////////////////////////////////////////
typedef struct {
u8 num;
u8 property;
u16 handle;
u16 uuid;
u16 ref;
} att_db_uuid16_t; //8-byte
typedef struct {
u8 num;
u8 property;
u16 handle;
u8 uuid[16];
} att_db_uuid128_t; //20-byte
//------------- event --------------------------------
typedef struct {
u8 status;
u16 connHandle;
u8 reason;
} event_disconnection_t; //20-byte
typedef struct {
u8 subcode;
u8 nreport;
u8 event_type;
u8 adr_type;
u8 mac[6];
u8 len;
u8 data[1];
} event_adv_report_t; //20-byte
typedef struct {
u8 subcode;
u8 status;
u16 handle;
u8 role;
u8 peer_adr_type;
u8 mac[6];
u16 interval;
u16 latency;
u16 timeout;
u8 accuracy;
} event_connection_complete_t; //20-byte
typedef struct {
u8 subcode;
u8 status;
u16 handle;
u16 interval;
u16 latency;
u16 timeout;
} event_connection_update_t; //20-byte
typedef struct {
u8 status;
u16 handle;
u8 enc_enable;
} event_enc_change_t;
typedef struct {
u8 status;
u16 handle;
} event_enc_refresh_t;
#endif
#endif