added k60d100m project
[adk-bluetooth-test.git] / adk-stack / BT.h
blob1f448d520fc5839e1b2ef6afde3e4184f2cdc9d9
1 /*
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.
16 #ifdef ADK_INTERNAL
17 #ifndef _BT_H_
18 #define _BT_H_
20 #include "sgBuf.h"
22 typedef struct{
24 uint8_t mac[6];
25 uint8_t PSRM, PSPM, PSM;
26 uint16_t co; //clock offset
27 uint32_t dc; //class
29 }BtDiscoveryResult;
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
45 #define BT_MAC_SIZE 6
48 #define BT_SSP_DONE_VAL 0x0FF00000
50 typedef struct{
52 void* userData;
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);
67 }BtFuncs;
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);
74 void btScan(void);
75 char btDiscoverable(char on);
76 char btConnectable(char on);
77 char btSetDeviceClass(uint32_t cls);
78 void btDeinit(void);
80 void btAclDataTx(uint16_t conn, char first, uint8_t bcastType, sg_buf* buf);
82 #endif
83 #endif