{"id":1235,"url":"https://github.com/Instrument/Vicinity","last_synced_at":"2025-07-30T20:32:58.236Z","repository":{"id":12592855,"uuid":"15263703","full_name":"Instrument/Vicinity","owner":"Instrument","description":"Replicates detecting and broadcasting iBeacons in the background ","archived":true,"fork":false,"pushed_at":"2016-08-22T09:07:20.000Z","size":477,"stargazers_count":376,"open_issues_count":12,"forks_count":64,"subscribers_count":58,"default_branch":"master","last_synced_at":"2024-08-14T14:06:28.297Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Instrument.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-17T19:23:05.000Z","updated_at":"2024-02-12T07:50:28.000Z","dependencies_parsed_at":"2022-08-28T11:31:17.919Z","dependency_job_id":null,"html_url":"https://github.com/Instrument/Vicinity","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Instrument%2FVicinity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Instrument%2FVicinity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Instrument%2FVicinity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Instrument%2FVicinity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Instrument","download_url":"https://codeload.github.com/Instrument/Vicinity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187604,"owners_count":17882335,"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","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":[],"created_at":"2024-01-05T20:15:41.883Z","updated_at":"2024-12-04T20:31:09.586Z","avatar_url":"https://github.com/Instrument.png","language":"Objective-C","funding_links":[],"categories":["Hardware","Objective-C"],"sub_categories":["iBeacon","Other free courses"],"readme":"# Vicinity\n\nVicinity replicates iBeacons and supports broadcasting and detecting low-energy bluetooth devices in the background.\n\nIt is built with CoreBluetooth framework and doesn't use CoreLocation to implement iBeacons.  CoreLocation itself limits how it can be used when apps are in the background, whereas CoreBluetooth fully supports background operations.\n\n## What is iBeacon\n\nThe term iBeacon describes the ability of low-engergy bluetooth devices to broadcast and detect proximity of devices by analyzing the received signal strength of the wireless bluetooth signal.  \n\nIn the iOS SDK iBeacons are implemented in the CoreLocation framework—which places many limits on how it can be used in the background.\n\nThe CoreBluetooth framework itself supports RSSI (received signal strength indication), which is all that it is needed to replicate the iBeacon sections of CoreLocation.\n\nThe problem with using CoreLocation to detect iBeacons is this functionality is very limited once an app is in the background.  CoreBluetooth has much greater background support of iOS apps.  With CoreBluetooth, you can broadcast as a peripheral and detect as a central while in the background.  The framework will even allow limited actions within your app code while these services are running.\n\n## INBeaconService\n\nThe heart of this is `INBeaconService`.  This replicates how iBeacons work by analyzing RSSI of low-energy bluetooth broadcasts.  Most of the work is done using `CBPeripheralManager` and `CBCentralManager`, which are classes in the CoreBluetooth framework.\n\nGetting this to work effectively required a two things:\n\n1. interpreting the RSSI values reliably, taking into account sensor noise and signal spikes\n1. converting the RSSI values to distances\n\n## Signal Noise\n\nWhen Reading data from sensors on iOS, be that accelerometer or RSSI, the values can contain a lot of noise and spikes.  I initially tried to use a weighted average which didn't work that well.  Applying an \"easing function\" to smooth out the incoming signal values worked much better.\n\n## RSSI to Distance\n\nConverting the RSSI values to distances was a matter of trial and error.  I also cheated by realizing that iBeacons uses fuzzy distance terms like \"Far\", \"Near\", and \"Immediate\".  The reason for these values became obvious once we analyzed the actual data.  Bluetooth RSSI flucuates wildly at ranges beyond five feet and becomes more accurate at values less than 1 foot.\n\nSupposedly, different bluetooth devices are going to have varying signal strengths, but the smattering of iOS devices we measured reported the same values.\n\n\n## Conclusion\n\nWe hope this simple app will come in useful.\n\nContact us with questions!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInstrument%2FVicinity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FInstrument%2FVicinity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInstrument%2FVicinity/lists"}