{"id":18880782,"url":"https://github.com/keenteam1990/whbledemo","last_synced_at":"2025-08-17T08:07:08.493Z","repository":{"id":107585974,"uuid":"124253082","full_name":"KeenTeam1990/WHBLEDemo","owner":"KeenTeam1990","description":"🐝🐝iOS蓝牙中心设备和外设开发","archived":false,"fork":false,"pushed_at":"2018-03-07T15:11:39.000Z","size":16,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T04:09:21.334Z","etag":null,"topics":["corebluetooth","objective-c"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KeenTeam1990.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-07T15:08:17.000Z","updated_at":"2025-02-18T13:43:09.000Z","dependencies_parsed_at":"2023-09-13T17:36:11.072Z","dependency_job_id":null,"html_url":"https://github.com/KeenTeam1990/WHBLEDemo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/KeenTeam1990/WHBLEDemo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenTeam1990%2FWHBLEDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenTeam1990%2FWHBLEDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenTeam1990%2FWHBLEDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenTeam1990%2FWHBLEDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KeenTeam1990","download_url":"https://codeload.github.com/KeenTeam1990/WHBLEDemo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenTeam1990%2FWHBLEDemo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270820793,"owners_count":24651534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["corebluetooth","objective-c"],"created_at":"2024-11-08T06:45:57.957Z","updated_at":"2025-08-17T08:07:08.466Z","avatar_url":"https://github.com/KeenTeam1990.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WHBLEDemo  （OC ）\nCoreBluetooth central and peripheral demo with OC\n\n(iOS蓝牙中心设备和外设开发)\n\niOS蓝牙开发基础请到这里查阅：**[iOS蓝牙开发介绍](https://remember17.github.io/2017/07/18/iOS%E8%93%9D%E7%89%99%E5%BC%80%E5%8F%91%EF%BC%8C%E4%B8%AD%E5%BF%83%E8%AE%BE%E5%A4%87%E5%92%8C%E5%A4%96%E8%AE%BE%E7%9A%84%E5%AE%9E%E7%8E%B0%EF%BC%8C%E6%9C%89Demo/)**\n\n## 目的\n\n最近公司在做一个iOS蓝牙项目，在开发的过程中简单整理了一些与之相关的基础知识，在这里分享一下。整理包括以下内容：\n\n\u003e1、iOS蓝牙开发的关键词\n2、蓝牙的简单介绍\n3、CoreBluetooth框架\n4、实现iOS蓝牙外设（Demo）\n5、实现iOS蓝牙中心设备（Demo）\n\nDemo的运行gif图如下，中心设备可以从外设读取数据，也可以向外设写入数据。外设也可以向中心设备发送数据。\nPS：需要使用真机测试。\n\n![蓝牙外设与中心设备之间的数据传输](http://upload-images.jianshu.io/upload_images/3873004-534bd304c4e797e6.gif?imageMogr2/auto-orient/strip)\n\n\niOS的蓝牙开发是围绕着CoreBluetooth框架来实现的。\n下面先从iOS蓝牙开发的基本概念说起。\n\n## 一、iOS蓝牙开发的关键词\n\n\u003e 中心设备：就是用来扫描周围蓝牙硬件的设备，比如通过你手机的蓝牙来扫描并连接智能手环，这时候你的手机就是中心设备。\n\n\u003e 外设：被扫描的设备。比如当你用手机的蓝牙扫描连接智能手环的时候，智能手环就是外设。\n\n![中心设备和外设](http://upload-images.jianshu.io/upload_images/3873004-a71ce7964e84a2ce.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)\n\n\u003e 广播：就是外设不停的散播蓝牙信号，让中心设备可以扫描到。\n\n![外设广播](http://upload-images.jianshu.io/upload_images/3873004-7ea93e545a2a4ec2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)\n\n\u003e 服务（services）：外设广播和运行的时候会有服务，可以理解成一个功能模块，中心设备可以读取服务。外设可以有多个服务。\n\n\u003e 特征（characteristic）：在服务中的一个单位，一个服务可以有多个特征，特征会有一个value，一般读写的数据就是这个value。\n\n![服务和特征.png](http://upload-images.jianshu.io/upload_images/3873004-444f173afd4f1e86.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)\n\n\n\u003e UUID：区分不同的服务和特征，可以理解为服务和特征的身份证。我们可以用UUID来挑选需要的服务和特征。\n\n**[CoreBluetooth框架 实现iOS蓝牙外设 实现iOS蓝牙中心设备](http://www.jianshu.com/p/38a4c6451d93)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenteam1990%2Fwhbledemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeenteam1990%2Fwhbledemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenteam1990%2Fwhbledemo/lists"}