2 * Copyright (C) 2012 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 uint8_t PSRM
, PSPM
, PSM
;
26 uint16_t co
; //clock offset
31 #define SUPORT_SSP 0 // 1
33 #define BT_CONN_LINK_TYPE_SCO 0
34 #define BT_CONN_LINK_TYPE_ACL 1
36 #define BT_BCAST_NONE 0 //point to point
37 #define BT_BCAST_ACTIVE 1 //to all active slaves
38 #define BT_BCAST_PICONET 2 //to all slaves (even parked)
40 #define BT_RX_BUF_SZ 1024
41 #define BT_BAUDRATE 1750000
44 #define BT_LINK_KEY_SIZE 16
48 #define BT_SSP_DONE_VAL 0x0FF00000
54 char (*BtDiscoveryF
)(void* userData
, BtDiscoveryResult
* r
);
55 char (*BtConnReqF
)(void* userData
, const uint8_t* mac
, uint32_t devClass
, uint8_t linkType
); //return 1 to accept
56 void (*BtConnStartF
)(void* userData
, uint16_t conn
, const uint8_t* mac
, uint8_t linkType
, uint8_t encrMode
);
57 void (*BtConnEndF
)(void* userData
, uint16_t conn
, uint8_t reason
);
58 uint8_t (*BtPinRequestF
)(void* userData
, const uint8_t* mac
, uint8_t* buf
); //fill buff with PIN code, return num bytes used (16 max) return 0 to decline
60 char (*BtLinkKeyRequestF
)(void* userData
, const uint8_t* mac
, uint8_t* buf
); //fill buff with the 16-byte link key if known. return 1 if yes, 0 if no
61 void (*BtLinkKeyCreatedF
)(void* userData
, const uint8_t* mac
, const uint8_t* key
); //save the key, if you want to...
63 void (*BtAclDataRxF
)(void* userData
, uint16_t conn
, char first
, uint8_t bcastType
, const uint8_t* data
, uint16_t sz
);
65 void (*BtSspShow
)(void* userData
, const uint8_t* mac
, uint32_t sspVal
);
69 char btInit(const BtFuncs
* btf
);
71 char btLocalMac(uint8_t* buf
);
72 char btSetLocalName(const char* name
);
73 char btGetRemoteName(const uint8_t* mac
, uint8_t PSRM
, uint8_t PSM
, uint16_t co
, char* nameBuf
);
75 char btDiscoverable(char on
);
76 char btConnectable(char on
);
77 char btSetDeviceClass(uint32_t cls
);
80 void btAclDataTx(uint16_t conn
, char first
, uint8_t bcastType
, sg_buf
* buf
);