美文网首页
BLE蓝牙4.0相关(iOS)

BLE蓝牙4.0相关(iOS)

作者: 布呐呐u | 来源:发表于2019-08-15 20:31 被阅读0次
1)使用方法
- (void)viewDidLoad {
  [super viewDidLoad];

  //①开始扫描
  [CCAirBLEManager startScan];

  //②扫描到设备后,连接设备

  //③成功连接设备,获取相关信息
  //连接失败,相关处理

  //④获取到服务

  //⑤获取到服务下面的所有特征
  //把指令写入相关特征,

  //⑥写入成功后,获取蓝牙设备返回值

  //⑦解析数据,
  //在需要扫描的地方,调用方法①开启蓝牙扫描;
  //其它的②③④⑤⑥⑦都在单例类CCAirBLEManager中封装好了,
  //需求不一样的地方,自己稍微变动即可!

  //注:我这边是16进制的格式,
  //1)16进制data转string
  //2)16进制string转int
}
2)16进制data转字符串
- (NSString *)hexadecimalString:(NSData *)data{
  NSString *result;
  const unsigned char* dataBuffer = (const unsigned char*)[data bytes];
  if(!dataBuffer){
    return nil;
  }
  NSUInteger dataLength = [data length];
  NSMutableString* hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
  for(int i = 0; i < dataLength; i++){
      [hexString appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)dataBuffer[i]]];
  }
  result = [NSString stringWithString:hexString];
  return result;
}
3)16进制字符串转int
- (int)convertHexStringWith:(NSString *)string
{
  UInt64 mac =  strtoul([string cStringUsingEncoding:NSUTF8StringEncoding], 0, 16);

  return [[NSString stringWithFormat:@"%llu",mac] intValue];
}
4)相关Demo

Demo连接

相关文章

  • CoreBluetooth

    iOS-BLE蓝牙开发持续更新 - 简书 蓝牙打印小票 一个第三方 IOS BLE4.0蓝牙和外设连接和收发数据的...

  • 蓝牙4.0 测试与数据的存储(SQLite)

    在之前的篇章 iOS之蓝牙4.0 BLE相关 中已经讲到了蓝牙的基本工作原理和获取数据,今天的篇章中将着重进行...

  • Android蓝牙4.0 Ble读写数据详解 -1

    Android蓝牙4.0 Ble读写数据详解 -1 Android蓝牙4.0 Ble读写数据详解 -2 因为最近公...

  • iOS蓝牙4.0基础开发

    1.蓝牙开发基础 蓝牙4.0是低电量模式所以也叫4.0BLE。本文将使用iOS系统提供的CoreBluetooth...

  • 蓝牙4.0一对多设备通讯技术文档

    一、蓝牙4.0简介 蓝牙4.0包括传统蓝牙和低功耗蓝牙BLE两部分,其中BLE(Bluetooth Low Ene...

  • Android蓝牙4.0 Ble读写数据详解 -2

    Android蓝牙4.0 Ble读写数据详解 -2 Android蓝牙4.0 Ble读写数据详解 -1 上一篇说了...

  • iOS之蓝牙4.0 BLE相关

    由于最近工作的东家是一家物联网公司,网上BLE相关的资料确实比较少,尤其我还做了一些调试和加密相关的工作.由于调试...

  • ios蓝牙框架CoreBluetooth使用

    相关基础知识介绍 蓝牙常见名称和缩写 BLE:(Bluetooth low energy)蓝牙4.0设备因为低耗电...

  • macOS-BLE蓝牙4.0开发

    macOS-BLE蓝牙4.0开发 !!!中心模式 !!! macOS的BLE程序代码和iOS差不多,只需要修改一些...

  • iOS蓝牙实现汇总

    一、相关介绍 CoreBluetooth专门用于与BLE设备通讯。并且现在很多蓝牙设备都支持4.0,4.0以其低功...

网友评论

      本文标题:BLE蓝牙4.0相关(iOS)

      本文链接:https://www.haomeiwen.com/subject/mlptsctx.html