mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 08:37:22 +00:00
fix endless remote name request
This commit is contained in:
parent
477fd550c1
commit
8c9b08f347
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// BTDevice.h
|
// BTDevice.h
|
||||||
// BT-Keyboard
|
|
||||||
//
|
//
|
||||||
// Created by Matthias Ringwald on 3/30/09.
|
// Created by Matthias Ringwald on 3/30/09.
|
||||||
//
|
//
|
||||||
|
@ -42,6 +42,8 @@
|
|||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#define INQUIRY_INTERVAL 3
|
#define INQUIRY_INTERVAL 3
|
||||||
|
|
||||||
|
// #define LASER_KB
|
||||||
|
|
||||||
// fix compare for 3.0
|
// fix compare for 3.0
|
||||||
#ifndef __IPHONE_3_0
|
#ifndef __IPHONE_3_0
|
||||||
#define __IPHONE_3_0 30000
|
#define __IPHONE_3_0 30000
|
||||||
@ -213,41 +215,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
remoteNameIndex++;
|
remoteNameIndex++;
|
||||||
[self getNextRemoteName];
|
[self getNextRemoteName];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_COMMAND_COMPLETE:
|
|
||||||
if (COMMAND_COMPLETE_EVENT(packet, hci_inquiry_cancel)){
|
|
||||||
// inquiry canceled
|
|
||||||
// NSLog(@"Inquiry cancelled successfully");
|
|
||||||
inquiryState = kInquiryInactive;
|
|
||||||
[[self tableView] reloadData];
|
|
||||||
if (notifyDelegateOnInquiryStopped){
|
|
||||||
notifyDelegateOnInquiryStopped = false;
|
|
||||||
if (delegate) {
|
|
||||||
[delegate inquiryStopped];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (COMMAND_COMPLETE_EVENT(packet, hci_remote_name_request_cancel)){
|
|
||||||
// inquiry canceled
|
|
||||||
// NSLog(@"Remote name request cancelled successfully");
|
|
||||||
inquiryState = kInquiryInactive;
|
|
||||||
[[self tableView] reloadData];
|
|
||||||
if (notifyDelegateOnInquiryStopped){
|
|
||||||
notifyDelegateOnInquiryStopped = false;
|
|
||||||
if (delegate) {
|
|
||||||
[delegate inquiryStopped];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HCI_EVENT_INQUIRY_COMPLETE:
|
|
||||||
// reset name check
|
|
||||||
remoteNameIndex = 0;
|
|
||||||
[self getNextRemoteName];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HCI_EVENT_LINK_KEY_NOTIFICATION:
|
case HCI_EVENT_LINK_KEY_NOTIFICATION:
|
||||||
if (deviceInfo) {
|
if (deviceInfo) {
|
||||||
bt_flip_addr(event_addr, &packet[2]);
|
bt_flip_addr(event_addr, &packet[2]);
|
||||||
@ -285,6 +252,42 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case HCI_EVENT_COMMAND_COMPLETE:
|
||||||
|
if (COMMAND_COMPLETE_EVENT(packet, hci_inquiry_cancel)){
|
||||||
|
// inquiry canceled
|
||||||
|
// NSLog(@"Inquiry cancelled successfully");
|
||||||
|
inquiryState = kInquiryInactive;
|
||||||
|
[[self tableView] reloadData];
|
||||||
|
if (notifyDelegateOnInquiryStopped){
|
||||||
|
notifyDelegateOnInquiryStopped = false;
|
||||||
|
if (delegate) {
|
||||||
|
[delegate inquiryStopped];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (COMMAND_COMPLETE_EVENT(packet, hci_remote_name_request_cancel)){
|
||||||
|
// inquiry canceled
|
||||||
|
// NSLog(@"Remote name request cancelled successfully");
|
||||||
|
inquiryState = kInquiryInactive;
|
||||||
|
[[self tableView] reloadData];
|
||||||
|
if (notifyDelegateOnInquiryStopped){
|
||||||
|
notifyDelegateOnInquiryStopped = false;
|
||||||
|
if (delegate) {
|
||||||
|
[delegate inquiryStopped];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HCI_EVENT_INQUIRY_COMPLETE:
|
||||||
|
// reset name check
|
||||||
|
remoteNameIndex = 0;
|
||||||
|
[self getNextRemoteName];
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -328,7 +331,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
|
|
||||||
remoteNameDevice = nil;
|
remoteNameDevice = nil;
|
||||||
|
|
||||||
for (remoteNameIndex = 0; remoteNameIndex < [devices count]; remoteNameIndex++){
|
for ( ; remoteNameIndex < [devices count]; remoteNameIndex++){
|
||||||
BTDevice *dev = [devices objectAtIndex:remoteNameIndex];
|
BTDevice *dev = [devices objectAtIndex:remoteNameIndex];
|
||||||
if (![dev name]){
|
if (![dev name]){
|
||||||
remoteNameDevice = dev;
|
remoteNameDevice = dev;
|
||||||
@ -523,17 +526,41 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
|
|
||||||
// pick an icon for the devices
|
// pick an icon for the devices
|
||||||
if (showIcons) {
|
if (showIcons) {
|
||||||
int major = ([dev classOfDevice] & 0x1f00) >> 8;
|
NSString *imageName = @"bluetooth.png";
|
||||||
if (major == 0x01) {
|
// check major device class
|
||||||
theImage = [UIImage imageNamed:@"computer.png"];
|
switch (([dev classOfDevice] & 0x1f00) >> 8) {
|
||||||
} else if (major == 0x02) {
|
case 0x01:
|
||||||
theImage = [UIImage imageNamed:@"smartphone.png"];
|
imageName = @"computer.png";
|
||||||
} else if ( major == 0x05 && ([dev classOfDevice] & 0xff) == 0x40){
|
break;
|
||||||
theImage = [UIImage imageNamed:@"keyboard.png"];
|
case 0x02:
|
||||||
} else {
|
imageName = @"smartphone.png";
|
||||||
theImage = [UIImage imageNamed:@"bluetooth.png"];
|
#ifdef LASER_KB
|
||||||
|
// Celluon CL800BT has COD 0x400210
|
||||||
|
if ([dev name] && [[dev name] isEqualToString:@"CL800BT"]){
|
||||||
|
imageName = @"keyboard.png";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case 0x05:
|
||||||
|
switch ([dev classOfDevice] & 0xff){
|
||||||
|
case 0x40:
|
||||||
|
imageName = @"keyboard.png";
|
||||||
|
break;
|
||||||
|
case 0x80:
|
||||||
|
imageName = @"mouse.png";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
imageName = @"HID.png";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef LASER_KB
|
||||||
|
// Celluon CL800BT has COD 0x400210
|
||||||
|
if ([dev name] && [[dev name] isEqualToString:@"VKB Keyboard"]){
|
||||||
|
imageName = @"keyboard.png";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
theImage = [UIImage imageNamed:imageName];
|
||||||
}
|
}
|
||||||
|
|
||||||
// set accessory view
|
// set accessory view
|
||||||
|
Loading…
x
Reference in New Issue
Block a user