This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var peripheral:Peripheral = ...; // Previously connected Peripheral | |
var characteristic:Characteristic = ...; // Discovered Characteristic of interest | |
peripheral.addEventListener( CharacteristicEvent.UPDATE, peripheral_characteristic_updatedHandler ); | |
peripheral.addEventListener( CharacteristicEvent.UPDATE_ERROR, peripheral_characteristic_errorHandler ); | |
peripheral.addEventListener( CharacteristicEvent.SUBSCRIBE, peripheral_characteristic_subscribeHandler ); | |
peripheral.addEventListener( CharacteristicEvent.SUBSCRIBE_ERROR, peripheral_characteristic_subscribeErrorHandler ); | |
peripheral.addEventListener( CharacteristicEvent.UNSUBSCRIBE, peripheral_characteristic_unsubscribeHandler ); | |
if (!peripheral.subscribeToCharacteristic( characteristic )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// These variables for peripheral and characteristic should have | |
// previously been obtained through scanning and discovery functionality | |
var peripheral:Peripheral = ...; | |
var characteristic:Characteristic = ...; | |
peripheral.addEventListener( CharacteristicEvent.WRITE_SUCCESS, peripheral_characteristic_writeHandler ); | |
peripheral.addEventListener( CharacteristicEvent.WRITE_ERROR, peripheral_characteristic_writeErrorHandler ); | |
// Some data to write | |
var value:ByteArray = new ByteArray(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var characteristic:Characteristic = new Characteristic( "E95E787B-9C88-4A8D-9A33-BA63EBC4A3A3" ); | |
var service:Service = new Service(); | |
service.uuid = "90753043-6E40-4590-AFF6-5B48F6412E2F"; | |
service.characteristics.push( characteristic ); | |
// com.distriqt.BluetoothLE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var characteristic:Characteristic = new Characteristic( "E95E787B-9C88-4A8D-9A33-BA63EBC4A3A3" ); | |
var service:Service = new Service(); | |
service.uuid = "90753043-6E40-4590-AFF6-5B48F6412E2F"; | |
service.characteristics.push( characteristic ); | |
BluetoothLE.service.peripheralManager.addEventListener( PeripheralManagerEvent.SERVICE_ADD, peripheral_serviceAddHandler ); | |
BluetoothLE.service.peripheralManager.addEventListener( PeripheralManagerEvent.SERVICE_ADD_ERROR, peripheral_serviceAddErrorHandler ); | |
// Remove all to prevent duplicate services (this only removes services added by this application) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var service:Service = ...; // A previously created and published service | |
BluetoothLE.service.peripheralManager.addEventListener( PeripheralManagerEvent.START_ADVERTISING, peripheral_startAdvertisingHandler ); | |
BluetoothLE.service.peripheralManager.startAdvertising( "distriqt", new <Service>[ service ] ); | |
... | |
private function peripheral_startAdvertisingHandler( event:PeripheralManagerEvent ):void | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var characteristic:Characteristic = ...; // Some characteristic you have created and added to a published service | |
BluetoothLE.service.peripheralManager.addEventListener( RequestEvent.READ, peripheral_readRequestHandler ); | |
... | |
private function peripheral_readRequestHandler( event:RequestEvent ):void | |
{ | |
// | |
// Read requests will only have one object in the requests event |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var characteristic:Characteristic = ...; // Some characteristic you have created and added to a published service | |
BluetoothLE.service.peripheralManager.addEventListener( RequestEvent.WRITE, peripheral_writeRequestHandler ); | |
... | |
private function peripheral_writeRequestHandler( event:RequestEvent ):void | |
{ | |
trace( "peripheral manager: write request: " + event.requests.length ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This assumes you have previously published and advertised services as a peripheral | |
var characteristic:Characteristic = ...; // Some characteristic you have created and added to a published service | |
BluetoothLE.service.peripheralManager.addEventListener( CentralEvent.SUBSCRIBE, peripheral_central_subscribeHandler ); | |
BluetoothLE.service.peripheralManager.addEventListener( CentralEvent.UNSUBSCRIBE, peripheral_central_unsubscribeHandler ); | |
... | |
private function peripheral_central_subscribeHandler( event:CentralEvent ):void | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Notifications.init( APP_KEY ); | |
if (Notifications.isSupported) | |
{ | |
var notification:Notification = new Notification(); | |
notification.tickerText = "Hello"; | |
notification.title = "My Notification"; | |
notification.body = "Hello World"; | |
var scheduled:Date = new Date(2015,12,13, 1,1,1); | |
var now:Date = new Date(); |