MPBluetoothKit icon indicating copy to clipboard operation
MPBluetoothKit copied to clipboard

扫描自动停止&Mac地址获取

Open swieer opened this issue 8 years ago • 0 comments

使用的时候发现,开始扫描后,一直没有停止,还需要自己写一个延时停止的方法,建议增加一个扫描方法,可以设定扫描时间。这样更方便使用。仅仅是建议。 还有就是你的博客上的获取Mac地址的方法,在180A的2A23下确实能得到这个值,前提是蓝牙端提供了这个service 的charactrstic的情况下。但是我用swift调用的时候 NSString *value = [NSString stringWithFormat:@"%@",characteristic.value]; 这个value不能转换为string,需要转换成二进制 var hexadecimalString: String { var bytes = [UInt8](repeating: 0, count: count) copyBytes(to: &bytes, count: count)

    let hexString = NSMutableString()
    for byte in bytes {
        hexString.appendFormat("%02x", UInt(byte))
    }
    return NSString(string: hexString) as String
}

有需要的人看看,这也是其它地方看到的。 在OC中没有试。

swieer avatar Nov 07 '16 09:11 swieer