我試圖在應用程序處於後臺時連接到cB-OLP425 ble設備。我已經盡我所能在網絡上做到了。我使用IAR embededWorkbench將連接藍色的cb.demo.c中的廣告時間間隔設置爲20ms。在背景中連接到cB-OLP425 iphone應用程序
void gapSetAlwaysAdvertising(void)
{
uint8 advertising_enable = TRUE;
uint16 desired_min_advertising_interval = 20; **//I'M ASSUMING THIS IS 20ms changed it from 1600**
int16 desired_max_advertising_interval = 2500;
uint8 advertData[] = 0x02, //length of first data structure (2 bytes excluding length byte)
**//I'm thinking I need to change this to 0x05 which is 30 sec. am I correct**
GAP_ADTYPE_FLAGS, //AD Type = Flags
GAP_ADTYPE_FLAGS_GENERAL | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED
};
我已經做了,以便它通過重命名它的本地名字,然後只允許連接到連接名稱只給一個特定的模塊。
帶我看,這可能是一個問題,在此背景下,可以離開?
我使用此代碼查找模塊
- (id)init
{
if ((self = [super init]))
{
self.characteristicsCBUUID = [NSMutableDictionary new];
self.myPeripherals = [NSMutableArray new];
manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
return self;
}
- (void)startScan
{
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
[manager scanForPeripheralsWithServices:self.myPeripherals options:options];
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
NSLog(@"Did discover peripheral. peripheral: %@ rssi: %@, UUID: %@ advertisementData: %@ ", peripheral, RSSI, peripheral.UUID, advertisementData);
NSDictionary *dataDict = [NSDictionary dictionaryWithObject:@"Specialname" forKey:@"kCBAdvDataLocalName" ];
if(![self.myPeripherals containsObject:peripheral])
[self.myPeripherals addObject:peripheral];
if ([advertisementData isEqualToDictionary:dataDict]) {
[manager retrievePeripherals:[NSArray arrayWithObject:(id) peripheral.UUID]];
}
}
我已經加入了正確的信息到應用程序的plist用於在背景模式下的功能性。 不是音頻,因爲我聽說蘋果公司不會批准這個,如果它只是被添加到保持應用程序去睡覺。
有沒有人有任何建議或看到我需要改變/添加任何東西。我開始感到沮喪。
感謝您的任何和所有幫助
對不起,我花了這麼長時間來回應,但我正處在另一個項目的中間。你能告訴我在哪裏以及如何做這個定製配對而不用本地名字 – user1114881