GithubHelp home page GithubHelp logo

geoffkerr / pxt-swge-beacon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ruthsarian/pxt-swge-beacon

1.0 0.0 0.0 342 KB

Generate Bluetooth beacons that droids from the depot will react to.

License: MIT License

C++ 65.28% TypeScript 34.18% Makefile 0.53%

pxt-swge-beacon's Introduction

pxt-swge-beacon

alt text

This PXT package allows the micro:bit to generate Bluetooth beacons to which droids from the droid depot will respond.

!! Version Compatibility Issues !!

As of December 2020, this extension does not work with the default MakeCode environment, which has changed since this extension was first created. In order to use this extension you will need to use the Version 1 MakeCode editor at https://makecode.microbit.org/v1.

This extension will also not work with V2 micro:bit. V2 micro:bit uses the CODAL runtime, which does not include the mbed API this extension utilizes.

Reference:

Usage

In MakeCode, open an existing project or create a new project. Click on the gear icon at the top-right and select extensions from the drop-down menu. In the search box enter github:ruthsarian/pxt-swge-beacon, press enter, and select swge-beacon when it comes up. Your project will now include SWGE beacon blocks under the Bluetooth section with some more advanced versions of those blocks under the more subsection.

MakeCode Examples

Video Tutorial

Block Descriptions

SWGE Location Beacon zone

  • zone: Select from a drop-down list the location the beacon should represent.
  • numeric version: there is a version of this block that accepts a numeric value for zone under "bluetooth : more"

SWGE Droid Beacon personality

  • personality: Select from a drop-down list the personality the beacon should represent.
  • usage note: Droids will not react to this type of beacon for up to 2 hours after last encountering a location beacon.
  • numeric version: there is a version of this block that accepts a numeric value for personality under "bluetooth : more"

SWGE Advanced Location Beacon zone, react_interval, rssi

  • zone: Set the location zone for the beacon. Valid values are 1 - 7.
  • react_interval: Controls how long the droid will wait before its next reaction to the same beacon. This value is in seconds, then multiplied by 5. For example, a value of 24 would cause the droid to react every 2 minutes (24 x 5 = 120 seconds or 2 minutes). The minimum reaction time interval is 1 minute. This means any value less than 12 will be treated as 12 (12 x 5 = 60 seconds) by the droid.
  • rssi: The minimum signal strength the droid must receive the beacon before it reacts. Value is in dBm and the default value is -90 which offers maximum distance (tens of feet). A value of around -26 will be a minimum distance of a few inches.
  • note: this block can be found under the bluetooth "more" subsection.

SWGE Generic Beacon mfr_id, beacon_data

  • mfr_id: A 2-byte value (0-65535) that identifies the manufacturer for the beacon. For droid beacons this should be set to 0x0183.
  • beacon_data: The raw beacon data; see tables below for details.
  • input values: input values will be treated as hexadecimal if they begin with 0x otherwise they are treated as an array of bytes.
  • note: this block may be found under "bluetooth : more"

Beacon Format

Droid beacons are typically 6 bytes long. Below is a table that describes the purpose of each byte for droid and location beacons.

Location Beacon

This beacon identifies a location. These beacons are placed throughout the park and droids will react to them as they are encountered.

Example value: 0x0A040102A601

BYTE Description Example Value Notes
01 Beacon Type 0x0A Location Beacon
02 Beacon Data Length 0x04 Value does not include the first two bytes; just the data that comes after
03 Zone 0x01 Valid values are 1 - 7
04 Reaction Interval 0x02 Multiply this value by 5 to get the number of seconds between droid reactions. Any value below 12 (60 seconds) will be treated as 12 (60 seconds) by the droid. A value of 0xFF will cause the droid to react once and then never again until power is cycled or the droid encounters enough other beacons (10) to make it forget it had encountered this beacon.
05 Minimum RSSI in dBm 0xA6 A way to determine how close a droid must be to the beacon before it reacts. 0xA6 (-90 dBm) essentially tells the droid to respond at any signal strength. 0xE6 (-26 dBm) would tell the droid not to react until it is within about 1 foot of the droid.
06 ? unknown ? 0x01 Droids will not react to the beacon is this byte is a value other than 0 or 1.

Droid Beacon

This beacon identifies a location. These beacons are placed throughout the park and droids will react to them as they are encountered.

Example value: 0x030444818201

BYTE Description Example Value Notes
01 Beacon Type 0x03 Droid Beacon
02 Beacon Data Length 0x04 Value does not include the first two bytes; just the data that comes after
03 ? unknown ? 0x44
04 Paired with Remote 0x81 0x01 + (0x80 if the droid is paired with a remote).
05 Affiliation 0x82 0x80 + (Affiliation ID * 2)
06 Personality 0x01 Personality Chip ID; 0x01 for unchipped R-unit, 0x02 for unchipped BB-unit.

Personality Chip and Affiliation IDs

Personality Chip Chip ID Affiliation Affiliation ID
Unchipped R-unit 1 Scoundrel 1
Unchipped BB-unit 2 Scoundrel 1
Blue 3 Resistance 5
Gray 4 Scoundrel 1
Red 5 First Order 9
Orange 6 Resistance 5
Purple 7 Scoundrel 1
Black 8 First Order 9

Supported targets

  • for PXT/microbit (The metadata above is needed for package search.)

pxt-swge-beacon's People

Stargazers

Geoff Kerr 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.