Return service ID to service

This commit is contained in:
Kristian Lauszus 2012-08-17 14:15:39 +02:00
parent d33c436b5b
commit 1ba56d3f05
2 changed files with 7 additions and 8 deletions

View file

@ -354,14 +354,14 @@ void BTD::HCI_event_task() {
case EV_CONNECT_COMPLETE:
if (!hcibuf[2]) { // check if connected OK
hci_handle = hcibuf[3] | hcibuf[4] << 8; //store the handle for the ACL connection
hci_handle = hcibuf[3] | hcibuf[4] << 8; // store the handle for the ACL connection
hci_event_flag |= HCI_FLAG_CONN_COMPLETE; // set connection complete flag
}
break;
case EV_DISCONNECT_COMPLETE:
if (!hcibuf[2]) { // check if disconnected OK
hci_event_flag |= HCI_FLAG_DISCONN_COMPLETE; //set disconnect commend complete flag
hci_event_flag |= HCI_FLAG_DISCONN_COMPLETE; // set disconnect command complete flag
hci_event_flag &= ~HCI_FLAG_CONN_COMPLETE; // clear connection complete flag
}
break;

11
BTD.h
View file

@ -110,7 +110,7 @@
#define WI_PROTOCOL_BT 0x01 // Bluetooth Programming Interface
#define BTD_MAX_ENDPOINTS 4
#define BTD_NUMSERVICES 4 // Max number of Bluetooth devices
#define BTD_NUMSERVICES 4 // Max number of Bluetooth services
class BluetoothService { // All services should include this class
public:
@ -142,18 +142,17 @@ public:
};
/* Register bluetooth dongle members/services */
uint8_t registerServiceClass(BluetoothService *pService) {
int8_t registerServiceClass(BluetoothService *pService) {
for (uint8_t i=0; i<BTD_NUMSERVICES; i++) {
if (!btService[i]) {
btService[i] = pService;
return 0; // Success
return i; // Return ID
}
}
return 1; // ErrorregisterServiceClass
return -1; // ErrorregisterServiceClass
};
void claimConnection() { l2capConnectionClaimed = true; }; // This is used by the service to know when to store the device information
bool l2capConnectionClaimed;
bool l2capConnectionClaimed; // This is used by the service to know when to store the device information
const char* btdName; // These are set by the SPP library
const char* btdPin;