{"id":16154928,"url":"https://github.com/rroemhild/ubeacon","last_synced_at":"2026-03-10T00:33:20.366Z","repository":{"id":46330636,"uuid":"515333716","full_name":"rroemhild/ubeacon","owner":"rroemhild","description":"MicroPython library for encode and decode BLE beacons","archived":false,"fork":false,"pushed_at":"2025-07-01T19:41:02.000Z","size":121,"stargazers_count":19,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T18:38:49.968Z","etag":null,"topics":["altbeacon","beacons","ble","bluetooth","eddystone","ibeacon","lintech","micropython","mikrotik","ruuvitag"],"latest_commit_sha":null,"homepage":"","language":"Python","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/rroemhild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2022-07-18T20:36:22.000Z","updated_at":"2025-08-19T15:16:48.000Z","dependencies_parsed_at":"2023-01-19T15:25:20.179Z","dependency_job_id":"fb613f53-7797-424f-8ca8-1efaa8c30a17","html_url":"https://github.com/rroemhild/ubeacon","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/rroemhild/ubeacon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rroemhild%2Fubeacon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rroemhild%2Fubeacon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rroemhild%2Fubeacon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rroemhild%2Fubeacon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rroemhild","download_url":"https://codeload.github.com/rroemhild/ubeacon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rroemhild%2Fubeacon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30318468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["altbeacon","beacons","ble","bluetooth","eddystone","ibeacon","lintech","micropython","mikrotik","ruuvitag"],"created_at":"2024-10-10T01:19:17.035Z","updated_at":"2026-03-10T00:33:20.333Z","avatar_url":"https://github.com/rroemhild.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uBeacon\n\n__uBeacon__ is a simple Bluetooth Low Energy (BLE) beacon library for MicroPython. It can be used to create beacons for BLE advertisement or to decode advertised beacons. It does not handle the advertisement or scanning part directly, as different MicroPython forks handle Bluetooth in various ways.\n\nSupported BLE beacons:\n\n* AltBeacon\n* Eddystone-UID\n* Eddystone-URL\n* iBeacon\n* LinTech\n* MikroTik (decode only)\n* RuuviTag (decode only)\n* SG Wireless CAP/T (decode only)\n\n\n## Installation\n\n### Install with mip\n\nYou can install __uBeacon__ with mip using the following command:\n\n```\nmpremote mip install github:rroemhild/ubeacon\n```\n\n### Copy files\n\nYou can also manually copy the files from the `ubeacon` directory to your MicroPython device. You may exclude the beacon types that are not required for your project, ensure to keep the *\\_\\_init\\_\\_.py* file as it is mandatory.\n\n```sh\nmpremote mkdir lib/ubeacon\nmpremote cp ubeacon/* :lib/ubeacon\n```\n\n## Usage\n\nThe __uBeacon__ library provides several examples in the `examples` directory, where you can find examples on how to advertise a beacon and decode beacons scanned by your device.\n\n### Advertise Beacon\n\nTo advertise a beacon, you first need to create a beacon object using one of the provided classes. For example, to create an iBeacon object:\n\n```python\nfrom ubeacon.ibeacon import IBeacon\n\nbeacon = IBeacon(\n    uuid=\"acbdf5ff-d272-45f5-8e45-01672fe51c47\",\n    major=42,\n    minor=21,\n)\n```\n\nOnce you have created a beacon object, you can start advertising it using i.e. the `bluetooth.BLE` module:\n\n```python\nimport bluetooth\n\nble = bluetooth.BLE()\nble.active(True)\nble.gap_advertise(250_000, adv_data=beacon.adv_data, resp_data=beacon.resp_bytes, connectable=False)\n```\n\n### Decode Beacon\n\nTo decode a beacon, start by extracting the payload data from a scan result. For most beacon types supported by this library (with the exception of the Eddystone class), you need to pass the manufacturer data to the corresponding beacon class. In MicroPython, you can retrieve this data using `result.manufacturer()`.\n\n#### Async Scan Example\n\nFor a complete example that demonstrates asynchronous scanning, see `examples/sync_async.py`.\n\n```python\nimport aioble\nimport asyncio\n\nasync def scan():\n    async with aioble.scan(10000, interval_us=30000, window_us=30000, active=False) as scanner:\n        async for result in scanner:\n            for mfg_id, mfg_data in result.manufacturer():\n                print(f\"MAC:{result.device.addr_hex()} MFG_ID:{mfg_id} MFG_DATA:{mfg_data}\")\n\nasyncio.run(scan())\n```\n\n#### Decode Example: AltBeacon\n\nThe following example shows how to decode an AltBeacon by passing the extracted mfg_data to the AltBeacon class:\n\n```python\nfrom ubeacon.altbeacon import AltBeacon\n\npayload_data = b'\\xbe\\xac=\\xf9=Z\\xa1\\xf2G\\xbb\\xa3\\xcf\u003eI\\xe6\\xa8\\x9b\\xb6\\x00\\x11\\x00*\\xbb#'  # Example mfg_data from ADV\nbeacon = AltBeacon(data=payload_data)\nprint(f\"{beacon,!r}\")\n```\n\n### Filter Beacon\n\nThe __uBeacon__ library provides a `BeaconFilter` class that allows you to filter beacons based on their UUID, Major, and Minor. For example:\n\n```python\nfrom ubeacon import BeaconFilter\n\n# Initialize the filter object to filter by uuid and major\nbeacon_filter = BeaconFilter(\n    uuid=\"7dc04cb6-ed25-420a-ae02-f31674a1f946\",\n    major=1337,\n)\n\nif not beacon_filter.match(beacon):\n    print(\"Beacon does not match filter.\")\n```\n\n## Beacon Naming\n\nThe beacon name is included in the response data.\n\nTo ensure compatibility with different MicroPython forks, __uBeacon__ utilizes `micropython.unique_id` to obtain a unique ID based on the Wi-Fi MAC address. To change the beacon name, it can be set after instantiation. For example, to use the last 2 bytes from the Bluetooth MAC address:\n\n```python\nimport bluetooth\nfrom ubeacon.eddystone import EddystoneUID\n\nNAMESPACE = \"85b9ae954b59c3d6f69d\"\nINSTANCE = \"000000001337\"\n\nble = bluetooth.BLE()\n\nbeacon = EddystoneUID(NAMESPACE, INSTANCE)\nbeacon.name = b\"ubeacon \" + hexlify(ble.config(\"mac\")[1][4:]).upper()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frroemhild%2Fubeacon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frroemhild%2Fubeacon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frroemhild%2Fubeacon/lists"}