This shows you the differences between two versions of the page.
built_in:bluetoothserial [2015/03/22 13:49] octazid completed |
built_in:bluetoothserial [2019/02/25 14:32] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== BluetoothSerial control ====== | ||
- | ===== Methods ===== | ||
- | ^ Method | ||
- | | BluetoothSerial.Clear() | ||
- | | BluetoothSerial.Connect( name, | ||
- | | BluetoothSerial.Disconnect() | ||
- | | BluetoothSerial.IsBluetoothEnabled() | ||
- | | BluetoothSerial.IsConnected() | ||
- | | BluetoothSerial.IsPaired( p1 ) | | | ||
- | | BluetoothSerial.RequestEnable() | ||
- | | BluetoothSerial.SetOnConnect( callback ) | | | ||
- | | BluetoothSerial.SetOnReceive( callback ) | | | ||
- | | BluetoothSerial.SetSplitMode( p1,p2,p3 ) | | | ||
- | | BluetoothSerial.SetTimeout( p1 ) | | | ||
- | | BluetoothSerial.Write( p1 ) | ||
- | |||
- | =====Example===== | ||
- | //(Example taken from the DroidScript sample section)// | ||
- | |||
- | <code javascript> | ||
- | // | ||
- | function OnStart() | ||
- | { | ||
- | // | ||
- | lay = app.CreateLayout( " | ||
- | |||
- | // | ||
- | btn = app.CreateButton( " | ||
- | btn.SetOnTouch( btn_OnTouch ); | ||
- | lay.AddChild( btn ); | ||
- | app.AddLayout( lay ); | ||
- | |||
- | // | ||
- | bt = app.CreateBluetoothSerial(); | ||
- | bt.SetOnConnect( bt_OnConnect ) | ||
- | bt.SetOnReceive( bt_OnReceive ); | ||
- | bt.SetSplitMode( " | ||
- | } | ||
- | |||
- | // | ||
- | function btn_OnTouch() | ||
- | { | ||
- | bt.Connect( " | ||
- | } | ||
- | |||
- | // | ||
- | function bt_OnConnect( ok ) | ||
- | { | ||
- | if( ok ) bt.Write( " | ||
- | else app.ShowPopup( " | ||
- | } | ||
- | |||
- | // | ||
- | function bt_OnReceive( data ) | ||
- | { | ||
- | app.ShowPopup( data ); | ||
- | } | ||
- | </ |