GithubHelp home page GithubHelp logo

huaruodie / whbledemo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from remember17/whbledemo

0.0 1.0 0.0 27 KB

📱iOS蓝牙中心设备和外设开发,包含OC和Swift版本

License: MIT License

Objective-C 56.53% Swift 43.47%

whbledemo's Introduction

WHBLEDemo (OC & Swift)

CoreBluetooth central and peripheral demo with OC/Swift

(iOS蓝牙中心设备和外设开发,本例中包含Swift版本)

iOS蓝牙开发基础请到这里查阅:iOS蓝牙开发介绍

目的

最近公司在做一个iOS蓝牙项目,在开发的过程中简单整理了一些与之相关的基础知识,在这里分享一下。整理包括以下内容:

1、iOS蓝牙开发的关键词 2、蓝牙的简单介绍 3、CoreBluetooth框架 4、实现iOS蓝牙外设(Demo) 5、实现iOS蓝牙中心设备(Demo)

Demo的运行gif图如下,中心设备可以从外设读取数据,也可以向外设写入数据。外设也可以向中心设备发送数据。 PS:需要使用真机测试。

蓝牙外设与中心设备之间的数据传输

iOS的蓝牙开发是围绕着CoreBluetooth框架来实现的。 下面先从iOS蓝牙开发的基本概念说起。

一、iOS蓝牙开发的关键词

中心设备:就是用来扫描周围蓝牙硬件的设备,比如通过你手机的蓝牙来扫描并连接智能手环,这时候你的手机就是中心设备。

外设:被扫描的设备。比如当你用手机的蓝牙扫描连接智能手环的时候,智能手环就是外设。

中心设备和外设

广播:就是外设不停的散播蓝牙信号,让中心设备可以扫描到。

外设广播

服务(services):外设广播和运行的时候会有服务,可以理解成一个功能模块,中心设备可以读取服务。外设可以有多个服务。

特征(characteristic):在服务中的一个单位,一个服务可以有多个特征,特征会有一个value,一般读写的数据就是这个value。

服务和特征.png

UUID:区分不同的服务和特征,可以理解为服务和特征的身份证。我们可以用UUID来挑选需要的服务和特征。

CoreBluetooth框架 实现iOS蓝牙外设 实现iOS蓝牙中心设备

whbledemo's People

Contributors

remember17 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.