Skip to content

Instantly share code, notes, and snippets.

View don's full-sized avatar

Don Coleman don

View GitHub Profile
/*********************************************************************
This is an example for our nRF51822 based Bluefruit LE modules
Pick one up today in the adafruit shop!
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
MIT license, check LICENSE for more information
@don
don / Example_4-3.ino
Last active October 16, 2015 17:09
Make:Bluetooth copyedits
void unlockCharacteristicWritten(BLECentral& central,
BLECharacteristic& characteristic) {
// central wrote new value to the unlock characteristic
Serial.println(F("Unlock characteristic written"));
openLock(characteristic.value(), characteristic.valueLength());
}
BluetoothManager manager =
(BluetoothManager) activity.getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter adapter = manager.getAdapter();
// code to add to slides, not a complete implementation
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
if (newState == BluetoothGatt.STATE_CONNECTED) {
this.gatt = gatt;
gatt.discoverServices();
}
}
@don
don / main.js
Last active December 1, 2015 19:21
Bleno with Eddystone beacon
var bleno = require('bleno');
var util = require('util');
var os = require('os');
var eddystone = require('eddystone-beacon');
var BlenoPrimaryService = bleno.PrimaryService;
var BlenoCharacteristic = bleno.Characteristic;
// Characteristic
@don
don / P2P_Send_LongRecord.ino
Created December 9, 2015 04:17
Writing large Peer to Peer NFC messages from Arduino
// Sends a NDEF Message to a Peer
// Requires SPI. Tested with Seeed Studio NFC Shield v2
#include "SPI.h"
#include "PN532_SPI.h"
#include "snep.h"
#include "NdefMessage.h"
#define TEXT_SIZE 226
#define LANGUAGE_ENCODING_SIZE 3
@don
don / BLE_Workshop_Software_Install.md
Last active January 21, 2016 04:09
Software Install instructions for the PhoneGap Day 2016 - Hands on Bluetooth LE Workshop

Hands-on Bluetooth Low Energy

PhoneGap Day - January 28th, 2016

Software Installation

In order to get the most of the class, we're asking everyone to install the software before the workshop.

It's important that you follow this guide and have you computer setup before you arrive. We want to spend time learning about Bluetooth not installing software.

PhoneGap

@don
don / index.js
Created February 17, 2016 16:59
BluetoothSerial counter showing count and raw data
var macAddress = "00:13:EF:00:08:8B";
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
@don
don / sample-arduino-101-notify-random.ino
Last active July 13, 2016 00:40 — forked from dkarchmer/sample-arduino-101-notify-random.ino
Sample Arduino 101 code advertising BLE characteristic with 'BLERead | BLENotify'
//Sample using LiquidCrystal library
//#include <LiquidCrystal.h>
#include <CurieBLE.h>
// select the pins used on the LCD panel
//LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
// Port Arduino BLE button demo to Puck-js
// https://github.com/don/ITP-BluetoothLE/blob/master/arduino/Button_v2/Button_v2.ino
NRF.setServices({
0xFFE0 : {
0xFFE1 : {
value: 0,
readable: true,
notify: true
}