Example: Get Raw Value from Daydream Controller
Peripheral
Service
Characteristic
Example (Get Raw Value from Daydream Controller)
About Daydream Controller
Get raw value form Daydream controller
Property
Target
Peripheral Name
Daydream controller
Service UUID
FE55
Characteristic Usage
notify
1. Get CoreBluetoothManager instance
Get shared CoreBluetoothManager instance.
manager = CoreBluetoothManager . Shared ;
manager . OnUpdateState ( ( string state ) =>
{
Debug . Log ( "state: " + state ) ;
if ( state != "poweredOn" ) return ;
manager . StartScan ( ) ;
} ) ;
3. Discover And Connect Daydream Controller
manager . OnDiscoverPeripheral ( ( CoreBluetoothPeripheral peripheral ) =>
{
if ( peripheral . name != "" )
Debug . Log ( "discover peripheral name: " + peripheral . name ) ;
if ( peripheral . name != "Daydream controller" ) return ;
manager . StopScan ( ) ;
manager . ConnectToPeripheral ( peripheral ) ;
} ) ;
4. Discover Services And Characteristic On Connected
manager . OnConnectPeripheral ( ( CoreBluetoothPeripheral peripheral ) =>
{
Debug . Log ( "connected peripheral name: " + peripheral . name ) ;
peripheral . discoverServices ( ) ;
} ) ;
manager . OnDiscoverService ( ( CoreBluetoothService service ) =>
{
Debug . Log ( "discover service uuid: " + service . uuid ) ;
if ( service . uuid != "FE55" ) return ;
service . discoverCharacteristics ( ) ;
} ) ;
manager . OnDiscoverCharacteristic ( ( CoreBluetoothCharacteristic characteristic ) =>
{
string uuid = characteristic . uuid ;
string usage = characteristic . propertis [ 0 ] ;
Debug . Log ( "discover characteristic uuid: " + uuid + ", usage: " + usage ) ;
if ( usage != "notify" ) return ;
characteristic . setNotifyValue ( true ) ;
} ) ;
manager . OnUpdateValue ( ( CoreBluetoothCharacteristic characteristic , byte [ ] data ) =>
{
this . value = data ;
this . flag = true ;
} ) ;
7. Start CoreBluetoothManager
byte [ ] value = { 0x64 , 0x68 } ;
characteristic . Write ( value ) ;
Example for Unity
Unity Version: 2020.3.5
Work on Unity Editor And iOS device
Show raw value from Daydream controller or M5StickC
Peripheral Example for M5StickC (Plus)
Support write and notify
Native Examample for iOS
Show raw value from Daydream controller
Native Examample for macOS
Show raw value from Daydream controller