Created
October 19, 2015 09:04
-
-
Save marchbold/52a155609b61eaafbfd3 to your computer and use it in GitHub Desktop.
Bluetooth LE: Reading the value of a 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
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.readValueForCharacteristic( characteristic ); | |
... | |
private function peripheral_characteristic_updatedHandler( event:CharacteristicEvent ):void | |
{ | |
trace( "peripheral characteristic updated: " + event.characteristic.uuid ); | |
trace( "value="+ event.characteristic.value.readUTFBytes( event.characteristic.value.length ) ); | |
} | |
private function peripheral_characteristic_errorHandler( event:CharacteristicEvent ):void | |
{ | |
trace( "peripheral characteristic error: [" + event.errorCode +"] "+event.error ); | |
} | |
// com.distriqt.BluetoothLE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment