简体   繁体   English

蓝牙外围设备不应答

[英]Bluetooth peripheral doesn't answer

I am in big trouble with my exams. 我考试很麻烦。 I have to write an iOS app that uses an external sensor made by Texas Instruments, it's called TI Sensortag . 我必须编写一个iOS应用程序,该应用程序使用德州仪器( TI)制造的外部传感器,称为TI Sensortag TI's documentation, in my humble opinion, is really poor and complicated to understand for an entry level programmer. 以我的拙见,TI的文档对于入门级程序员来说确实很差,而且理解起来很复杂。 I tried to ask in the E2E forum but they weren't able to help me, their answer was something like "Um, well, we don't know, go away and ask someone else", ... 我试图在E2E论坛上提问,但他们无法帮助我,他们的回答是“嗯,嗯,我们不知道,走开问别人”,...

I added the CoreBluetooth framework to my project an created a CentralManager. 我在我的项目中添加了CoreBluetooth框架并创建了CentralManager。 I am able to find my device, connect and get his name and (sometimes) his RSSI. 我能够找到我的设备,连接并获取他的名字和(有时)他的RSSI。 Now what I'm trying to do is to ask my CBPeripheral object if it has some services for me or something like that. 现在,我要尝试的是询问CBPeripheral对象是否为我提供某些服务或类似的服务。 I've found the Complete Attribute Table but I have no idea how to use it... I know I have to activate some services or something like that but I really don't now ho to do it, I googled a lot but I've not found something helpful... 我已经找到了完整的属性表,但我不知道如何使用它...我知道我必须激活一些服务或类似的东西,但是我现在真的不愿意这样做,我在Google上搜索了很多,但是我找不到有用的东西...

I'm trying to enable my sensor with this method, but I'm doing something wrong. 我正在尝试使用此方法启用传感器,但是我做错了事。

-(void) configureSensorTag
{

    uint8_t myData = 0x01;

    NSData *data = [[NSData alloc] initWithBytes:&myData length:1];

    [BLEUtility writeCharacteristic:myPer sUUID:@"F000AA00-0451-4000-B000-000000000000" cUUID:@"F000AA02-0451-4000-B000-000000000000" data:data];

    [BLEUtility setNotificationForCharacteristic:myPer sUUID:@"F000AA00-0451-4000-B000-000000000000" cUUID:@"F000AA01-0451-4000-B000-000000000000" enable:YES];


    NSLog(@"Configured TI SensorTag IR Termometer Service profile");

}

Moreover I'm trying to retrive Sensortag's services with this method 此外,我正在尝试使用此方法检索Sensortag的服务

[peripheral discoverServices:nil];

and his delegate 和他的代表

- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error
{
    NSLog(@"Found service");
    if (error) {
        NSLog(@"Error: %@", error);
    }

}

but it is never called. 但它从未被调用。

Has someone any idea? 有人知道吗?

Thank you very much! 非常感谢你!

Unfortunately I can't help you with the details of the iOS, but I can help you with understanding the sensor tag. 不幸的是,我无法为您提供iOS的详细信息,但可以帮助您了解传感器标签。 If you look at that attribute PDF you linked you'll find entries marked "GATT_CLIENT_CHAR_CFG_UUID". 如果查看链接的该属性PDF,则会找到标记为“ GATT_CLIENT_CHAR_CFG_UUID”的条目。 It's 16 bits of flags where only the 2 least significant bits are used. 它是16位标志,仅使用2个最低有效位。 It even says in there 'Write "01:00" to enable notifications, "00:00" to disable'. 甚至在其中说“写“ 01:00”以启用通知,写“ 00:00”以禁用通知”。 (That's the least significant bit because it's encoded in little-endian format) (这是最不重要的一点,因为它是以小尾数格式编码的)

So, you're sending a 0x01 to turn on the IR temperature sensor, but you haven't turned on the notifications. 因此,您要发送0x01来打开红外温度传感器,但是您尚未打开通知。 Turning it on will then cause the device to stream notifications back to the client. 然后将其打开将使设备将通知流回客户端。 The accelerometer doesn't require turning on, so maybe you should try that first. 加速计不需要打开,所以也许您应该先尝试一下。

I have no idea what that second chunk of code is supposed to be doing... sorry. 我不知道第二段代码应该做什么……抱歉。

Ok ok I got it, there were any software problem, I mean, not by iOS side. 好吧,好吧,我明白了,这是软件问题,不是iOS方面的问题。 Sensortag has a wrong firmware and so it did'n work. Sensortag的固件错误,因此无法正常工作。

I've changed Sensortag and now everything works fine. 我更改了Sensortag,现在一切正常。

Thank you anyway! 还是要谢谢你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM