gpt4 book ai didi

ios - CoreBluetooth 读/写数据

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:36:30 25 4
gpt4 key购买 nike

我正在使用 iOS Central 与 BLE 外围设备进行通信。

使用LG蓝牙框架https://github.com/DavidSahakyan/LGBluetooth

方法获取

        [LGUtils readDataFromCharactUUID:aCharactId                              seriveUUID:aServiceId                              peripheral:peripheral                              completion:^(NSData *data, NSError *error) {                                  NSLog(@"Data : %s Error : %@", (char *)[data bytes], error);                              }];

它输出“1234567890”

我需要将 (char *) [data bytes] 转换为 NSInteger。当我得到它时

         NSInteger dataInt = [data bytes];

我得到2013527536,但外围端的值为1234567890

最佳答案

尝试做这样的事情:

NSInteger dataInt = atoi((const char*)[data bytes]);

关于ios - CoreBluetooth 读/写数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21795174/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com