├── .gitignore ├── README.md ├── arduino ├── Button │ └── Button.ino ├── Button_bb.png ├── LED │ └── LED.ino ├── LED_bb.png ├── README.md ├── Thermometer │ └── Thermometer.ino └── Thermometer_bb.png ├── button ├── .editorconfig ├── .gitignore ├── README.md ├── config.xml ├── ionic.config.json ├── package.json ├── resources │ ├── android │ │ ├── icon │ │ │ ├── drawable-hdpi-icon.png │ │ │ ├── drawable-ldpi-icon.png │ │ │ ├── drawable-mdpi-icon.png │ │ │ ├── drawable-xhdpi-icon.png │ │ │ ├── drawable-xxhdpi-icon.png │ │ │ └── drawable-xxxhdpi-icon.png │ │ └── splash │ │ │ ├── drawable-land-hdpi-screen.png │ │ │ ├── drawable-land-ldpi-screen.png │ │ │ ├── drawable-land-mdpi-screen.png │ │ │ ├── drawable-land-xhdpi-screen.png │ │ │ ├── drawable-land-xxhdpi-screen.png │ │ │ ├── drawable-land-xxxhdpi-screen.png │ │ │ ├── drawable-port-hdpi-screen.png │ │ │ ├── drawable-port-ldpi-screen.png │ │ │ ├── drawable-port-mdpi-screen.png │ │ │ ├── drawable-port-xhdpi-screen.png │ │ │ ├── drawable-port-xxhdpi-screen.png │ │ │ └── drawable-port-xxxhdpi-screen.png │ ├── icon.png │ ├── ios │ │ ├── icon │ │ │ ├── icon-40.png │ │ │ ├── icon-40@2x.png │ │ │ ├── icon-40@3x.png │ │ │ ├── icon-50.png │ │ │ ├── icon-50@2x.png │ │ │ ├── icon-60.png │ │ │ ├── icon-60@2x.png │ │ │ ├── icon-60@3x.png │ │ │ ├── icon-72.png │ │ │ ├── icon-72@2x.png │ │ │ ├── icon-76.png │ │ │ ├── icon-76@2x.png │ │ │ ├── icon-83.5@2x.png │ │ │ ├── icon-small.png │ │ │ ├── icon-small@2x.png │ │ │ ├── icon-small@3x.png │ │ │ ├── icon.png │ │ │ └── icon@2x.png │ │ └── splash │ │ │ ├── Default-568h@2x~iphone.png │ │ │ ├── Default-667h.png │ │ │ ├── Default-736h.png │ │ │ ├── Default-Landscape-736h.png │ │ │ ├── Default-Landscape@2x~ipad.png │ │ │ ├── Default-Landscape@~ipadpro.png │ │ │ ├── Default-Landscape~ipad.png │ │ │ ├── Default-Portrait@2x~ipad.png │ │ │ ├── Default-Portrait@~ipadpro.png │ │ │ ├── Default-Portrait~ipad.png │ │ │ ├── Default@2x~iphone.png │ │ │ └── Default~iphone.png │ └── splash.png ├── src │ ├── app │ │ ├── app.component.ts │ │ ├── app.html │ │ ├── app.module.ts │ │ ├── app.scss │ │ └── main.ts │ ├── assets │ │ └── icon │ │ │ └── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── pages │ │ ├── detail │ │ │ ├── detail.html │ │ │ ├── detail.scss │ │ │ └── detail.ts │ │ └── home │ │ │ ├── home.html │ │ │ ├── home.scss │ │ │ └── home.ts │ ├── pipes │ │ └── button-state-description │ │ │ └── button-state-description.ts │ ├── service-worker.js │ └── theme │ │ └── variables.scss ├── tsconfig.json └── tslint.json ├── connect ├── .editorconfig ├── .gitignore ├── README.md ├── config.xml ├── ionic.config.json ├── package.json ├── resources │ ├── android │ │ ├── icon │ │ │ ├── drawable-hdpi-icon.png │ │ │ ├── drawable-ldpi-icon.png │ │ │ ├── drawable-mdpi-icon.png │ │ │ ├── drawable-xhdpi-icon.png │ │ │ ├── drawable-xxhdpi-icon.png │ │ │ └── drawable-xxxhdpi-icon.png │ │ └── splash │ │ │ ├── drawable-land-hdpi-screen.png │ │ │ ├── drawable-land-ldpi-screen.png │ │ │ ├── drawable-land-mdpi-screen.png │ │ │ ├── drawable-land-xhdpi-screen.png │ │ │ ├── drawable-land-xxhdpi-screen.png │ │ │ ├── drawable-land-xxxhdpi-screen.png │ │ │ ├── drawable-port-hdpi-screen.png │ │ │ ├── drawable-port-ldpi-screen.png │ │ │ ├── drawable-port-mdpi-screen.png │ │ │ ├── drawable-port-xhdpi-screen.png │ │ │ ├── drawable-port-xxhdpi-screen.png │ │ │ └── drawable-port-xxxhdpi-screen.png │ ├── icon.png │ ├── ios │ │ ├── icon │ │ │ ├── icon-40.png │ │ │ ├── icon-40@2x.png │ │ │ ├── icon-40@3x.png │ │ │ ├── icon-50.png │ │ │ ├── icon-50@2x.png │ │ │ ├── icon-60.png │ │ │ ├── icon-60@2x.png │ │ │ ├── icon-60@3x.png │ │ │ ├── icon-72.png │ │ │ ├── icon-72@2x.png │ │ │ ├── icon-76.png │ │ │ ├── icon-76@2x.png │ │ │ ├── icon-83.5@2x.png │ │ │ ├── icon-small.png │ │ │ ├── icon-small@2x.png │ │ │ ├── icon-small@3x.png │ │ │ ├── icon.png │ │ │ └── icon@2x.png │ │ └── splash │ │ │ ├── Default-568h@2x~iphone.png │ │ │ ├── Default-667h.png │ │ │ ├── Default-736h.png │ │ │ ├── Default-Landscape-736h.png │ │ │ ├── Default-Landscape@2x~ipad.png │ │ │ ├── Default-Landscape@~ipadpro.png │ │ │ ├── Default-Landscape~ipad.png │ │ │ ├── Default-Portrait@2x~ipad.png │ │ │ ├── Default-Portrait@~ipadpro.png │ │ │ ├── Default-Portrait~ipad.png │ │ │ ├── Default@2x~iphone.png │ │ │ └── Default~iphone.png │ └── splash.png ├── src │ ├── app │ │ ├── app.component.ts │ │ ├── app.html │ │ ├── app.module.ts │ │ ├── app.scss │ │ └── main.ts │ ├── assets │ │ └── icon │ │ │ └── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── pages │ │ ├── detail │ │ │ ├── detail.html │ │ │ ├── detail.scss │ │ │ └── detail.ts │ │ └── home │ │ │ ├── home.html │ │ │ ├── home.scss │ │ │ └── home.ts │ ├── service-worker.js │ └── theme │ │ └── variables.scss ├── tsconfig.json └── tslint.json ├── light ├── .editorconfig ├── .gitignore ├── README.md ├── config.xml ├── ionic.config.json ├── package.json ├── resources │ ├── android │ │ ├── icon │ │ │ ├── drawable-hdpi-icon.png │ │ │ ├── drawable-ldpi-icon.png │ │ │ ├── drawable-mdpi-icon.png │ │ │ ├── drawable-xhdpi-icon.png │ │ │ ├── drawable-xxhdpi-icon.png │ │ │ └── drawable-xxxhdpi-icon.png │ │ └── splash │ │ │ ├── drawable-land-hdpi-screen.png │ │ │ ├── drawable-land-ldpi-screen.png │ │ │ ├── drawable-land-mdpi-screen.png │ │ │ ├── drawable-land-xhdpi-screen.png │ │ │ ├── drawable-land-xxhdpi-screen.png │ │ │ ├── drawable-land-xxxhdpi-screen.png │ │ │ ├── drawable-port-hdpi-screen.png │ │ │ ├── drawable-port-ldpi-screen.png │ │ │ ├── drawable-port-mdpi-screen.png │ │ │ ├── drawable-port-xhdpi-screen.png │ │ │ ├── drawable-port-xxhdpi-screen.png │ │ │ └── drawable-port-xxxhdpi-screen.png │ ├── icon.png │ ├── ios │ │ ├── icon │ │ │ ├── icon-40.png │ │ │ ├── icon-40@2x.png │ │ │ ├── icon-40@3x.png │ │ │ ├── icon-50.png │ │ │ ├── icon-50@2x.png │ │ │ ├── icon-60.png │ │ │ ├── icon-60@2x.png │ │ │ ├── icon-60@3x.png │ │ │ ├── icon-72.png │ │ │ ├── icon-72@2x.png │ │ │ ├── icon-76.png │ │ │ ├── icon-76@2x.png │ │ │ ├── icon-83.5@2x.png │ │ │ ├── icon-small.png │ │ │ ├── icon-small@2x.png │ │ │ ├── icon-small@3x.png │ │ │ ├── icon.png │ │ │ └── icon@2x.png │ │ └── splash │ │ │ ├── Default-568h@2x~iphone.png │ │ │ ├── Default-667h.png │ │ │ ├── Default-736h.png │ │ │ ├── Default-Landscape-736h.png │ │ │ ├── Default-Landscape@2x~ipad.png │ │ │ ├── Default-Landscape@~ipadpro.png │ │ │ ├── Default-Landscape~ipad.png │ │ │ ├── Default-Portrait@2x~ipad.png │ │ │ ├── Default-Portrait@~ipadpro.png │ │ │ ├── Default-Portrait~ipad.png │ │ │ ├── Default@2x~iphone.png │ │ │ └── Default~iphone.png │ └── splash.png ├── src │ ├── app │ │ ├── app.component.ts │ │ ├── app.html │ │ ├── app.module.ts │ │ ├── app.scss │ │ └── main.ts │ ├── assets │ │ └── icon │ │ │ └── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── pages │ │ ├── detail │ │ │ ├── detail.html │ │ │ ├── detail.scss │ │ │ └── detail.ts │ │ └── home │ │ │ ├── home.html │ │ │ ├── home.scss │ │ │ └── home.ts │ ├── service-worker.js │ └── theme │ │ └── variables.scss ├── tsconfig.json └── tslint.json ├── neopixel ├── .editorconfig ├── .gitignore ├── README.md ├── config.xml ├── ionic.config.json ├── package.json ├── resources │ ├── android │ │ ├── icon │ │ │ ├── drawable-hdpi-icon.png │ │ │ ├── drawable-ldpi-icon.png │ │ │ ├── drawable-mdpi-icon.png │ │ │ ├── drawable-xhdpi-icon.png │ │ │ ├── drawable-xxhdpi-icon.png │ │ │ └── drawable-xxxhdpi-icon.png │ │ └── splash │ │ │ ├── drawable-land-hdpi-screen.png │ │ │ ├── drawable-land-ldpi-screen.png │ │ │ ├── drawable-land-mdpi-screen.png │ │ │ ├── drawable-land-xhdpi-screen.png │ │ │ ├── drawable-land-xxhdpi-screen.png │ │ │ ├── drawable-land-xxxhdpi-screen.png │ │ │ ├── drawable-port-hdpi-screen.png │ │ │ ├── drawable-port-ldpi-screen.png │ │ │ ├── drawable-port-mdpi-screen.png │ │ │ ├── drawable-port-xhdpi-screen.png │ │ │ ├── drawable-port-xxhdpi-screen.png │ │ │ └── drawable-port-xxxhdpi-screen.png │ ├── icon.png │ ├── ios │ │ ├── icon │ │ │ ├── icon-40.png │ │ │ ├── icon-40@2x.png │ │ │ ├── icon-40@3x.png │ │ │ ├── icon-50.png │ │ │ ├── icon-50@2x.png │ │ │ ├── icon-60.png │ │ │ ├── icon-60@2x.png │ │ │ ├── icon-60@3x.png │ │ │ ├── icon-72.png │ │ │ ├── icon-72@2x.png │ │ │ ├── icon-76.png │ │ │ ├── icon-76@2x.png │ │ │ ├── icon-83.5@2x.png │ │ │ ├── icon-small.png │ │ │ ├── icon-small@2x.png │ │ │ ├── icon-small@3x.png │ │ │ ├── icon.png │ │ │ └── icon@2x.png │ │ └── splash │ │ │ ├── Default-568h@2x~iphone.png │ │ │ ├── Default-667h.png │ │ │ ├── Default-736h.png │ │ │ ├── Default-Landscape-736h.png │ │ │ ├── Default-Landscape@2x~ipad.png │ │ │ ├── Default-Landscape@~ipadpro.png │ │ │ ├── Default-Landscape~ipad.png │ │ │ ├── Default-Portrait@2x~ipad.png │ │ │ ├── Default-Portrait@~ipadpro.png │ │ │ ├── Default-Portrait~ipad.png │ │ │ ├── Default@2x~iphone.png │ │ │ └── Default~iphone.png │ └── splash.png ├── src │ ├── app │ │ ├── app.component.ts │ │ ├── app.html │ │ ├── app.module.ts │ │ ├── app.scss │ │ └── main.ts │ ├── assets │ │ └── icon │ │ │ └── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── pages │ │ ├── detail │ │ │ ├── detail.html │ │ │ ├── detail.scss │ │ │ └── detail.ts │ │ └── home │ │ │ ├── home.html │ │ │ ├── home.scss │ │ │ └── home.ts │ ├── service-worker.js │ └── theme │ │ └── variables.scss ├── tsconfig.json └── tslint.json ├── scan ├── .editorconfig ├── .gitignore ├── README.md ├── config.xml ├── ionic.config.json ├── package.json ├── resources │ ├── README.md │ ├── android │ │ ├── icon │ │ │ ├── drawable-hdpi-icon.png │ │ │ ├── drawable-ldpi-icon.png │ │ │ ├── drawable-mdpi-icon.png │ │ │ ├── drawable-xhdpi-icon.png │ │ │ ├── drawable-xxhdpi-icon.png │ │ │ └── drawable-xxxhdpi-icon.png │ │ └── splash │ │ │ ├── drawable-land-hdpi-screen.png │ │ │ ├── drawable-land-ldpi-screen.png │ │ │ ├── drawable-land-mdpi-screen.png │ │ │ ├── drawable-land-xhdpi-screen.png │ │ │ ├── drawable-land-xxhdpi-screen.png │ │ │ ├── drawable-land-xxxhdpi-screen.png │ │ │ ├── drawable-port-hdpi-screen.png │ │ │ ├── drawable-port-ldpi-screen.png │ │ │ ├── drawable-port-mdpi-screen.png │ │ │ ├── drawable-port-xhdpi-screen.png │ │ │ ├── drawable-port-xxhdpi-screen.png │ │ │ └── drawable-port-xxxhdpi-screen.png │ ├── icon.png │ ├── ios │ │ ├── icon │ │ │ ├── icon-1024.png │ │ │ ├── icon-40.png │ │ │ ├── icon-40@2x.png │ │ │ ├── icon-40@3x.png │ │ │ ├── icon-50.png │ │ │ ├── icon-50@2x.png │ │ │ ├── icon-60.png │ │ │ ├── icon-60@2x.png │ │ │ ├── icon-60@3x.png │ │ │ ├── icon-72.png │ │ │ ├── icon-72@2x.png │ │ │ ├── icon-76.png │ │ │ ├── icon-76@2x.png │ │ │ ├── icon-83.5@2x.png │ │ │ ├── icon-small.png │ │ │ ├── icon-small@2x.png │ │ │ ├── icon-small@3x.png │ │ │ ├── icon.png │ │ │ └── icon@2x.png │ │ └── splash │ │ │ ├── Default-568h@2x~iphone.png │ │ │ ├── Default-667h.png │ │ │ ├── Default-736h.png │ │ │ ├── Default-Landscape-736h.png │ │ │ ├── Default-Landscape@2x~ipad.png │ │ │ ├── Default-Landscape@~ipadpro.png │ │ │ ├── Default-Landscape~ipad.png │ │ │ ├── Default-Portrait@2x~ipad.png │ │ │ ├── Default-Portrait@~ipadpro.png │ │ │ ├── Default-Portrait~ipad.png │ │ │ ├── Default@2x~iphone.png │ │ │ ├── Default@2x~universal~anyany.png │ │ │ └── Default~iphone.png │ └── splash.png ├── src │ ├── app │ │ ├── app.component.ts │ │ ├── app.html │ │ ├── app.module.ts │ │ ├── app.scss │ │ └── main.ts │ ├── assets │ │ └── icon │ │ │ └── favicon.ico │ ├── index.html │ ├── manifest.json │ ├── pages │ │ └── home │ │ │ ├── home.html │ │ │ ├── home.scss │ │ │ └── home.ts │ ├── service-worker.js │ └── theme │ │ └── variables.scss ├── tsconfig.json └── tslint.json └── thermometer ├── .editorconfig ├── .gitignore ├── README.md ├── config.xml ├── ionic.config.json ├── package.json ├── resources ├── android │ ├── icon │ │ ├── drawable-hdpi-icon.png │ │ ├── drawable-ldpi-icon.png │ │ ├── drawable-mdpi-icon.png │ │ ├── drawable-xhdpi-icon.png │ │ ├── drawable-xxhdpi-icon.png │ │ └── drawable-xxxhdpi-icon.png │ └── splash │ │ ├── drawable-land-hdpi-screen.png │ │ ├── drawable-land-ldpi-screen.png │ │ ├── drawable-land-mdpi-screen.png │ │ ├── drawable-land-xhdpi-screen.png │ │ ├── drawable-land-xxhdpi-screen.png │ │ ├── drawable-land-xxxhdpi-screen.png │ │ ├── drawable-port-hdpi-screen.png │ │ ├── drawable-port-ldpi-screen.png │ │ ├── drawable-port-mdpi-screen.png │ │ ├── drawable-port-xhdpi-screen.png │ │ ├── drawable-port-xxhdpi-screen.png │ │ └── drawable-port-xxxhdpi-screen.png ├── icon.png ├── ios │ ├── icon │ │ ├── icon-40.png │ │ ├── icon-40@2x.png │ │ ├── icon-40@3x.png │ │ ├── icon-50.png │ │ ├── icon-50@2x.png │ │ ├── icon-60.png │ │ ├── icon-60@2x.png │ │ ├── icon-60@3x.png │ │ ├── icon-72.png │ │ ├── icon-72@2x.png │ │ ├── icon-76.png │ │ ├── icon-76@2x.png │ │ ├── icon-83.5@2x.png │ │ ├── icon-small.png │ │ ├── icon-small@2x.png │ │ ├── icon-small@3x.png │ │ ├── icon.png │ │ └── icon@2x.png │ └── splash │ │ ├── Default-568h@2x~iphone.png │ │ ├── Default-667h.png │ │ ├── Default-736h.png │ │ ├── Default-Landscape-736h.png │ │ ├── Default-Landscape@2x~ipad.png │ │ ├── Default-Landscape@~ipadpro.png │ │ ├── Default-Landscape~ipad.png │ │ ├── Default-Portrait@2x~ipad.png │ │ ├── Default-Portrait@~ipadpro.png │ │ ├── Default-Portrait~ipad.png │ │ ├── Default@2x~iphone.png │ │ └── Default~iphone.png └── splash.png ├── src ├── app │ ├── app.component.ts │ ├── app.html │ ├── app.module.ts │ ├── app.scss │ └── main.ts ├── assets │ └── icon │ │ └── favicon.ico ├── index.html ├── manifest.json ├── pages │ ├── detail │ │ ├── detail.html │ │ ├── detail.scss │ │ └── detail.ts │ └── home │ │ ├── home.html │ │ ├── home.scss │ │ └── home.ts ├── pipes │ ├── format-temperature-c │ │ └── format-temperature-c.ts │ ├── format-temperature-f │ │ └── format-temperature-f.ts │ └── format-temperature │ │ └── format-temperature.ts ├── service-worker.js └── theme │ └── variables.scss ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | build.json 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ionic Bluetooth Low Energy Examples 2 | 3 | Demonstrate [cordova-plugin-ble-central](https://github.com/don/cordova-plugin-ble-central) with [Ionic](https://ionic.io). 4 | 5 | These were examples written for an Ionic Bluetooth presentation given at the [Ionic Philadelphia Meetup](https://www.meetup.com/ionic-philly) and the [Ionic Madison Meetup](https://www.meetup.com/Ionic-Madison/events/241516046/). The [presentation slides](http://don.github.io/slides/2017-12-07-ionic-philadephia/#/1) are available online. 6 | 7 | Projects 8 | * [Scan](/scan) - Scan for Bluetooth LE devices 9 | * [Connect](/connect) - Connect to a Bluetooth LE device and show services 10 | * [Light](/light) - Control a Bluetooth LE lightbulb 11 | * [Button](/button) - Receive notifications from a TI CC2650 SensorTag button 12 | * [Thermometer](/thermometer) - Receive temperature notifications from Bluetooth LE thermometer 13 | * [NeoPixel](/neopixel) - Control NeoPixel lights with Bluetooth LE 14 | 15 | The [arduino](/arduino) directory has programs and wiring diagrams for building Bluetooth LE peripherals with the Arduino 101. 16 | -------------------------------------------------------------------------------- /arduino/Button/Button.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // create peripheral instance 4 | BLEPeripheral blePeripheral; 5 | 6 | // create service 7 | BLEService buttonService = BLEService("FFE0"); 8 | 9 | // create characteristic 10 | BLECharCharacteristic buttonCharacteristic = BLECharCharacteristic("FFE1", BLENotify); 11 | BLEDescriptor buttonDescriptor = BLEDescriptor("2901", "Button State"); 12 | 13 | #define BUTTON_PIN 7 14 | 15 | unsigned long lastReadTime = 0; 16 | unsigned char readInterval = 100; 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | pinMode(BUTTON_PIN, INPUT); 21 | 22 | // set advertised local name and service UUID 23 | blePeripheral.setLocalName("Button"); 24 | blePeripheral.setDeviceName("Button"); 25 | // Advertise AA80 so this looks like a TI CC2650 Sensor Tag 26 | blePeripheral.setAdvertisedServiceUuid("AA80"); 27 | 28 | // add service and characteristics 29 | blePeripheral.addAttribute(buttonService); 30 | blePeripheral.addAttribute(buttonCharacteristic); 31 | blePeripheral.addAttribute(buttonDescriptor); 32 | 33 | // begin initialization 34 | blePeripheral.begin(); 35 | Serial.println(F("Bluetooth Button")); 36 | } 37 | 38 | void loop() { 39 | // Tell the bluetooth radio to do whatever it should be working on 40 | blePeripheral.poll(); 41 | 42 | // limit how often we read the button 43 | if (millis() - lastReadTime > readInterval) { 44 | readButton(); 45 | lastReadTime = millis(); 46 | } 47 | } 48 | 49 | void readButton() { 50 | char buttonValue = digitalRead(BUTTON_PIN); 51 | 52 | // has the value changed since the last read? 53 | if (buttonCharacteristic.value() != buttonValue) { 54 | Serial.print("Button "); 55 | Serial.println(buttonValue, HEX); 56 | buttonCharacteristic.setValue(buttonValue); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /arduino/Button_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/arduino/Button_bb.png -------------------------------------------------------------------------------- /arduino/LED/LED.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #define LED_PIN 6 3 | 4 | // create peripheral instance 5 | BLEPeripheral blePeripheral; 6 | 7 | // create service 8 | BLEService ledService = BLEService("FF10"); 9 | 10 | // create switch and dimmer characteristic 11 | BLECharCharacteristic switchCharacteristic = BLECharCharacteristic("FF11", BLERead | BLEWrite); 12 | BLEDescriptor switchDescriptor = BLEDescriptor("2901", "Switch"); 13 | BLEUnsignedCharCharacteristic dimmerCharacteristic = BLEUnsignedCharCharacteristic("FF12", BLERead | BLEWrite); 14 | BLEDescriptor dimmerDescriptor = BLEDescriptor("2901", "Dimmer"); 15 | 16 | void setup() { 17 | Serial.begin(9600); 18 | 19 | // set LED pin to output mode 20 | pinMode(LED_PIN, OUTPUT); 21 | 22 | // set advertised local name and service UUID 23 | blePeripheral.setLocalName("LED"); 24 | blePeripheral.setDeviceName("LED"); 25 | blePeripheral.setAdvertisedServiceUuid(ledService.uuid()); 26 | 27 | // add service and characteristics 28 | blePeripheral.addAttribute(ledService); 29 | blePeripheral.addAttribute(switchCharacteristic); 30 | blePeripheral.addAttribute(switchDescriptor); 31 | blePeripheral.addAttribute(dimmerCharacteristic); 32 | blePeripheral.addAttribute(dimmerDescriptor); 33 | 34 | // assign event handlers for characteristic 35 | switchCharacteristic.setEventHandler(BLEWritten, switchCharacteristicWritten); 36 | dimmerCharacteristic.setEventHandler(BLEWritten, dimmerCharacteristicWritten); 37 | 38 | // begin initialization 39 | blePeripheral.begin(); 40 | 41 | // set the default value 42 | dimmerCharacteristic.setValue(0xFF); 43 | 44 | Serial.println(F("Bluetooth LED")); 45 | } 46 | 47 | void loop() { 48 | // Tell the bluetooth radio to do whatever it should be working on 49 | blePeripheral.poll(); 50 | } 51 | 52 | void switchCharacteristicWritten(BLECentral& central, BLECharacteristic& characteristic) { 53 | // central wrote new value to characteristic, update LED 54 | Serial.print(F("Characteristic event, written: ")); 55 | 56 | if (switchCharacteristic.value()) { 57 | Serial.println(F("LED on")); 58 | analogWrite(LED_PIN, dimmerCharacteristic.value()); 59 | } else { 60 | Serial.println(F("LED off")); 61 | analogWrite(LED_PIN, 0x00); 62 | } 63 | 64 | } 65 | 66 | void dimmerCharacteristicWritten(BLECentral& central, BLECharacteristic& characteristic) { 67 | Serial.print(F("Dimmer set to: ")); 68 | Serial.println(dimmerCharacteristic.value()); 69 | 70 | analogWrite(LED_PIN, dimmerCharacteristic.value()); 71 | } 72 | -------------------------------------------------------------------------------- /arduino/LED_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/arduino/LED_bb.png -------------------------------------------------------------------------------- /arduino/README.md: -------------------------------------------------------------------------------- 1 | Use the [Arduino IDE](https://www.arduino.cc/en/Main/Software) and an [Arduino 101](http://www.microcenter.com/product/460273/Arduino_101_with_Intel_Curie) to build this Bluetooth Hardware. 2 | 3 | [LED.ino](LED/LED.ino) emulates the SmartBotics lightbulb. 4 | 5 | 6 | 7 | [Button.ino](Button/Button.ino) emulates the button service from the [TI CC2650 SensorTag](ti.com/sensortag). 8 | 9 | 10 | 11 | [Thermometer.ino](Thermometer/Thermometer.ino) uses a [TMP36](https://www.adafruit.com/product/165) analog temperature sensor and provides a custom temperature service. 12 | 13 | 14 | -------------------------------------------------------------------------------- /arduino/Thermometer/Thermometer.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | BLEPeripheral blePeripheral; 4 | BLEService thermometerService = BLEService("BBB0"); 5 | BLEFloatCharacteristic temperatureCharacteristic = BLEFloatCharacteristic("BBB1", BLERead | BLENotify); 6 | BLEDescriptor temperatureDescriptor = BLEDescriptor("2901", "degrees C"); 7 | 8 | #define TEMPERATURE_PIN A0 9 | 10 | unsigned long previousMillis = 0; // will store last time temperature was updated 11 | unsigned short interval = 2000; // interval at which to read temperature (milliseconds) 12 | 13 | void setup() 14 | { 15 | Serial.begin(9600); 16 | Serial.println(F("Bluetooth Low Energy Thermometer")); 17 | 18 | // set advertised name and service 19 | blePeripheral.setLocalName("Thermometer"); 20 | blePeripheral.setDeviceName("Thermometer"); 21 | blePeripheral.setAdvertisedServiceUuid(thermometerService.uuid()); 22 | 23 | // add service and characteristic 24 | blePeripheral.addAttribute(thermometerService); 25 | blePeripheral.addAttribute(temperatureCharacteristic); 26 | blePeripheral.addAttribute(temperatureDescriptor); 27 | 28 | blePeripheral.begin(); 29 | } 30 | 31 | void loop() 32 | { 33 | // Tell the bluetooth radio to do whatever it should be working on 34 | blePeripheral.poll(); 35 | 36 | // limit how often we read the sensor 37 | if(millis() - previousMillis > interval) { 38 | pollTemperatureSensor(); 39 | previousMillis = millis(); 40 | } 41 | } 42 | 43 | void pollTemperatureSensor() 44 | { 45 | float temperature = calculateTemperature(); 46 | 47 | // only set the characteristic value if the temperature has changed 48 | if (temperatureCharacteristic.value() != temperature) { 49 | temperatureCharacteristic.setValue(temperature); 50 | Serial.println(temperature); 51 | } 52 | } 53 | 54 | // calculate the temperature from the sensor reading 55 | // https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor 56 | float calculateTemperature() 57 | { 58 | // read the sensor value 59 | int sensorValue = analogRead(TEMPERATURE_PIN); 60 | 61 | // 3.3v logic, 10-bit ADC 62 | float voltage = sensorValue * 3.3 / 1024.0; 63 | // 100 degrees per volt with 0.5 volt offset 64 | float temperature = (voltage - 0.5) * 100; 65 | 66 | return temperature; 67 | } 68 | -------------------------------------------------------------------------------- /arduino/Thermometer_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/arduino/Thermometer_bb.png -------------------------------------------------------------------------------- /button/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 2 9 | 10 | # We recommend you to keep these unchanged 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /button/.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .sass-cache/ 17 | .tmp/ 18 | .versions/ 19 | coverage/ 20 | dist/ 21 | node_modules/ 22 | tmp/ 23 | temp/ 24 | hooks/ 25 | platforms/ 26 | plugins/ 27 | plugins/android.json 28 | plugins/ios.json 29 | www/ 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | -------------------------------------------------------------------------------- /button/README.md: -------------------------------------------------------------------------------- 1 | # Ionic3 Bluetooth Low Energy Button 2 | 3 | Read the button status from a TI CC2650 SensorTag. 4 | 5 | ## Ionic 3 6 | 7 | This project requires Ionic3 8 | 9 | npm install -g ionic@latest 10 | 11 | Install Cordova just to be safe 12 | 13 | npm install -g cordova@latest 14 | 15 | 16 | ## iOS 17 | 18 | Assuming you have Xcode installed 19 | 20 | ionic cordova run ios --device 21 | 22 | Note: You might need to open Xcode and set the Team for code signing. 23 | 24 | ## Android 25 | 26 | Assuming you have the Android SDK installed 27 | 28 | ionic cordova run android --device 29 | -------------------------------------------------------------------------------- /button/ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Button", 3 | "app_id": "com.example.ble.button", 4 | "type": "ionic-angular", 5 | "integrations": { 6 | "cordova": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /button/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-ble-button", 3 | "version": "0.0.1", 4 | "author": "Don Coleman", 5 | "homepage": "http://github.com/don", 6 | "private": true, 7 | "scripts": { 8 | "clean": "ionic-app-scripts clean", 9 | "build": "ionic-app-scripts build", 10 | "lint": "ionic-app-scripts lint", 11 | "ionic:build": "ionic-app-scripts build", 12 | "ionic:serve": "ionic-app-scripts serve" 13 | }, 14 | "dependencies": { 15 | "@angular/common": "4.1.3", 16 | "@angular/compiler": "4.1.3", 17 | "@angular/compiler-cli": "4.1.3", 18 | "@angular/core": "4.1.3", 19 | "@angular/forms": "4.1.3", 20 | "@angular/http": "4.1.3", 21 | "@angular/platform-browser": "4.1.3", 22 | "@angular/platform-browser-dynamic": "4.1.3", 23 | "@ionic-native/ble": "^4.0.1", 24 | "@ionic-native/core": "3.12.1", 25 | "@ionic-native/splash-screen": "3.12.1", 26 | "@ionic-native/status-bar": "3.12.1", 27 | "@ionic/storage": "2.0.1", 28 | "cordova-android": "^6.2.3", 29 | "cordova-ios": "~4.4.0", 30 | "cordova-plugin-ble-central": "^1.1.4", 31 | "cordova-plugin-compat": "^1.2.0", 32 | "cordova-plugin-console": "^1.1.0", 33 | "cordova-plugin-device": "^1.1.7", 34 | "cordova-plugin-splashscreen": "^4.1.0", 35 | "cordova-plugin-statusbar": "^2.3.0", 36 | "cordova-plugin-whitelist": "^1.3.3", 37 | "ionic-angular": "3.5.3", 38 | "ionic-plugin-keyboard": "^2.2.1", 39 | "ionicons": "3.0.0", 40 | "rxjs": "5.4.0", 41 | "sw-toolbox": "3.6.0", 42 | "zone.js": "0.8.12" 43 | }, 44 | "devDependencies": { 45 | "@ionic/app-scripts": "2.0.2", 46 | "typescript": "2.3.4" 47 | }, 48 | "description": "An Ionic project", 49 | "cordova": { 50 | "plugins": { 51 | "cordova-plugin-ble-central": { 52 | "BLUETOOTH_USAGE_DESCRIPTION": " " 53 | }, 54 | "cordova-plugin-console": {}, 55 | "cordova-plugin-device": {}, 56 | "cordova-plugin-splashscreen": {}, 57 | "cordova-plugin-statusbar": {}, 58 | "cordova-plugin-whitelist": {}, 59 | "ionic-plugin-keyboard": {} 60 | }, 61 | "platforms": [ 62 | "android", 63 | "ios" 64 | ] 65 | } 66 | } -------------------------------------------------------------------------------- /button/resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /button/resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /button/resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /button/resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /button/resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /button/resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /button/resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /button/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/icon.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /button/resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /button/resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /button/resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/resources/splash.png -------------------------------------------------------------------------------- /button/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Platform } from 'ionic-angular'; 3 | import { StatusBar } from '@ionic-native/status-bar'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | 6 | import { HomePage } from '../pages/home/home'; 7 | @Component({ 8 | templateUrl: 'app.html' 9 | }) 10 | export class MyApp { 11 | rootPage:any = HomePage; 12 | 13 | constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 14 | platform.ready().then(() => { 15 | // Okay, so the platform is ready and our plugins are available. 16 | // Here you can do any higher level native things you might need. 17 | statusBar.styleDefault(); 18 | splashScreen.hide(); 19 | }); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /button/src/app/app.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /button/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { ErrorHandler, NgModule } from '@angular/core'; 3 | import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | import { StatusBar } from '@ionic-native/status-bar'; 6 | import { BLE } from '@ionic-native/ble'; 7 | 8 | import { MyApp } from './app.component'; 9 | import { HomePage } from '../pages/home/home'; 10 | import { DetailPage } from '../pages/detail/detail'; 11 | import { ButtonStateDescriptionPipe } from '../pipes/button-state-description/button-state-description'; 12 | 13 | @NgModule({ 14 | declarations: [ 15 | MyApp, 16 | HomePage, 17 | DetailPage, 18 | ButtonStateDescriptionPipe 19 | ], 20 | imports: [ 21 | BrowserModule, 22 | IonicModule.forRoot(MyApp) 23 | ], 24 | bootstrap: [IonicApp], 25 | entryComponents: [ 26 | MyApp, 27 | HomePage, 28 | DetailPage 29 | ], 30 | providers: [ 31 | StatusBar, 32 | SplashScreen, 33 | {provide: ErrorHandler, useClass: IonicErrorHandler}, 34 | BLE 35 | ] 36 | }) 37 | export class AppModule {} 38 | -------------------------------------------------------------------------------- /button/src/app/app.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Global Sass 5 | // -------------------------------------------------- 6 | // Put style rules here that you want to apply globally. These 7 | // styles are for the entire app and not just one component. 8 | // Additionally, this file can be also used as an entry point 9 | // to import other Sass files to be included in the output CSS. 10 | // 11 | // Shared Sass variables, which can be used to adjust Ionic's 12 | // default Sass variables, belong in "theme/variables.scss". 13 | // 14 | // To declare rules for a specific mode, create a child rule 15 | // for the .md, .ios, or .wp mode classes. The mode class is 16 | // automatically applied to the element in the app. 17 | -------------------------------------------------------------------------------- /button/src/app/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | 3 | import { AppModule } from './app.module'; 4 | 5 | platformBrowserDynamic().bootstrapModule(AppModule); 6 | -------------------------------------------------------------------------------- /button/src/assets/icon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/button/src/assets/icon/favicon.ico -------------------------------------------------------------------------------- /button/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /button/src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Ionic", 3 | "short_name": "Ionic", 4 | "start_url": "index.html", 5 | "display": "standalone", 6 | "icons": [{ 7 | "src": "assets/imgs/logo.png", 8 | "sizes": "512x512", 9 | "type": "image/png" 10 | }], 11 | "background_color": "#4e8ef7", 12 | "theme_color": "#4e8ef7" 13 | } -------------------------------------------------------------------------------- /button/src/pages/detail/detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ peripheral.name || 'Device' }} 4 | 5 | 6 | 7 | 8 | 9 |

{{ buttonState | buttonStateDescription }}

10 |
11 | 12 |
13 | 14 | 15 | 16 |

{{ statusMessage }}

17 |
18 |
19 | -------------------------------------------------------------------------------- /button/src/pages/detail/detail.scss: -------------------------------------------------------------------------------- 1 | page-detail { 2 | .toolbar-content p { 3 | margin-left: 10px; 4 | } 5 | .card { 6 | padding: 20px; 7 | text-align: center; 8 | } 9 | 10 | .card h1 { 11 | font-size: 4em; 12 | } 13 | } -------------------------------------------------------------------------------- /button/src/pages/detail/detail.ts: -------------------------------------------------------------------------------- 1 | import { Component, NgZone } from '@angular/core'; 2 | import { NavController, NavParams, AlertController } from 'ionic-angular'; 3 | import { BLE } from '@ionic-native/ble'; 4 | 5 | // Bluetooth UUIDs 6 | const BUTTON_SERVICE = 'ffe0'; 7 | const BUTTON_STATE_CHARACTERISTIC = 'ffe1'; 8 | 9 | @Component({ 10 | selector: 'page-detail', 11 | templateUrl: 'detail.html', 12 | }) 13 | export class DetailPage { 14 | 15 | peripheral: any = {}; 16 | buttonState: number; 17 | statusMessage: string; 18 | 19 | constructor(public navCtrl: NavController, 20 | public navParams: NavParams, 21 | private ble: BLE, 22 | private alertCtrl: AlertController, 23 | private ngZone: NgZone) { 24 | 25 | let device = navParams.get('device'); 26 | 27 | this.setStatus('Connecting to ' + device.name || device.id); 28 | 29 | this.ble.connect(device.id).subscribe( 30 | peripheral => this.onConnected(peripheral), 31 | peripheral => this.showAlert('Disconnected', 'The peripheral unexpectedly disconnected') 32 | ); 33 | 34 | } 35 | 36 | // the connection to the peripheral was successful 37 | onConnected(peripheral) { 38 | 39 | this.peripheral = peripheral; 40 | this.setStatus('Connected to ' + (peripheral.name || peripheral.id)); 41 | 42 | this.ble.startNotification(this.peripheral.id, BUTTON_SERVICE, BUTTON_STATE_CHARACTERISTIC).subscribe( 43 | data => this.onButtonStateChange(data), 44 | () => this.showAlert('Unexpected Error', 'Failed to subscribe for button state changes') 45 | ) 46 | 47 | } 48 | 49 | onButtonStateChange(buffer:ArrayBuffer) { 50 | var data = new Uint8Array(buffer); 51 | console.log(data[0]); 52 | 53 | this.ngZone.run(() => { 54 | this.buttonState = data[0]; 55 | }); 56 | 57 | } 58 | 59 | // Disconnect peripheral when leaving the page 60 | ionViewWillLeave() { 61 | console.log('ionViewWillLeave disconnecting Bluetooth'); 62 | this.ble.disconnect(this.peripheral.id).then( 63 | () => console.log('Disconnected ' + JSON.stringify(this.peripheral)), 64 | () => console.log('ERROR disconnecting ' + JSON.stringify(this.peripheral)) 65 | ) 66 | } 67 | 68 | showAlert(title, message) { 69 | let alert = this.alertCtrl.create({ 70 | title: title, 71 | subTitle: message, 72 | buttons: ['OK'] 73 | }); 74 | alert.present(); 75 | } 76 | 77 | setStatus(message) { 78 | console.log(message); 79 | this.ngZone.run(() => { 80 | this.statusMessage = message; 81 | }); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /button/src/pages/home/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BLE Button 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 |

{{ statusMessage }}

27 |
28 |
29 | -------------------------------------------------------------------------------- /button/src/pages/home/home.scss: -------------------------------------------------------------------------------- 1 | page-home { 2 | .toolbar-content p { 3 | margin-left: 10px; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /button/src/pages/home/home.ts: -------------------------------------------------------------------------------- 1 | import { BLE } from '@ionic-native/ble'; 2 | import { Component, NgZone } from '@angular/core'; 3 | import { NavController } from 'ionic-angular'; 4 | import { ToastController } from 'ionic-angular'; 5 | import { DetailPage } from '../detail/detail'; 6 | 7 | const SENSORTAG_SERVICE = 'aa80'; 8 | 9 | @Component({ 10 | selector: 'page-home', 11 | templateUrl: 'home.html' 12 | }) 13 | export class HomePage { 14 | 15 | devices: any[] = []; 16 | statusMessage: string; 17 | 18 | constructor(public navCtrl: NavController, 19 | private toastCtrl: ToastController, 20 | private ble: BLE, 21 | private ngZone: NgZone) { 22 | } 23 | 24 | ionViewDidEnter() { 25 | console.log('ionViewDidEnter'); 26 | this.scan(); 27 | } 28 | 29 | scan() { 30 | this.setStatus('Scanning for Bluetooth LE Devices'); 31 | this.devices = []; // clear list 32 | 33 | this.ble.scan([SENSORTAG_SERVICE], 5).subscribe( 34 | device => this.onDeviceDiscovered(device), 35 | error => this.scanError(error) 36 | ); 37 | 38 | setTimeout(this.setStatus.bind(this), 5000, 'Scan complete'); 39 | } 40 | 41 | onDeviceDiscovered(device) { 42 | console.log('Discovered ' + JSON.stringify(device, null, 2)); 43 | this.ngZone.run(() => { 44 | this.devices.push(device); 45 | }); 46 | } 47 | 48 | // If location permission is denied, you'll end up here 49 | scanError(error) { 50 | this.setStatus('Error ' + error); 51 | let toast = this.toastCtrl.create({ 52 | message: 'Error scanning for Bluetooth low energy devices', 53 | position: 'middle', 54 | duration: 5000 55 | }); 56 | toast.present(); 57 | } 58 | 59 | setStatus(message) { 60 | console.log(message); 61 | this.ngZone.run(() => { 62 | this.statusMessage = message; 63 | }); 64 | } 65 | 66 | deviceSelected(device) { 67 | console.log(JSON.stringify(device) + ' selected'); 68 | this.navCtrl.push(DetailPage, { 69 | device: device 70 | }); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /button/src/pipes/button-state-description/button-state-description.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | @Pipe({ 4 | name: 'buttonStateDescription', 5 | }) 6 | export class ButtonStateDescriptionPipe implements PipeTransform { 7 | /** 8 | * Translate the button state into a description 9 | */ 10 | transform(buttonState: number, ...args) { 11 | 12 | let description; 13 | 14 | // TODO get code from SensorTag for multiple buttons 15 | if (buttonState === 0) { 16 | description = 'Button is Released'; 17 | } else if (buttonState) { 18 | description = 'Button is Pressed'; 19 | } else { 20 | description = 'Button State is Unknown'; 21 | } 22 | 23 | return description; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /button/src/service-worker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Check out https://googlechrome.github.io/sw-toolbox/ for 3 | * more info on how to use sw-toolbox to custom configure your service worker. 4 | */ 5 | 6 | 7 | 'use strict'; 8 | importScripts('./build/sw-toolbox.js'); 9 | 10 | self.toolbox.options.cache = { 11 | name: 'ionic-cache' 12 | }; 13 | 14 | // pre-cache our key assets 15 | self.toolbox.precache( 16 | [ 17 | './build/main.js', 18 | './build/main.css', 19 | './build/polyfills.js', 20 | 'index.html', 21 | 'manifest.json' 22 | ] 23 | ); 24 | 25 | // dynamically cache any other local assets 26 | self.toolbox.router.any('/*', self.toolbox.cacheFirst); 27 | 28 | // for any other requests go to the network, cache, 29 | // and then only use that cached resource if your user goes offline 30 | self.toolbox.router.default = self.toolbox.networkFirst; 31 | -------------------------------------------------------------------------------- /button/src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/v2/theming/ 3 | 4 | // Font path is used to include ionicons, 5 | // roboto, and noto sans fonts 6 | $font-path: "../assets/fonts"; 7 | 8 | 9 | // The app direction is used to include 10 | // rtl styles in your app. For more info, please see: 11 | // http://ionicframework.com/docs/theming/rtl-support/ 12 | $app-direction: ltr; 13 | 14 | 15 | @import "ionic.globals"; 16 | 17 | 18 | // Shared Variables 19 | // -------------------------------------------------- 20 | // To customize the look and feel of this app, you can override 21 | // the Sass variables found in Ionic's source scss files. 22 | // To view all the possible Ionic variables, see: 23 | // http://ionicframework.com/docs/v2/theming/overriding-ionic-variables/ 24 | 25 | 26 | 27 | 28 | // Named Color Variables 29 | // -------------------------------------------------- 30 | // Named colors makes it easy to reuse colors on various components. 31 | // It's highly recommended to change the default colors 32 | // to match your app's branding. Ionic uses a Sass map of 33 | // colors so you can add, rename and remove colors as needed. 34 | // The "primary" color is the only required color in the map. 35 | 36 | $colors: ( 37 | primary: #488aff, 38 | secondary: #32db64, 39 | danger: #f53d3d, 40 | light: #f4f4f4, 41 | dark: #222 42 | ); 43 | 44 | 45 | // App iOS Variables 46 | // -------------------------------------------------- 47 | // iOS only Sass variables can go here 48 | 49 | 50 | 51 | 52 | // App Material Design Variables 53 | // -------------------------------------------------- 54 | // Material Design only Sass variables can go here 55 | 56 | 57 | 58 | 59 | // App Windows Variables 60 | // -------------------------------------------------- 61 | // Windows only Sass variables can go here 62 | 63 | 64 | 65 | 66 | // App Theme 67 | // -------------------------------------------------- 68 | // Ionic apps can have different themes applied, which can 69 | // then be future customized. This import comes last 70 | // so that the above variables are used and Ionic's 71 | // default are overridden. 72 | 73 | @import "ionic.theme.default"; 74 | 75 | 76 | // Ionicons 77 | // -------------------------------------------------- 78 | // The premium icon font for Ionic. For more info, please see: 79 | // http://ionicframework.com/docs/v2/ionicons/ 80 | 81 | @import "ionic.ionicons"; 82 | 83 | 84 | // Fonts 85 | // -------------------------------------------------- 86 | 87 | @import "roboto"; 88 | @import "noto-sans"; 89 | -------------------------------------------------------------------------------- /button/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "declaration": false, 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "lib": [ 8 | "dom", 9 | "es2015" 10 | ], 11 | "module": "es2015", 12 | "moduleResolution": "node", 13 | "sourceMap": true, 14 | "target": "es5" 15 | }, 16 | "include": [ 17 | "src/**/*.ts" 18 | ], 19 | "exclude": [ 20 | "node_modules" 21 | ], 22 | "compileOnSave": false, 23 | "atom": { 24 | "rewriteTsconfig": false 25 | } 26 | } -------------------------------------------------------------------------------- /button/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-duplicate-variable": true, 4 | "no-unused-variable": [ 5 | true 6 | ] 7 | }, 8 | "rulesDirectory": [ 9 | "node_modules/tslint-eslint-rules/dist/rules" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /connect/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 2 9 | 10 | # We recommend you to keep these unchanged 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /connect/.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .sass-cache/ 17 | .tmp/ 18 | .versions/ 19 | coverage/ 20 | dist/ 21 | node_modules/ 22 | tmp/ 23 | temp/ 24 | hooks/ 25 | platforms/ 26 | plugins/ 27 | plugins/android.json 28 | plugins/ios.json 29 | www/ 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | -------------------------------------------------------------------------------- /connect/README.md: -------------------------------------------------------------------------------- 1 | # Ionic3 Bluetooth Low Energy Connect 2 | 3 | Scan for and connect to the Bluetooth Low Energy device. 4 | 5 | This example builds on the Scan example and adds a detail page with information about the connected peripheral. 6 | 7 | ## Ionic 3 8 | 9 | This project requires Ionic3 10 | 11 | npm install -g ionic@latest 12 | 13 | Install Cordova just to be safe 14 | 15 | npm install -g cordova@latest 16 | 17 | 18 | ## iOS 19 | 20 | Assuming you have Xcode installed 21 | 22 | ionic cordova run ios --device 23 | 24 | Note: You might need to open Xcode and set the Team for code signing. 25 | 26 | ## Android 27 | 28 | Assuming you have the Android SDK installed 29 | 30 | ionic cordova run android --device 31 | -------------------------------------------------------------------------------- /connect/ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Connect", 3 | "app_id": "com.example.ble.connect", 4 | "type": "ionic-angular", 5 | "integrations": { 6 | "cordova": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /connect/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-ble-connect", 3 | "version": "0.0.1", 4 | "author": "Ionic Framework", 5 | "homepage": "http://ionicframework.com/", 6 | "private": true, 7 | "scripts": { 8 | "clean": "ionic-app-scripts clean", 9 | "build": "ionic-app-scripts build", 10 | "lint": "ionic-app-scripts lint", 11 | "ionic:build": "ionic-app-scripts build", 12 | "ionic:serve": "ionic-app-scripts serve" 13 | }, 14 | "dependencies": { 15 | "@angular/common": "4.1.3", 16 | "@angular/compiler": "4.1.3", 17 | "@angular/compiler-cli": "4.1.3", 18 | "@angular/core": "4.1.3", 19 | "@angular/forms": "4.1.3", 20 | "@angular/http": "4.1.3", 21 | "@angular/platform-browser": "4.1.3", 22 | "@angular/platform-browser-dynamic": "4.1.3", 23 | "@ionic-native/ble": "^4.0.0", 24 | "@ionic-native/core": "3.12.1", 25 | "@ionic-native/splash-screen": "3.12.1", 26 | "@ionic-native/status-bar": "3.12.1", 27 | "@ionic/storage": "2.0.1", 28 | "cordova-plugin-ble-central": "^1.1.4", 29 | "cordova-plugin-compat": "^1.2.0", 30 | "cordova-plugin-console": "^1.1.0", 31 | "cordova-plugin-device": "^1.1.7", 32 | "cordova-plugin-splashscreen": "^4.1.0", 33 | "cordova-plugin-statusbar": "^2.3.0", 34 | "cordova-plugin-whitelist": "^1.3.3", 35 | "ionic-angular": "3.5.0", 36 | "ionic-plugin-keyboard": "^2.2.1", 37 | "ionicons": "3.0.0", 38 | "rxjs": "5.4.0", 39 | "sw-toolbox": "3.6.0", 40 | "zone.js": "0.8.12", 41 | "cordova-ios": "~4.5.4", 42 | "cordova-android": "~6.3.0" 43 | }, 44 | "devDependencies": { 45 | "@ionic/app-scripts": "2.0.1", 46 | "typescript": "2.3.4" 47 | }, 48 | "description": "An Ionic project", 49 | "cordova": { 50 | "plugins": { 51 | "cordova-plugin-ble-central": { 52 | "BLUETOOTH_USAGE_DESCRIPTION": " " 53 | }, 54 | "cordova-plugin-console": {}, 55 | "cordova-plugin-device": {}, 56 | "cordova-plugin-splashscreen": {}, 57 | "cordova-plugin-statusbar": {}, 58 | "cordova-plugin-whitelist": {}, 59 | "ionic-plugin-keyboard": {} 60 | }, 61 | "platforms": [ 62 | "ios", 63 | "android" 64 | ] 65 | } 66 | } -------------------------------------------------------------------------------- /connect/resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /connect/resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /connect/resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /connect/resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /connect/resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /connect/resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /connect/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/icon.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /connect/resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /connect/resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /connect/resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/resources/splash.png -------------------------------------------------------------------------------- /connect/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Platform } from 'ionic-angular'; 3 | import { StatusBar } from '@ionic-native/status-bar'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | 6 | import { HomePage } from '../pages/home/home'; 7 | @Component({ 8 | templateUrl: 'app.html' 9 | }) 10 | export class MyApp { 11 | rootPage:any = HomePage; 12 | 13 | constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 14 | platform.ready().then(() => { 15 | // Okay, so the platform is ready and our plugins are available. 16 | // Here you can do any higher level native things you might need. 17 | statusBar.styleDefault(); 18 | splashScreen.hide(); 19 | }); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /connect/src/app/app.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /connect/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { ErrorHandler, NgModule } from '@angular/core'; 3 | import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | import { StatusBar } from '@ionic-native/status-bar'; 6 | import { BLE } from '@ionic-native/ble'; 7 | 8 | import { MyApp } from './app.component'; 9 | import { HomePage } from '../pages/home/home'; 10 | import { DetailPage } from '../pages/detail/detail'; 11 | 12 | @NgModule({ 13 | declarations: [ 14 | MyApp, 15 | HomePage, 16 | DetailPage 17 | ], 18 | imports: [ 19 | BrowserModule, 20 | IonicModule.forRoot(MyApp) 21 | ], 22 | bootstrap: [IonicApp], 23 | entryComponents: [ 24 | MyApp, 25 | HomePage, 26 | DetailPage 27 | ], 28 | providers: [ 29 | StatusBar, 30 | SplashScreen, 31 | {provide: ErrorHandler, useClass: IonicErrorHandler}, 32 | BLE 33 | ] 34 | }) 35 | export class AppModule {} 36 | -------------------------------------------------------------------------------- /connect/src/app/app.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Global Sass 5 | // -------------------------------------------------- 6 | // Put style rules here that you want to apply globally. These 7 | // styles are for the entire app and not just one component. 8 | // Additionally, this file can be also used as an entry point 9 | // to import other Sass files to be included in the output CSS. 10 | // 11 | // Shared Sass variables, which can be used to adjust Ionic's 12 | // default Sass variables, belong in "theme/variables.scss". 13 | // 14 | // To declare rules for a specific mode, create a child rule 15 | // for the .md, .ios, or .wp mode classes. The mode class is 16 | // automatically applied to the element in the app. 17 | -------------------------------------------------------------------------------- /connect/src/app/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | 3 | import { AppModule } from './app.module'; 4 | 5 | platformBrowserDynamic().bootstrapModule(AppModule); 6 | -------------------------------------------------------------------------------- /connect/src/assets/icon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/connect/src/assets/icon/favicon.ico -------------------------------------------------------------------------------- /connect/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /connect/src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Ionic", 3 | "short_name": "Ionic", 4 | "start_url": "index.html", 5 | "display": "standalone", 6 | "icons": [{ 7 | "src": "assets/imgs/logo.png", 8 | "sizes": "512x512", 9 | "type": "image/png" 10 | }], 11 | "background_color": "#4e8ef7", 12 | "theme_color": "#4e8ef7" 13 | } -------------------------------------------------------------------------------- /connect/src/pages/detail/detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ peripheral.name || 'Device' }} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{ peripheral.name || 'Unnamed' }} 12 | 13 | 14 | {{ peripheral.id }} 15 | 16 | 17 | 18 | 19 | 20 | Services 21 | 22 | 23 | 24 | 25 | {{service}} 26 | 27 | 28 | 29 | 30 | 31 | 32 | Details 33 | 34 | 35 |
{{peripheral | json }}
36 |
37 |
38 |
39 | 40 | 41 | 42 |

{{ statusMessage }}

43 |
44 |
45 | -------------------------------------------------------------------------------- /connect/src/pages/detail/detail.scss: -------------------------------------------------------------------------------- 1 | page-detail { 2 | .toolbar-content p { 3 | margin-left: 10px; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /connect/src/pages/detail/detail.ts: -------------------------------------------------------------------------------- 1 | import { Component, NgZone } from '@angular/core'; 2 | import { NavController, NavParams } from 'ionic-angular'; 3 | import { ToastController } from 'ionic-angular'; 4 | import { BLE } from '@ionic-native/ble'; 5 | 6 | @Component({ 7 | selector: 'page-detail', 8 | templateUrl: 'detail.html', 9 | }) 10 | export class DetailPage { 11 | 12 | peripheral: any = {}; 13 | statusMessage: string; 14 | 15 | constructor(public navCtrl: NavController, 16 | public navParams: NavParams, 17 | private ble: BLE, 18 | private toastCtrl: ToastController, 19 | private ngZone: NgZone) { 20 | 21 | let device = navParams.get('device'); 22 | 23 | this.setStatus('Connecting to ' + device.name || device.id); 24 | 25 | this.ble.connect(device.id).subscribe( 26 | peripheral => this.onConnected(peripheral), 27 | peripheral => this.onDeviceDisconnected(peripheral) 28 | ); 29 | 30 | } 31 | 32 | onConnected(peripheral) { 33 | this.ngZone.run(() => { 34 | this.setStatus(''); 35 | this.peripheral = peripheral; 36 | }); 37 | } 38 | 39 | onDeviceDisconnected(peripheral) { 40 | let toast = this.toastCtrl.create({ 41 | message: 'The peripheral unexpectedly disconnected', 42 | duration: 3000, 43 | position: 'middle' 44 | }); 45 | toast.present(); 46 | } 47 | 48 | // Disconnect peripheral when leaving the page 49 | ionViewWillLeave() { 50 | console.log('ionViewWillLeave disconnecting Bluetooth'); 51 | this.ble.disconnect(this.peripheral.id).then( 52 | () => console.log('Disconnected ' + JSON.stringify(this.peripheral)), 53 | () => console.log('ERROR disconnecting ' + JSON.stringify(this.peripheral)) 54 | ) 55 | } 56 | 57 | setStatus(message) { 58 | console.log(message); 59 | this.ngZone.run(() => { 60 | this.statusMessage = message; 61 | }); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /connect/src/pages/home/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BLE Connect 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 |

{{ statusMessage }}

27 |
28 |
29 | -------------------------------------------------------------------------------- /connect/src/pages/home/home.scss: -------------------------------------------------------------------------------- 1 | page-home { 2 | .toolbar-content p { 3 | margin-left: 10px; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /connect/src/pages/home/home.ts: -------------------------------------------------------------------------------- 1 | import { BLE } from '@ionic-native/ble'; 2 | import { Component, NgZone } from '@angular/core'; 3 | import { NavController } from 'ionic-angular'; 4 | import { ToastController } from 'ionic-angular'; 5 | import { DetailPage } from '../detail/detail'; 6 | 7 | @Component({ 8 | selector: 'page-home', 9 | templateUrl: 'home.html' 10 | }) 11 | export class HomePage { 12 | 13 | devices: any[] = []; 14 | statusMessage: string; 15 | 16 | constructor(public navCtrl: NavController, 17 | private toastCtrl: ToastController, 18 | private ble: BLE, 19 | private ngZone: NgZone) { 20 | } 21 | 22 | ionViewDidEnter() { 23 | console.log('ionViewDidEnter'); 24 | this.scan(); 25 | } 26 | 27 | scan() { 28 | this.setStatus('Scanning for Bluetooth LE Devices'); 29 | this.devices = []; // clear list 30 | 31 | this.ble.scan([], 5).subscribe( 32 | device => this.onDeviceDiscovered(device), 33 | error => this.scanError(error) 34 | ); 35 | 36 | setTimeout(this.setStatus.bind(this), 5000, 'Scan complete'); 37 | } 38 | 39 | onDeviceDiscovered(device) { 40 | console.log('Discovered ' + JSON.stringify(device, null, 2)); 41 | this.ngZone.run(() => { 42 | this.devices.push(device); 43 | }); 44 | } 45 | 46 | // If location permission is denied, you'll end up here 47 | scanError(error) { 48 | this.setStatus('Error ' + error); 49 | let toast = this.toastCtrl.create({ 50 | message: 'Error scanning for Bluetooth low energy devices', 51 | position: 'middle', 52 | duration: 5000 53 | }); 54 | toast.present(); 55 | } 56 | 57 | setStatus(message) { 58 | console.log(message); 59 | this.ngZone.run(() => { 60 | this.statusMessage = message; 61 | }); 62 | } 63 | 64 | deviceSelected(device) { 65 | console.log(JSON.stringify(device) + ' selected'); 66 | this.navCtrl.push(DetailPage, { 67 | device: device 68 | }); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /connect/src/service-worker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Check out https://googlechrome.github.io/sw-toolbox/ for 3 | * more info on how to use sw-toolbox to custom configure your service worker. 4 | */ 5 | 6 | 7 | 'use strict'; 8 | importScripts('./build/sw-toolbox.js'); 9 | 10 | self.toolbox.options.cache = { 11 | name: 'ionic-cache' 12 | }; 13 | 14 | // pre-cache our key assets 15 | self.toolbox.precache( 16 | [ 17 | './build/main.js', 18 | './build/main.css', 19 | './build/polyfills.js', 20 | 'index.html', 21 | 'manifest.json' 22 | ] 23 | ); 24 | 25 | // dynamically cache any other local assets 26 | self.toolbox.router.any('/*', self.toolbox.cacheFirst); 27 | 28 | // for any other requests go to the network, cache, 29 | // and then only use that cached resource if your user goes offline 30 | self.toolbox.router.default = self.toolbox.networkFirst; 31 | -------------------------------------------------------------------------------- /connect/src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/v2/theming/ 3 | 4 | // Font path is used to include ionicons, 5 | // roboto, and noto sans fonts 6 | $font-path: "../assets/fonts"; 7 | 8 | 9 | // The app direction is used to include 10 | // rtl styles in your app. For more info, please see: 11 | // http://ionicframework.com/docs/theming/rtl-support/ 12 | $app-direction: ltr; 13 | 14 | 15 | @import "ionic.globals"; 16 | 17 | 18 | // Shared Variables 19 | // -------------------------------------------------- 20 | // To customize the look and feel of this app, you can override 21 | // the Sass variables found in Ionic's source scss files. 22 | // To view all the possible Ionic variables, see: 23 | // http://ionicframework.com/docs/v2/theming/overriding-ionic-variables/ 24 | 25 | 26 | 27 | 28 | // Named Color Variables 29 | // -------------------------------------------------- 30 | // Named colors makes it easy to reuse colors on various components. 31 | // It's highly recommended to change the default colors 32 | // to match your app's branding. Ionic uses a Sass map of 33 | // colors so you can add, rename and remove colors as needed. 34 | // The "primary" color is the only required color in the map. 35 | 36 | $colors: ( 37 | primary: #488aff, 38 | secondary: #32db64, 39 | danger: #f53d3d, 40 | light: #f4f4f4, 41 | dark: #222 42 | ); 43 | 44 | 45 | // App iOS Variables 46 | // -------------------------------------------------- 47 | // iOS only Sass variables can go here 48 | 49 | 50 | 51 | 52 | // App Material Design Variables 53 | // -------------------------------------------------- 54 | // Material Design only Sass variables can go here 55 | 56 | 57 | 58 | 59 | // App Windows Variables 60 | // -------------------------------------------------- 61 | // Windows only Sass variables can go here 62 | 63 | 64 | 65 | 66 | // App Theme 67 | // -------------------------------------------------- 68 | // Ionic apps can have different themes applied, which can 69 | // then be future customized. This import comes last 70 | // so that the above variables are used and Ionic's 71 | // default are overridden. 72 | 73 | @import "ionic.theme.default"; 74 | 75 | 76 | // Ionicons 77 | // -------------------------------------------------- 78 | // The premium icon font for Ionic. For more info, please see: 79 | // http://ionicframework.com/docs/v2/ionicons/ 80 | 81 | @import "ionic.ionicons"; 82 | 83 | 84 | // Fonts 85 | // -------------------------------------------------- 86 | 87 | @import "roboto"; 88 | @import "noto-sans"; 89 | -------------------------------------------------------------------------------- /connect/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "declaration": false, 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "lib": [ 8 | "dom", 9 | "es2015" 10 | ], 11 | "module": "es2015", 12 | "moduleResolution": "node", 13 | "sourceMap": true, 14 | "target": "es5" 15 | }, 16 | "include": [ 17 | "src/**/*.ts" 18 | ], 19 | "exclude": [ 20 | "node_modules" 21 | ], 22 | "compileOnSave": false, 23 | "atom": { 24 | "rewriteTsconfig": false 25 | } 26 | } -------------------------------------------------------------------------------- /connect/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-duplicate-variable": true, 4 | "no-unused-variable": [ 5 | true 6 | ] 7 | }, 8 | "rulesDirectory": [ 9 | "node_modules/tslint-eslint-rules/dist/rules" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /light/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 2 9 | 10 | # We recommend you to keep these unchanged 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /light/.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .sass-cache/ 17 | .tmp/ 18 | .versions/ 19 | coverage/ 20 | dist/ 21 | node_modules/ 22 | tmp/ 23 | temp/ 24 | hooks/ 25 | platforms/ 26 | plugins/ 27 | plugins/android.json 28 | plugins/ios.json 29 | www/ 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | -------------------------------------------------------------------------------- /light/README.md: -------------------------------------------------------------------------------- 1 | # Ionic3 Bluetooth Low Energy Light 2 | 3 | Control RoboSmart Bluetooth light bulbs (or the Arduino equivalent) with your phone. 4 | 5 | This example builds on the Connect example. 6 | 7 | ## Ionic 3 8 | 9 | This project requires Ionic3 10 | 11 | npm install -g ionic@latest 12 | 13 | Install Cordova just to be safe 14 | 15 | npm install -g cordova@latest 16 | 17 | 18 | ## iOS 19 | 20 | Assuming you have Xcode installed 21 | 22 | ionic cordova run ios --device 23 | 24 | Note: You might need to open Xcode and set the Team for code signing. 25 | 26 | ## Android 27 | 28 | Assuming you have the Android SDK installed 29 | 30 | ionic cordova run android --device 31 | -------------------------------------------------------------------------------- /light/ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Light", 3 | "app_id": "com.example.ble.light", 4 | "type": "ionic-angular", 5 | "integrations": { 6 | "cordova": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /light/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-ble-light", 3 | "version": "0.0.1", 4 | "author": "Don Coleman", 5 | "homepage": "http://github.com/don", 6 | "private": true, 7 | "scripts": { 8 | "clean": "ionic-app-scripts clean", 9 | "build": "ionic-app-scripts build", 10 | "lint": "ionic-app-scripts lint", 11 | "ionic:build": "ionic-app-scripts build", 12 | "ionic:serve": "ionic-app-scripts serve" 13 | }, 14 | "dependencies": { 15 | "@angular/common": "4.1.3", 16 | "@angular/compiler": "4.1.3", 17 | "@angular/compiler-cli": "4.1.3", 18 | "@angular/core": "4.1.3", 19 | "@angular/forms": "4.1.3", 20 | "@angular/http": "4.1.3", 21 | "@angular/platform-browser": "4.1.3", 22 | "@angular/platform-browser-dynamic": "4.1.3", 23 | "@ionic-native/ble": "^4.0.0", 24 | "@ionic-native/core": "3.12.1", 25 | "@ionic-native/splash-screen": "3.12.1", 26 | "@ionic-native/status-bar": "3.12.1", 27 | "@ionic/storage": "2.0.1", 28 | "cordova-plugin-ble-central": "^1.1.4", 29 | "cordova-plugin-compat": "^1.2.0", 30 | "cordova-plugin-console": "^1.1.0", 31 | "cordova-plugin-device": "^1.1.7", 32 | "cordova-plugin-splashscreen": "^4.1.0", 33 | "cordova-plugin-statusbar": "^2.3.0", 34 | "cordova-plugin-whitelist": "^1.3.3", 35 | "ionic-angular": "3.5.0", 36 | "ionic-plugin-keyboard": "^2.2.1", 37 | "ionicons": "3.0.0", 38 | "rxjs": "5.4.0", 39 | "sw-toolbox": "3.6.0", 40 | "zone.js": "0.8.12", 41 | "cordova-ios": "~4.5.4", 42 | "cordova-android": "~6.3.0" 43 | }, 44 | "devDependencies": { 45 | "@ionic/app-scripts": "2.0.1", 46 | "typescript": "2.3.4" 47 | }, 48 | "description": "An Ionic project", 49 | "cordova": { 50 | "plugins": { 51 | "cordova-plugin-ble-central": { 52 | "BLUETOOTH_USAGE_DESCRIPTION": " " 53 | }, 54 | "cordova-plugin-console": {}, 55 | "cordova-plugin-device": {}, 56 | "cordova-plugin-splashscreen": {}, 57 | "cordova-plugin-statusbar": {}, 58 | "cordova-plugin-whitelist": {}, 59 | "ionic-plugin-keyboard": {} 60 | }, 61 | "platforms": [ 62 | "ios", 63 | "android" 64 | ] 65 | } 66 | } -------------------------------------------------------------------------------- /light/resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /light/resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /light/resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /light/resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /light/resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /light/resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /light/resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /light/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/icon.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /light/resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /light/resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /light/resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/resources/splash.png -------------------------------------------------------------------------------- /light/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Platform } from 'ionic-angular'; 3 | import { StatusBar } from '@ionic-native/status-bar'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | 6 | import { HomePage } from '../pages/home/home'; 7 | @Component({ 8 | templateUrl: 'app.html' 9 | }) 10 | export class MyApp { 11 | rootPage:any = HomePage; 12 | 13 | constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 14 | platform.ready().then(() => { 15 | // Okay, so the platform is ready and our plugins are available. 16 | // Here you can do any higher level native things you might need. 17 | statusBar.styleDefault(); 18 | splashScreen.hide(); 19 | }); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /light/src/app/app.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /light/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { ErrorHandler, NgModule } from '@angular/core'; 3 | import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | import { StatusBar } from '@ionic-native/status-bar'; 6 | import { BLE } from '@ionic-native/ble'; 7 | 8 | import { MyApp } from './app.component'; 9 | import { HomePage } from '../pages/home/home'; 10 | import { DetailPage } from '../pages/detail/detail'; 11 | 12 | @NgModule({ 13 | declarations: [ 14 | MyApp, 15 | HomePage, 16 | DetailPage 17 | ], 18 | imports: [ 19 | BrowserModule, 20 | IonicModule.forRoot(MyApp) 21 | ], 22 | bootstrap: [IonicApp], 23 | entryComponents: [ 24 | MyApp, 25 | HomePage, 26 | DetailPage 27 | ], 28 | providers: [ 29 | StatusBar, 30 | SplashScreen, 31 | {provide: ErrorHandler, useClass: IonicErrorHandler}, 32 | BLE 33 | ] 34 | }) 35 | export class AppModule {} 36 | -------------------------------------------------------------------------------- /light/src/app/app.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Global Sass 5 | // -------------------------------------------------- 6 | // Put style rules here that you want to apply globally. These 7 | // styles are for the entire app and not just one component. 8 | // Additionally, this file can be also used as an entry point 9 | // to import other Sass files to be included in the output CSS. 10 | // 11 | // Shared Sass variables, which can be used to adjust Ionic's 12 | // default Sass variables, belong in "theme/variables.scss". 13 | // 14 | // To declare rules for a specific mode, create a child rule 15 | // for the .md, .ios, or .wp mode classes. The mode class is 16 | // automatically applied to the element in the app. 17 | -------------------------------------------------------------------------------- /light/src/app/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | 3 | import { AppModule } from './app.module'; 4 | 5 | platformBrowserDynamic().bootstrapModule(AppModule); 6 | -------------------------------------------------------------------------------- /light/src/assets/icon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/light/src/assets/icon/favicon.ico -------------------------------------------------------------------------------- /light/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /light/src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Ionic", 3 | "short_name": "Ionic", 4 | "start_url": "index.html", 5 | "display": "standalone", 6 | "icons": [{ 7 | "src": "assets/imgs/logo.png", 8 | "sizes": "512x512", 9 | "type": "image/png" 10 | }], 11 | "background_color": "#4e8ef7", 12 | "theme_color": "#4e8ef7" 13 | } -------------------------------------------------------------------------------- /light/src/pages/detail/detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ peripheral.name || 'Device' }} 4 | 5 | 6 | 7 | 8 | 9 | 10 | Power 11 | 12 | 13 | 14 | 15 | {{brightness}} 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |

{{ statusMessage }}

27 |
28 |
29 | -------------------------------------------------------------------------------- /light/src/pages/detail/detail.scss: -------------------------------------------------------------------------------- 1 | page-detail { 2 | .toolbar-content p { 3 | margin-left: 10px; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /light/src/pages/home/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BLE Light 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 |

{{ statusMessage }}

27 |
28 |
29 | -------------------------------------------------------------------------------- /light/src/pages/home/home.scss: -------------------------------------------------------------------------------- 1 | page-home { 2 | .toolbar-content p { 3 | margin-left: 10px; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /light/src/pages/home/home.ts: -------------------------------------------------------------------------------- 1 | import { BLE } from '@ionic-native/ble'; 2 | import { Component, NgZone } from '@angular/core'; 3 | import { NavController } from 'ionic-angular'; 4 | import { ToastController } from 'ionic-angular'; 5 | import { DetailPage } from '../detail/detail'; 6 | 7 | const LIGHTBULB_SERVICE = 'ff10'; 8 | 9 | @Component({ 10 | selector: 'page-home', 11 | templateUrl: 'home.html' 12 | }) 13 | export class HomePage { 14 | 15 | devices: any[] = []; 16 | statusMessage: string; 17 | 18 | constructor(public navCtrl: NavController, 19 | private toastCtrl: ToastController, 20 | private ble: BLE, 21 | private ngZone: NgZone) { 22 | } 23 | 24 | ionViewDidEnter() { 25 | console.log('ionViewDidEnter'); 26 | this.scan(); 27 | } 28 | 29 | scan() { 30 | this.setStatus('Scanning for Bluetooth LE Devices'); 31 | this.devices = []; // clear list 32 | 33 | this.ble.scan([LIGHTBULB_SERVICE], 5).subscribe( 34 | device => this.onDeviceDiscovered(device), 35 | error => this.scanError(error) 36 | ); 37 | 38 | setTimeout(this.setStatus.bind(this), 5000, 'Scan complete'); 39 | } 40 | 41 | onDeviceDiscovered(device) { 42 | console.log('Discovered ' + JSON.stringify(device, null, 2)); 43 | this.ngZone.run(() => { 44 | this.devices.push(device); 45 | }); 46 | } 47 | 48 | // If location permission is denied, you'll end up here 49 | scanError(error) { 50 | this.setStatus('Error ' + error); 51 | let toast = this.toastCtrl.create({ 52 | message: 'Error scanning for Bluetooth low energy devices', 53 | position: 'middle', 54 | duration: 5000 55 | }); 56 | toast.present(); 57 | } 58 | 59 | setStatus(message) { 60 | console.log(message); 61 | this.ngZone.run(() => { 62 | this.statusMessage = message; 63 | }); 64 | } 65 | 66 | deviceSelected(device) { 67 | console.log(JSON.stringify(device) + ' selected'); 68 | this.navCtrl.push(DetailPage, { 69 | device: device 70 | }); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /light/src/service-worker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Check out https://googlechrome.github.io/sw-toolbox/ for 3 | * more info on how to use sw-toolbox to custom configure your service worker. 4 | */ 5 | 6 | 7 | 'use strict'; 8 | importScripts('./build/sw-toolbox.js'); 9 | 10 | self.toolbox.options.cache = { 11 | name: 'ionic-cache' 12 | }; 13 | 14 | // pre-cache our key assets 15 | self.toolbox.precache( 16 | [ 17 | './build/main.js', 18 | './build/main.css', 19 | './build/polyfills.js', 20 | 'index.html', 21 | 'manifest.json' 22 | ] 23 | ); 24 | 25 | // dynamically cache any other local assets 26 | self.toolbox.router.any('/*', self.toolbox.cacheFirst); 27 | 28 | // for any other requests go to the network, cache, 29 | // and then only use that cached resource if your user goes offline 30 | self.toolbox.router.default = self.toolbox.networkFirst; 31 | -------------------------------------------------------------------------------- /light/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "declaration": false, 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "lib": [ 8 | "dom", 9 | "es2015" 10 | ], 11 | "module": "es2015", 12 | "moduleResolution": "node", 13 | "sourceMap": true, 14 | "target": "es5" 15 | }, 16 | "include": [ 17 | "src/**/*.ts" 18 | ], 19 | "exclude": [ 20 | "node_modules" 21 | ], 22 | "compileOnSave": false, 23 | "atom": { 24 | "rewriteTsconfig": false 25 | } 26 | } -------------------------------------------------------------------------------- /light/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-duplicate-variable": true, 4 | "no-unused-variable": [ 5 | true 6 | ] 7 | }, 8 | "rulesDirectory": [ 9 | "node_modules/tslint-eslint-rules/dist/rules" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /neopixel/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 2 9 | 10 | # We recommend you to keep these unchanged 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /neopixel/.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .sass-cache/ 17 | .tmp/ 18 | .versions/ 19 | coverage/ 20 | dist/ 21 | node_modules/ 22 | tmp/ 23 | temp/ 24 | hooks/ 25 | platforms/ 26 | plugins/ 27 | plugins/android.json 28 | plugins/ios.json 29 | www/ 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | build.json 36 | -------------------------------------------------------------------------------- /neopixel/README.md: -------------------------------------------------------------------------------- 1 | # Ionic3 Bluetooth Low Energy NeoPixel 2 | 3 | Ionic3 port of NeoPixel Lamp from [Make:Bluetooth book](https://www.amazon.com/Make-Bluetooth-Projects-Raspberry-Smartphones/dp/1457187094) 4 | 5 | See https://github.com/MakeBluetooth/ble-neopixel/ 6 | 7 | ## Ionic 3 8 | 9 | This project requires Ionic3 10 | 11 | npm install -g ionic@latest 12 | 13 | Install Cordova just to be safe 14 | 15 | npm install -g cordova@latest 16 | 17 | 18 | ## iOS 19 | 20 | Assuming you have Xcode installed 21 | 22 | ionic cordova run ios --device 23 | 24 | 25 | ## Android 26 | 27 | Assuming you have the Android SDK installed 28 | 29 | ionic cordova run android --device 30 | -------------------------------------------------------------------------------- /neopixel/ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NeoPixel", 3 | "app_id": "com.megster.ionic3.neopixel", 4 | "type": "ionic-angular", 5 | "integrations": { 6 | "cordova": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /neopixel/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic3-neopixel", 3 | "version": "0.0.1", 4 | "author": "Don Coleman", 5 | "homepage": "http://github.com/don", 6 | "private": true, 7 | "scripts": { 8 | "clean": "ionic-app-scripts clean", 9 | "build": "ionic-app-scripts build", 10 | "lint": "ionic-app-scripts lint", 11 | "ionic:build": "ionic-app-scripts build", 12 | "ionic:serve": "ionic-app-scripts serve" 13 | }, 14 | "dependencies": { 15 | "@angular/common": "4.1.3", 16 | "@angular/compiler": "4.1.3", 17 | "@angular/compiler-cli": "4.1.3", 18 | "@angular/core": "4.1.3", 19 | "@angular/forms": "4.1.3", 20 | "@angular/http": "4.1.3", 21 | "@angular/platform-browser": "4.1.3", 22 | "@angular/platform-browser-dynamic": "4.1.3", 23 | "@ionic-native/ble": "^4.0.0", 24 | "@ionic-native/core": "3.12.1", 25 | "@ionic-native/splash-screen": "3.12.1", 26 | "@ionic-native/status-bar": "3.12.1", 27 | "@ionic/storage": "2.0.1", 28 | "cordova-plugin-ble-central": "^1.1.4", 29 | "cordova-plugin-compat": "^1.2.0", 30 | "cordova-plugin-console": "^1.1.0", 31 | "cordova-plugin-device": "^1.1.7", 32 | "cordova-plugin-splashscreen": "^4.1.0", 33 | "cordova-plugin-statusbar": "^2.3.0", 34 | "cordova-plugin-whitelist": "^1.3.3", 35 | "ionic-angular": "3.5.0", 36 | "ionic-plugin-keyboard": "^2.2.1", 37 | "ionicons": "3.0.0", 38 | "rxjs": "5.4.0", 39 | "sw-toolbox": "3.6.0", 40 | "zone.js": "0.8.12", 41 | "cordova-ios": "~4.5.4", 42 | "cordova-android": "~6.3.0" 43 | }, 44 | "devDependencies": { 45 | "@ionic/app-scripts": "2.0.1", 46 | "typescript": "2.3.4" 47 | }, 48 | "description": "An Ionic project", 49 | "cordova": { 50 | "plugins": { 51 | "cordova-plugin-ble-central": { 52 | "BLUETOOTH_USAGE_DESCRIPTION": " " 53 | }, 54 | "cordova-plugin-console": {}, 55 | "cordova-plugin-device": {}, 56 | "cordova-plugin-splashscreen": {}, 57 | "cordova-plugin-statusbar": {}, 58 | "cordova-plugin-whitelist": {}, 59 | "ionic-plugin-keyboard": {} 60 | }, 61 | "platforms": [ 62 | "ios", 63 | "android" 64 | ] 65 | } 66 | } -------------------------------------------------------------------------------- /neopixel/resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /neopixel/resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /neopixel/resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /neopixel/resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /neopixel/resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /neopixel/resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /neopixel/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/icon.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /neopixel/resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /neopixel/resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /neopixel/resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/resources/splash.png -------------------------------------------------------------------------------- /neopixel/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Platform } from 'ionic-angular'; 3 | import { StatusBar } from '@ionic-native/status-bar'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | 6 | import { HomePage } from '../pages/home/home'; 7 | @Component({ 8 | templateUrl: 'app.html' 9 | }) 10 | export class MyApp { 11 | rootPage:any = HomePage; 12 | 13 | constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 14 | platform.ready().then(() => { 15 | // Okay, so the platform is ready and our plugins are available. 16 | // Here you can do any higher level native things you might need. 17 | statusBar.styleDefault(); 18 | splashScreen.hide(); 19 | }); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /neopixel/src/app/app.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /neopixel/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { ErrorHandler, NgModule } from '@angular/core'; 3 | import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | import { StatusBar } from '@ionic-native/status-bar'; 6 | import { BLE } from '@ionic-native/ble'; 7 | 8 | import { MyApp } from './app.component'; 9 | import { HomePage } from '../pages/home/home'; 10 | import { DetailPage } from '../pages/detail/detail'; 11 | 12 | @NgModule({ 13 | declarations: [ 14 | MyApp, 15 | HomePage, 16 | DetailPage 17 | ], 18 | imports: [ 19 | BrowserModule, 20 | IonicModule.forRoot(MyApp) 21 | ], 22 | bootstrap: [IonicApp], 23 | entryComponents: [ 24 | MyApp, 25 | HomePage, 26 | DetailPage 27 | ], 28 | providers: [ 29 | StatusBar, 30 | SplashScreen, 31 | {provide: ErrorHandler, useClass: IonicErrorHandler}, 32 | BLE 33 | ] 34 | }) 35 | export class AppModule {} 36 | -------------------------------------------------------------------------------- /neopixel/src/app/app.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Global Sass 5 | // -------------------------------------------------- 6 | // Put style rules here that you want to apply globally. These 7 | // styles are for the entire app and not just one component. 8 | // Additionally, this file can be also used as an entry point 9 | // to import other Sass files to be included in the output CSS. 10 | // 11 | // Shared Sass variables, which can be used to adjust Ionic's 12 | // default Sass variables, belong in "theme/variables.scss". 13 | // 14 | // To declare rules for a specific mode, create a child rule 15 | // for the .md, .ios, or .wp mode classes. The mode class is 16 | // automatically applied to the element in the app. 17 | -------------------------------------------------------------------------------- /neopixel/src/app/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | 3 | import { AppModule } from './app.module'; 4 | 5 | platformBrowserDynamic().bootstrapModule(AppModule); 6 | -------------------------------------------------------------------------------- /neopixel/src/assets/icon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/neopixel/src/assets/icon/favicon.ico -------------------------------------------------------------------------------- /neopixel/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /neopixel/src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Ionic", 3 | "short_name": "Ionic", 4 | "start_url": "index.html", 5 | "display": "standalone", 6 | "icons": [{ 7 | "src": "assets/imgs/logo.png", 8 | "sizes": "512x512", 9 | "type": "image/png" 10 | }], 11 | "background_color": "#4e8ef7", 12 | "theme_color": "#4e8ef7" 13 | } -------------------------------------------------------------------------------- /neopixel/src/pages/detail/detail.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | {{ peripheral.name || 'Device' }} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Red 19 | 20 | 21 | 22 | 23 | Green 24 | 25 | 26 | 27 | 28 | Blue 29 | 30 | 31 | 32 | 33 | Brightness 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Power 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /neopixel/src/pages/detail/detail.scss: -------------------------------------------------------------------------------- 1 | page-detail { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /neopixel/src/pages/home/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NeoPixel 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 |

{{ statusMessage }}

27 |
28 |
29 | 30 | -------------------------------------------------------------------------------- /neopixel/src/pages/home/home.scss: -------------------------------------------------------------------------------- 1 | page-home { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /neopixel/src/pages/home/home.ts: -------------------------------------------------------------------------------- 1 | import { BLE } from '@ionic-native/ble'; 2 | import { Component, NgZone } from '@angular/core'; 3 | import { NavController, AlertController } from 'ionic-angular'; 4 | 5 | import { DetailPage } from '../detail/detail'; 6 | 7 | const NEOPIXEL_SERVICE = 'ccc0'; 8 | 9 | @Component({ 10 | selector: 'page-home', 11 | templateUrl: 'home.html' 12 | }) 13 | export class HomePage { 14 | 15 | devices: any[] = []; 16 | statusMessage: string; 17 | 18 | constructor(public navCtrl: NavController, 19 | private ble: BLE, 20 | private alertCtrl: AlertController, 21 | private ngZone: NgZone) { 22 | } 23 | 24 | ionViewDidEnter() { 25 | console.log('ionViewDidEnter'); 26 | this.scan(); 27 | } 28 | 29 | scan() { 30 | this.devices = []; // clear existing list 31 | this.ble.scan([NEOPIXEL_SERVICE], 4).subscribe( 32 | device => this.onDiscoveredDevice(device), 33 | e => this.showAlert('Scan Failed', 'Error scanning for BLE devices.') 34 | ); 35 | 36 | console.log('Scanning for Bluetooth LE Devices'); 37 | } 38 | 39 | onDiscoveredDevice(device) { 40 | console.log('Discovered ' + JSON.stringify(device, null, 2)); 41 | this.ngZone.run(() => { 42 | this.devices.push(device); 43 | }); 44 | } 45 | 46 | deviceSelected(device) { 47 | console.log(JSON.stringify(device) + ' selected'); 48 | this.navCtrl.push(DetailPage, { 49 | device: device 50 | }); 51 | } 52 | 53 | setStatus(message) { 54 | console.log(message); 55 | this.ngZone.run(() => { 56 | this.statusMessage = message; 57 | }); 58 | } 59 | 60 | showAlert(title, message) { 61 | let alert = this.alertCtrl.create({ 62 | title: title, 63 | subTitle: message, 64 | buttons: ['OK'] 65 | }); 66 | alert.present(); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /neopixel/src/service-worker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Check out https://googlechrome.github.io/sw-toolbox/ for 3 | * more info on how to use sw-toolbox to custom configure your service worker. 4 | */ 5 | 6 | 7 | 'use strict'; 8 | importScripts('./build/sw-toolbox.js'); 9 | 10 | self.toolbox.options.cache = { 11 | name: 'ionic-cache' 12 | }; 13 | 14 | // pre-cache our key assets 15 | self.toolbox.precache( 16 | [ 17 | './build/main.js', 18 | './build/main.css', 19 | './build/polyfills.js', 20 | 'index.html', 21 | 'manifest.json' 22 | ] 23 | ); 24 | 25 | // dynamically cache any other local assets 26 | self.toolbox.router.any('/*', self.toolbox.cacheFirst); 27 | 28 | // for any other requests go to the network, cache, 29 | // and then only use that cached resource if your user goes offline 30 | self.toolbox.router.default = self.toolbox.networkFirst; 31 | -------------------------------------------------------------------------------- /neopixel/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "declaration": false, 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "lib": [ 8 | "dom", 9 | "es2015" 10 | ], 11 | "module": "es2015", 12 | "moduleResolution": "node", 13 | "sourceMap": true, 14 | "target": "es5" 15 | }, 16 | "include": [ 17 | "src/**/*.ts" 18 | ], 19 | "exclude": [ 20 | "node_modules" 21 | ], 22 | "compileOnSave": false, 23 | "atom": { 24 | "rewriteTsconfig": false 25 | } 26 | } -------------------------------------------------------------------------------- /neopixel/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-duplicate-variable": true, 4 | "no-unused-variable": [ 5 | true 6 | ] 7 | }, 8 | "rulesDirectory": [ 9 | "node_modules/tslint-eslint-rules/dist/rules" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /scan/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 2 9 | 10 | # We recommend you to keep these unchanged 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /scan/.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .sass-cache/ 17 | .tmp/ 18 | .versions/ 19 | coverage/ 20 | dist/ 21 | node_modules/ 22 | tmp/ 23 | temp/ 24 | hooks/ 25 | platforms/ 26 | plugins/ 27 | plugins/android.json 28 | plugins/ios.json 29 | www/ 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | -------------------------------------------------------------------------------- /scan/README.md: -------------------------------------------------------------------------------- 1 | # Ionic3 Bluetooth Low Energy Scan 2 | 3 | Scan for Bluetooth Low Energy devices and display the results in a list. 4 | 5 | ## Ionic 3 6 | 7 | This project requires Ionic3 8 | 9 | npm install -g ionic@latest 10 | 11 | Install Cordova just to be safe 12 | 13 | npm install -g cordova@latest 14 | 15 | ## iOS 16 | 17 | Assuming you have Xcode installed 18 | 19 | ionic cordova run ios --device 20 | 21 | Note: You might need to open Xcode and set the Team for code signing. 22 | 23 | ## Android 24 | 25 | Assuming you have the Android SDK installed 26 | 27 | ionic cordova run android --device 28 | -------------------------------------------------------------------------------- /scan/ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Scan", 3 | "app_id": "com.example.ble.scan", 4 | "type": "ionic-angular", 5 | "integrations": { 6 | "cordova": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /scan/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-ble-scan", 3 | "version": "0.0.1", 4 | "author": "Don Coleman", 5 | "homepage": "http://github.com/don", 6 | "private": true, 7 | "scripts": { 8 | "clean": "ionic-app-scripts clean", 9 | "build": "ionic-app-scripts build", 10 | "lint": "ionic-app-scripts lint", 11 | "ionic:build": "ionic-app-scripts build", 12 | "ionic:serve": "ionic-app-scripts serve" 13 | }, 14 | "dependencies": { 15 | "@angular/common": "4.1.3", 16 | "@angular/compiler": "4.1.3", 17 | "@angular/compiler-cli": "4.1.3", 18 | "@angular/core": "4.1.3", 19 | "@angular/forms": "4.1.3", 20 | "@angular/http": "4.1.3", 21 | "@angular/platform-browser": "4.1.3", 22 | "@angular/platform-browser-dynamic": "4.1.3", 23 | "@ionic-native/ble": "^4.0.0", 24 | "@ionic-native/core": "3.12.1", 25 | "@ionic-native/splash-screen": "3.12.1", 26 | "@ionic-native/status-bar": "3.12.1", 27 | "@ionic/storage": "2.0.1", 28 | "cordova-ios": "~4.5.4", 29 | "cordova-plugin-ble-central": "^1.1.4", 30 | "cordova-plugin-compat": "^1.2.0", 31 | "cordova-plugin-console": "^1.1.0", 32 | "cordova-plugin-device": "^1.1.7", 33 | "cordova-plugin-ionic-webview": "^1.1.16", 34 | "cordova-plugin-splashscreen": "^4.1.0", 35 | "cordova-plugin-statusbar": "^2.3.0", 36 | "cordova-plugin-whitelist": "^1.3.3", 37 | "ionic-angular": "3.5.0", 38 | "ionic-plugin-keyboard": "^2.2.1", 39 | "ionicons": "3.0.0", 40 | "rxjs": "5.4.0", 41 | "sw-toolbox": "3.6.0", 42 | "zone.js": "0.8.12", 43 | "cordova-android": "~6.3.0" 44 | }, 45 | "devDependencies": { 46 | "@ionic/app-scripts": "2.0.1", 47 | "typescript": "2.3.4" 48 | }, 49 | "description": "An Ionic project", 50 | "cordova": { 51 | "plugins": { 52 | "cordova-plugin-ble-central": { 53 | "BLUETOOTH_USAGE_DESCRIPTION": " " 54 | }, 55 | "cordova-plugin-console": {}, 56 | "cordova-plugin-device": {}, 57 | "cordova-plugin-splashscreen": {}, 58 | "cordova-plugin-statusbar": {}, 59 | "cordova-plugin-whitelist": {}, 60 | "ionic-plugin-keyboard": {}, 61 | "cordova-plugin-ionic-webview": {} 62 | }, 63 | "platforms": [ 64 | "ios", 65 | "android" 66 | ] 67 | } 68 | } -------------------------------------------------------------------------------- /scan/resources/README.md: -------------------------------------------------------------------------------- 1 | These are Cordova resources. You can replace icon.png and splash.png and run 2 | `ionic cordova resources` to generate custom icons and splash screens for your 3 | app. See `ionic cordova resources --help` for details. 4 | 5 | Cordova reference documentation: 6 | 7 | - Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html 8 | - Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/ 9 | -------------------------------------------------------------------------------- /scan/resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /scan/resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /scan/resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /scan/resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /scan/resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /scan/resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /scan/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/icon.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-1024.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /scan/resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default@2x~universal~anyany.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default@2x~universal~anyany.png -------------------------------------------------------------------------------- /scan/resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /scan/resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/resources/splash.png -------------------------------------------------------------------------------- /scan/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Platform } from 'ionic-angular'; 3 | import { StatusBar } from '@ionic-native/status-bar'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | 6 | import { HomePage } from '../pages/home/home'; 7 | @Component({ 8 | templateUrl: 'app.html' 9 | }) 10 | export class MyApp { 11 | rootPage:any = HomePage; 12 | 13 | constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 14 | platform.ready().then(() => { 15 | // Okay, so the platform is ready and our plugins are available. 16 | // Here you can do any higher level native things you might need. 17 | statusBar.styleDefault(); 18 | splashScreen.hide(); 19 | }); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /scan/src/app/app.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /scan/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { ErrorHandler, NgModule } from '@angular/core'; 3 | import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | import { StatusBar } from '@ionic-native/status-bar'; 6 | import { BLE } from '@ionic-native/ble'; 7 | 8 | import { MyApp } from './app.component'; 9 | import { HomePage } from '../pages/home/home'; 10 | 11 | @NgModule({ 12 | declarations: [ 13 | MyApp, 14 | HomePage 15 | ], 16 | imports: [ 17 | BrowserModule, 18 | IonicModule.forRoot(MyApp) 19 | ], 20 | bootstrap: [IonicApp], 21 | entryComponents: [ 22 | MyApp, 23 | HomePage 24 | ], 25 | providers: [ 26 | StatusBar, 27 | SplashScreen, 28 | {provide: ErrorHandler, useClass: IonicErrorHandler}, 29 | BLE 30 | ] 31 | }) 32 | export class AppModule {} 33 | -------------------------------------------------------------------------------- /scan/src/app/app.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Global Sass 5 | // -------------------------------------------------- 6 | // Put style rules here that you want to apply globally. These 7 | // styles are for the entire app and not just one component. 8 | // Additionally, this file can be also used as an entry point 9 | // to import other Sass files to be included in the output CSS. 10 | // 11 | // Shared Sass variables, which can be used to adjust Ionic's 12 | // default Sass variables, belong in "theme/variables.scss". 13 | // 14 | // To declare rules for a specific mode, create a child rule 15 | // for the .md, .ios, or .wp mode classes. The mode class is 16 | // automatically applied to the element in the app. 17 | -------------------------------------------------------------------------------- /scan/src/app/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | 3 | import { AppModule } from './app.module'; 4 | 5 | platformBrowserDynamic().bootstrapModule(AppModule); 6 | -------------------------------------------------------------------------------- /scan/src/assets/icon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/scan/src/assets/icon/favicon.ico -------------------------------------------------------------------------------- /scan/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /scan/src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Ionic", 3 | "short_name": "Ionic", 4 | "start_url": "index.html", 5 | "display": "standalone", 6 | "icons": [{ 7 | "src": "assets/imgs/logo.png", 8 | "sizes": "512x512", 9 | "type": "image/png" 10 | }], 11 | "background_color": "#4e8ef7", 12 | "theme_color": "#4e8ef7" 13 | } -------------------------------------------------------------------------------- /scan/src/pages/home/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BLE Scanner 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 |

{{ statusMessage }}

27 |
28 |
-------------------------------------------------------------------------------- /scan/src/pages/home/home.scss: -------------------------------------------------------------------------------- 1 | page-home { 2 | .toolbar-content p { 3 | margin-left: 10px; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /scan/src/pages/home/home.ts: -------------------------------------------------------------------------------- 1 | import { Component, NgZone } from '@angular/core'; 2 | import { NavController } from 'ionic-angular'; 3 | import { ToastController } from 'ionic-angular'; 4 | import { BLE } from '@ionic-native/ble'; 5 | 6 | @Component({ 7 | selector: 'page-home', 8 | templateUrl: 'home.html' 9 | }) 10 | export class HomePage { 11 | 12 | devices: any[] = []; 13 | statusMessage: string; 14 | 15 | constructor(public navCtrl: NavController, 16 | private toastCtrl: ToastController, 17 | private ble: BLE, 18 | private ngZone: NgZone) { 19 | } 20 | 21 | ionViewDidEnter() { 22 | console.log('ionViewDidEnter'); 23 | this.scan(); 24 | } 25 | 26 | scan() { 27 | this.setStatus('Scanning for Bluetooth LE Devices'); 28 | this.devices = []; // clear list 29 | 30 | this.ble.scan([], 5).subscribe( 31 | device => this.onDeviceDiscovered(device), 32 | error => this.scanError(error) 33 | ); 34 | 35 | setTimeout(this.setStatus.bind(this), 5000, 'Scan complete'); 36 | } 37 | 38 | onDeviceDiscovered(device) { 39 | console.log('Discovered ' + JSON.stringify(device, null, 2)); 40 | this.ngZone.run(() => { 41 | this.devices.push(device); 42 | }); 43 | } 44 | 45 | // If location permission is denied, you'll end up here 46 | scanError(error) { 47 | this.setStatus('Error ' + error); 48 | let toast = this.toastCtrl.create({ 49 | message: 'Error scanning for Bluetooth low energy devices', 50 | position: 'middle', 51 | duration: 5000 52 | }); 53 | toast.present(); 54 | } 55 | 56 | setStatus(message) { 57 | console.log(message); 58 | this.ngZone.run(() => { 59 | this.statusMessage = message; 60 | }); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /scan/src/service-worker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Check out https://googlechrome.github.io/sw-toolbox/ for 3 | * more info on how to use sw-toolbox to custom configure your service worker. 4 | */ 5 | 6 | 7 | 'use strict'; 8 | importScripts('./build/sw-toolbox.js'); 9 | 10 | self.toolbox.options.cache = { 11 | name: 'ionic-cache' 12 | }; 13 | 14 | // pre-cache our key assets 15 | self.toolbox.precache( 16 | [ 17 | './build/main.js', 18 | './build/main.css', 19 | './build/polyfills.js', 20 | 'index.html', 21 | 'manifest.json' 22 | ] 23 | ); 24 | 25 | // dynamically cache any other local assets 26 | self.toolbox.router.any('/*', self.toolbox.cacheFirst); 27 | 28 | // for any other requests go to the network, cache, 29 | // and then only use that cached resource if your user goes offline 30 | self.toolbox.router.default = self.toolbox.networkFirst; 31 | -------------------------------------------------------------------------------- /scan/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "declaration": false, 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "lib": [ 8 | "dom", 9 | "es2015" 10 | ], 11 | "module": "es2015", 12 | "moduleResolution": "node", 13 | "sourceMap": true, 14 | "target": "es5" 15 | }, 16 | "include": [ 17 | "src/**/*.ts" 18 | ], 19 | "exclude": [ 20 | "node_modules" 21 | ], 22 | "compileOnSave": false, 23 | "atom": { 24 | "rewriteTsconfig": false 25 | } 26 | } -------------------------------------------------------------------------------- /scan/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-duplicate-variable": true, 4 | "no-unused-variable": [ 5 | true 6 | ] 7 | }, 8 | "rulesDirectory": [ 9 | "node_modules/tslint-eslint-rules/dist/rules" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /thermometer/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 2 9 | 10 | # We recommend you to keep these unchanged 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /thermometer/.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .sass-cache/ 17 | .tmp/ 18 | .versions/ 19 | coverage/ 20 | dist/ 21 | node_modules/ 22 | tmp/ 23 | temp/ 24 | hooks/ 25 | platforms/ 26 | plugins/ 27 | plugins/android.json 28 | plugins/ios.json 29 | www/ 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | -------------------------------------------------------------------------------- /thermometer/README.md: -------------------------------------------------------------------------------- 1 | # Ionic3 Bluetooth Low Energy Thermometer 2 | 3 | Get the temperature from a for Bluetooth Low Energy thermometer. 4 | 5 | ## Ionic 3 6 | 7 | This project requires Ionic3 8 | 9 | npm install -g ionic@latest 10 | 11 | Install Cordova just to be safe 12 | 13 | npm install -g cordova@latest 14 | 15 | ## iOS 16 | 17 | Assuming you have Xcode installed 18 | 19 | ionic cordova run ios --device 20 | 21 | Note: You might need to open Xcode and set the Team for code signing. 22 | 23 | ## Android 24 | 25 | Assuming you have the Android SDK installed 26 | 27 | ionic cordova run android --device 28 | 29 | -------------------------------------------------------------------------------- /thermometer/ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Thermometer", 3 | "app_id": "com.example.ble.thermometer", 4 | "type": "ionic-angular", 5 | "integrations": { 6 | "cordova": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /thermometer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic3-ble-thermometer", 3 | "version": "0.0.1", 4 | "author": "Don Coleman", 5 | "homepage": "http://github.com/don", 6 | "private": true, 7 | "scripts": { 8 | "clean": "ionic-app-scripts clean", 9 | "build": "ionic-app-scripts build", 10 | "lint": "ionic-app-scripts lint", 11 | "ionic:build": "ionic-app-scripts build", 12 | "ionic:serve": "ionic-app-scripts serve" 13 | }, 14 | "dependencies": { 15 | "@angular/common": "4.1.3", 16 | "@angular/compiler": "4.1.3", 17 | "@angular/compiler-cli": "4.1.3", 18 | "@angular/core": "4.1.3", 19 | "@angular/forms": "4.1.3", 20 | "@angular/http": "4.1.3", 21 | "@angular/platform-browser": "4.1.3", 22 | "@angular/platform-browser-dynamic": "4.1.3", 23 | "@ionic-native/ble": "^4.0.1", 24 | "@ionic-native/core": "3.12.1", 25 | "@ionic-native/splash-screen": "3.12.1", 26 | "@ionic-native/status-bar": "3.12.1", 27 | "@ionic/storage": "2.0.1", 28 | "cordova-plugin-ble-central": "^1.1.4", 29 | "cordova-plugin-compat": "^1.2.0", 30 | "cordova-plugin-console": "^1.1.0", 31 | "cordova-plugin-device": "^1.1.7", 32 | "cordova-plugin-splashscreen": "^4.1.0", 33 | "cordova-plugin-statusbar": "^2.3.0", 34 | "cordova-plugin-whitelist": "^1.3.3", 35 | "ionic-angular": "3.5.3", 36 | "ionic-plugin-keyboard": "^2.2.1", 37 | "ionicons": "3.0.0", 38 | "rxjs": "5.4.0", 39 | "sw-toolbox": "3.6.0", 40 | "zone.js": "0.8.12", 41 | "cordova-ios": "~4.5.4", 42 | "cordova-android": "~6.3.0" 43 | }, 44 | "devDependencies": { 45 | "@ionic/app-scripts": "2.0.2", 46 | "typescript": "2.3.4" 47 | }, 48 | "description": "An Ionic project", 49 | "cordova": { 50 | "plugins": { 51 | "cordova-plugin-ble-central": { 52 | "BLUETOOTH_USAGE_DESCRIPTION": " " 53 | }, 54 | "cordova-plugin-console": {}, 55 | "cordova-plugin-device": {}, 56 | "cordova-plugin-splashscreen": {}, 57 | "cordova-plugin-statusbar": {}, 58 | "cordova-plugin-whitelist": {}, 59 | "ionic-plugin-keyboard": {} 60 | }, 61 | "platforms": [ 62 | "ios", 63 | "android" 64 | ] 65 | } 66 | } -------------------------------------------------------------------------------- /thermometer/resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /thermometer/resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /thermometer/resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /thermometer/resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /thermometer/resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /thermometer/resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /thermometer/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/icon.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /thermometer/resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /thermometer/resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /thermometer/resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/resources/splash.png -------------------------------------------------------------------------------- /thermometer/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Platform } from 'ionic-angular'; 3 | import { StatusBar } from '@ionic-native/status-bar'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | 6 | import { HomePage } from '../pages/home/home'; 7 | @Component({ 8 | templateUrl: 'app.html' 9 | }) 10 | export class MyApp { 11 | rootPage:any = HomePage; 12 | 13 | constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 14 | platform.ready().then(() => { 15 | // Okay, so the platform is ready and our plugins are available. 16 | // Here you can do any higher level native things you might need. 17 | statusBar.styleDefault(); 18 | splashScreen.hide(); 19 | }); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /thermometer/src/app/app.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thermometer/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { ErrorHandler, NgModule } from '@angular/core'; 3 | import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen'; 5 | import { StatusBar } from '@ionic-native/status-bar'; 6 | import { BLE } from '@ionic-native/ble'; 7 | 8 | import { MyApp } from './app.component'; 9 | import { HomePage } from '../pages/home/home'; 10 | import { DetailPage } from '../pages/detail/detail'; 11 | import { FormatTemperaturePipe } from '../pipes/format-temperature/format-temperature'; 12 | import { FormatTemperatureCPipe } from '../pipes/format-temperature-c/format-temperature-c'; 13 | import { FormatTemperatureFPipe } from '../pipes/format-temperature-f/format-temperature-f'; 14 | 15 | @NgModule({ 16 | declarations: [ 17 | MyApp, 18 | HomePage, 19 | DetailPage, 20 | FormatTemperaturePipe, 21 | FormatTemperatureCPipe, 22 | FormatTemperatureFPipe 23 | ], 24 | imports: [ 25 | BrowserModule, 26 | IonicModule.forRoot(MyApp) 27 | ], 28 | bootstrap: [IonicApp], 29 | entryComponents: [ 30 | MyApp, 31 | HomePage, 32 | DetailPage 33 | ], 34 | providers: [ 35 | StatusBar, 36 | SplashScreen, 37 | {provide: ErrorHandler, useClass: IonicErrorHandler}, 38 | BLE 39 | ] 40 | }) 41 | export class AppModule {} 42 | -------------------------------------------------------------------------------- /thermometer/src/app/app.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Global Sass 5 | // -------------------------------------------------- 6 | // Put style rules here that you want to apply globally. These 7 | // styles are for the entire app and not just one component. 8 | // Additionally, this file can be also used as an entry point 9 | // to import other Sass files to be included in the output CSS. 10 | // 11 | // Shared Sass variables, which can be used to adjust Ionic's 12 | // default Sass variables, belong in "theme/variables.scss". 13 | // 14 | // To declare rules for a specific mode, create a child rule 15 | // for the .md, .ios, or .wp mode classes. The mode class is 16 | // automatically applied to the element in the app. 17 | -------------------------------------------------------------------------------- /thermometer/src/app/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | 3 | import { AppModule } from './app.module'; 4 | 5 | platformBrowserDynamic().bootstrapModule(AppModule); 6 | -------------------------------------------------------------------------------- /thermometer/src/assets/icon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/ionic-ble-examples/51ca75b831e6dc87aeb0738b550efa8aa7ffebc4/thermometer/src/assets/icon/favicon.ico -------------------------------------------------------------------------------- /thermometer/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /thermometer/src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Ionic", 3 | "short_name": "Ionic", 4 | "start_url": "index.html", 5 | "display": "standalone", 6 | "icons": [{ 7 | "src": "assets/imgs/logo.png", 8 | "sizes": "512x512", 9 | "type": "image/png" 10 | }], 11 | "background_color": "#4e8ef7", 12 | "theme_color": "#4e8ef7" 13 | } -------------------------------------------------------------------------------- /thermometer/src/pages/detail/detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ peripheral.name || 'Device' }} 4 | 5 | 6 | 7 | 8 | 9 |

{{ temperature | formatTemperatureC }}

10 |

{{ temperature | formatTemperatureF }}

11 |
12 |
13 | 14 | 15 | 16 |

{{ statusMessage }}

17 |
18 |
19 | -------------------------------------------------------------------------------- /thermometer/src/pages/detail/detail.scss: -------------------------------------------------------------------------------- 1 | page-detail { 2 | .toolbar-content p { 3 | margin-left: 10px; 4 | } 5 | 6 | .card { 7 | padding: 20px; 8 | text-align: center; 9 | } 10 | 11 | .card h1 { 12 | font-size: 6em; 13 | } 14 | } -------------------------------------------------------------------------------- /thermometer/src/pages/home/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Thermometer 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 |

{{ statusMessage }}

27 |
28 |
29 | -------------------------------------------------------------------------------- /thermometer/src/pages/home/home.scss: -------------------------------------------------------------------------------- 1 | page-home { 2 | .toolbar-content p { 3 | margin-left: 10px; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /thermometer/src/pages/home/home.ts: -------------------------------------------------------------------------------- 1 | import { BLE } from '@ionic-native/ble'; 2 | import { Component, NgZone } from '@angular/core'; 3 | import { NavController } from 'ionic-angular'; 4 | import { ToastController } from 'ionic-angular'; 5 | import { DetailPage } from '../detail/detail'; 6 | 7 | const THERMOMETER_SERVICE = 'bbb0'; 8 | 9 | @Component({ 10 | selector: 'page-home', 11 | templateUrl: 'home.html' 12 | }) 13 | export class HomePage { 14 | 15 | devices: any[] = []; 16 | statusMessage: string; 17 | 18 | constructor(public navCtrl: NavController, 19 | private toastCtrl: ToastController, 20 | private ble: BLE, 21 | private ngZone: NgZone) { 22 | } 23 | 24 | ionViewDidEnter() { 25 | console.log('ionViewDidEnter'); 26 | this.scan(); 27 | } 28 | 29 | scan() { 30 | this.setStatus('Scanning for Bluetooth LE Devices'); 31 | this.devices = []; // clear list 32 | 33 | this.ble.scan([THERMOMETER_SERVICE], 5).subscribe( 34 | device => this.onDeviceDiscovered(device), 35 | error => this.scanError(error) 36 | ); 37 | 38 | setTimeout(this.setStatus.bind(this), 5000, 'Scan complete'); 39 | } 40 | 41 | onDeviceDiscovered(device) { 42 | console.log('Discovered ' + JSON.stringify(device, null, 2)); 43 | this.ngZone.run(() => { 44 | this.devices.push(device); 45 | }); 46 | } 47 | 48 | // If location permission is denied, you'll end up here 49 | scanError(error) { 50 | this.setStatus('Error ' + error); 51 | let toast = this.toastCtrl.create({ 52 | message: 'Error scanning for Bluetooth low energy devices', 53 | position: 'middle', 54 | duration: 5000 55 | }); 56 | toast.present(); 57 | } 58 | 59 | setStatus(message) { 60 | console.log(message); 61 | this.ngZone.run(() => { 62 | this.statusMessage = message; 63 | }); 64 | } 65 | 66 | deviceSelected(device) { 67 | console.log(JSON.stringify(device) + ' selected'); 68 | this.navCtrl.push(DetailPage, { 69 | device: device 70 | }); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /thermometer/src/pipes/format-temperature-c/format-temperature-c.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | /** 4 | * Take raw Celsius value and return formatted string with °C 5 | * 6 | * See https://angular.io/docs/ts/latest/guide/pipes.html for more info on 7 | * Angular Pipes. 8 | */ 9 | @Pipe({ 10 | name: 'formatTemperatureC', 11 | }) 12 | export class FormatTemperatureCPipe implements PipeTransform { 13 | 14 | transform(celsius: number, ...args) { 15 | if (celsius === undefined) { 16 | return '???'; 17 | } 18 | 19 | return celsius.toFixed(1) + '°C'; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /thermometer/src/pipes/format-temperature-f/format-temperature-f.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | /** 4 | * Take raw Celsius value and return formatted string with as ° Fahrenheit 5 | * 6 | * See https://angular.io/docs/ts/latest/guide/pipes.html for more info on 7 | * Angular Pipes. 8 | */ 9 | @Pipe({ 10 | name: 'formatTemperatureF', 11 | }) 12 | export class FormatTemperatureFPipe implements PipeTransform { 13 | 14 | transform(celsius: number, ...args) { 15 | if (celsius === undefined) { 16 | return '???'; 17 | } 18 | 19 | let fahrenheit = this.toFahrenheit(celsius); 20 | 21 | return fahrenheit.toFixed(1) + '°F'; 22 | 23 | } 24 | 25 | toFahrenheit(celsius: number): number { 26 | var fahrenheit = (celsius * 1.8 + 32.0); 27 | return fahrenheit; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /thermometer/src/pipes/format-temperature/format-temperature.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | /** 4 | * Take raw Celsius value and return formatted string with Celsius and Fahrenheit 5 | */ 6 | @Pipe({ 7 | name: 'formatTemperature', 8 | }) 9 | export class FormatTemperaturePipe implements PipeTransform { 10 | 11 | transform(celsius: number, ...args) { 12 | 13 | if (celsius === undefined) { 14 | return '???'; 15 | } 16 | let fahrenheit = this.toFahrenheit(celsius); 17 | 18 | return celsius.toFixed(1) + '°C ' + fahrenheit.toFixed(1) + '°F'; 19 | } 20 | 21 | toFahrenheit(celsius: number): number { 22 | var fahrenheit = (celsius * 1.8 + 32.0); 23 | return fahrenheit; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /thermometer/src/service-worker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Check out https://googlechrome.github.io/sw-toolbox/ for 3 | * more info on how to use sw-toolbox to custom configure your service worker. 4 | */ 5 | 6 | 7 | 'use strict'; 8 | importScripts('./build/sw-toolbox.js'); 9 | 10 | self.toolbox.options.cache = { 11 | name: 'ionic-cache' 12 | }; 13 | 14 | // pre-cache our key assets 15 | self.toolbox.precache( 16 | [ 17 | './build/main.js', 18 | './build/main.css', 19 | './build/polyfills.js', 20 | 'index.html', 21 | 'manifest.json' 22 | ] 23 | ); 24 | 25 | // dynamically cache any other local assets 26 | self.toolbox.router.any('/*', self.toolbox.cacheFirst); 27 | 28 | // for any other requests go to the network, cache, 29 | // and then only use that cached resource if your user goes offline 30 | self.toolbox.router.default = self.toolbox.networkFirst; 31 | -------------------------------------------------------------------------------- /thermometer/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "declaration": false, 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "lib": [ 8 | "dom", 9 | "es2015" 10 | ], 11 | "module": "es2015", 12 | "moduleResolution": "node", 13 | "sourceMap": true, 14 | "target": "es5" 15 | }, 16 | "include": [ 17 | "src/**/*.ts" 18 | ], 19 | "exclude": [ 20 | "node_modules" 21 | ], 22 | "compileOnSave": false, 23 | "atom": { 24 | "rewriteTsconfig": false 25 | } 26 | } -------------------------------------------------------------------------------- /thermometer/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-duplicate-variable": true, 4 | "no-unused-variable": [ 5 | true 6 | ] 7 | }, 8 | "rulesDirectory": [ 9 | "node_modules/tslint-eslint-rules/dist/rules" 10 | ] 11 | } 12 | --------------------------------------------------------------------------------