Code Monkey home page Code Monkey logo

pxt-bluetooth-beacons's Introduction

bluetooth-beacons

This PXT package allows the micro:bit to act as iBeacon / AltBeacon advertiser.

Usage

On MakeCode workspace, open the menu item Add Package..., and specify the package id github:kshoji/pxt-bluetooth-beacons.

iBeacon

To advertise BLE iBeacon packets, write code like this.

bluetooth.advertiseIBeacon("E20A39F4-73F5-4BC4-A12F-17D1AD07A961", 1, 2, -56);

Arguments: uuid, majorId, minorId, and txPower.

  • The uuid argument is string style, and it can omit the hyphens.
  • The majorId minorId arguments are numbers from 0 to 65535.
  • The txPower argument is a number (dBm) from -128 to 127.

AltBeacon

To advertise BLE AltBeacon packets, write code like this.

let beaconId = pins.createBuffer(20)
beaconId.setNumber(NumberFormat.Int32BE, 0, 0x01020304)
beaconId.setNumber(NumberFormat.Int32BE, 4, 0x05060708)
beaconId.setNumber(NumberFormat.Int32BE, 8, 0x090A0B0C)
beaconId.setNumber(NumberFormat.Int32BE, 12, 0x0D0E0F10)
beaconId.setNumber(NumberFormat.Int32BE, 16, 0x11121314)

bluetooth.advertiseAltBeacon(0x0059, beaconId, -56)

Arguments: manufacturerId, beaconId, and txPower.

  • The manufacturerId argument is a number from 0 to 65535.
  • The beaconId argument is a buffer with 20 bytes.
  • The txPower argument is a number (dBm) from 0 to -127.

Supported targets

  • for PXT/microbit

(The metadata above is needed for package search.)

License

Source code: MIT

icon.png: Culmstock: Culmstock Beacon cc-by-sa/2.0 - © Martin Bodman - geograph.org.uk/p/213525

bluetooth
bluetooth-beacons=github:kshoji/pxt-bluetooth-beacons

pxt-bluetooth-beacons's People

Contributors

kshoji avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

pxt-bluetooth-beacons's Issues

The hex file is not available, please connect to internet and try again.

I'm using a micro:bit v2 on Mac OS 11.7, the module was working great until randomly this error started appearing.

It occurs every time I download the module service on multiple devices, browsers and Operating Systems, even before I write any code using it.

Tested On:

  • Mac OS with Chrome and Opera
  • Iphone with Safari
  • Beta Editor
  • V1 Editor

Screenshot 2023-02-05 at 20 15 41

Apparently there is an issue with core -> math.ts as it flashes with an error every time I try to download my code. This module is amazing and it would be nice to have this detrimental issue fixed.

If you can't fix it, how else can I broadcast a bluetooth UART beacon with the micro:bit?

compilation error on make code

I'm using micro:bit on Windows10 using Chrome to test some beacon stuff. When I try to compile the following error is thrown
Compilation failed, please check your code for errors

I'm using the following script:

bluetooth.advertiseIBeacon(
"E20A39F473F54BC4A12F17D1AD07A961",
1,
2,
-56
)

Thank you in advance.

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.