Skip to content

Instantly share code, notes, and snippets.

@theladyjaye
Last active February 1, 2017 23:20
Show Gist options
  • Save theladyjaye/bd8534ab589425cfc1e14b014f6063b6 to your computer and use it in GitHub Desktop.
Save theladyjaye/bd8534ab589425cfc1e14b014f6063b6 to your computer and use it in GitHub Desktop.
Adafruit Bluefruit LE SPI Friend - Make an Eddystone Beacon
// GATT Member codes (16 bits / 2 Bytes)
// https://www.bluetooth.com/specifications/assigned-numbers/16-bit-uuids-for-members
//
// Note that the relevant google registry entry is:
// 65194 0xFEAA Google 12-Mar-2015
// Eddystone Service UUID of 0xFEAA (see docs here: https://github.com/google/eddystone/blob/master/protocol-specification.md#common-elements)
//
// GAP Codes
// https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile
//
// 0x01: Flags
// 0x16: Service Data (16 bit UUID for the data type must follow)
// 0x03: Complete List of 16-bit Service Class UUIDs
//
// https://github.com/google/eddystone/blob/master/protocol-specification.md#common-elements
// https://github.com/google/eddystone/tree/master/eddystone-uid#frame-specification
//
// Advertising Data:
// 02-01-06-03-03-AA-FE-17-16-AA-FE-00-EE-8B-0C-A7-50-09-54-77-CB-3E-77-01-00-00-00-00-00-00-00
//
// Let's break down what this payload means:
//
// Flags:
// 02-01-06
//
// GATT Service ID:
// 03-03-AA-FE
//
// Service Data:
// 17-16-AA-FE-00-EE-8B-0C-A7-50-09-54-77-CB-3E-77-01-00-00-00-00-00-00-00
//
// Flags:
// 02-01-06
// 0x02 (2 bytes) - Flag (0x01) - 0x06
//
// 0x06 (0b00000110) is the Flag value, and asserts the following fields (see Core Specification 4.0, Volume 3, Part C, 18.1):
// - LE General Discoverable Mode (i.e. anyone can discover this device)
// - BR/EDR Not Supported (i.e. this is a Bluetooth Low Energy only device)
//
// GATT Service ID:
// 03-03-AA-FE
//
// 0x03 (3 bytes) - 0x03
// (this values means we are listing the "Complete List of 16-bit Service Class UUIDs" See GAP code above)
// 0xAA - 0xFE
// note the 2 bytes are inverted here (0xFEAA)
//
// Service Data:
// 17-16-AA-FE-00-EE-8B-0C-A7-50-09-54-77-CB-3E-77-01-00-00-00-00-00-00-00
//
// 0x17 (23) bytes long, 0x16 (GAP Code for 16 bit / 2 byte Data Type which is AA-FE, again inverted)
// 17-16-AA-FE
//
// 0x00 : Frame type (Eddystone-UID) (See:https://github.com/google/eddystone/tree/master/eddystone-uid#frame-specification)
//
// 0xEE : Ranging Data - Calibrated Tx power at 0 m (See: https://github.com/google/eddystone/tree/master/eddystone-uid#tx-power)
//
// 8B-0C-A7-50-09-54-77-CB-3E-77 : 10 Byte Namespace [NOT INVERTED] (can be anyting you want, see: https://github.com/google/eddystone/tree/master/eddystone-uid#uid-construction)
//
// 01-00-00-00-00-00: 6 Byte Instance ID [NOT INVERTED] (can be anything you want, see: https://github.com/google/eddystone/tree/master/eddystone-uid#instance-id)
//
// 00-00: 2 Reserved Bytes for RFU data, see offset 18 and 19: https://github.com/google/eddystone/tree/master/eddystone-uid#frame-specification
//
// Put all this together and set the Advertising data on the Bluefruit LE Device:
ble.println("AT+GAPSETADVDATA=02-01-06-03-03-AA-FE-17-16-AA-FE-00-EE-8B-0C-A7-50-09-54-77-CB-3E-77-01-00-00-00-00-00-00-00");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment