This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
built_in:bluetoothserial [2014/12/18 21:35] bcarroll [Methods] |
built_in:bluetoothserial [2019/02/25 06:32] stevegarman Add modes |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== BluetoothSerial control ====== | ====== BluetoothSerial control ====== | ||
+ | ===== Syntax ===== | ||
+ | app.CreateBluetoothSerial(mode) | ||
+ | Possible modes are | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
===== Methods ===== | ===== Methods ===== | ||
- | ^Method ^Description ^ | + | ^ Method |
- | |BluetoothSerial.Connect( name, | + | | BluetoothSerial.Clear() |
- | |BluetoothSerial.SetOnConnect( p1 ) | | | + | | BluetoothSerial.Connect( name, |
- | |BluetoothSerial.Disconnect() | | | + | | BluetoothSerial.Disconnect() |
- | |BluetoothSerial.IsBluetoothEnabled() | | | + | | BluetoothSerial.IsBluetoothEnabled() |
- | |BluetoothSerial.RequestEnable() | | | + | | BluetoothSerial.IsConnected() |
- | |BluetoothSerial.IsPaired( p1 ) | | | + | | BluetoothSerial.IsPaired( p1 ) | | |
- | |BluetoothSerial.IsConnected() | | | + | | BluetoothSerial.RequestEnable() |
- | |BluetoothSerial.Write( p1 ) | | | + | | BluetoothSerial.SetOnConnect( callback |
- | |BluetoothSerial.SetOnReceive( | + | | BluetoothSerial.SetOnReceive( |
- | |BluetoothSerial.SetSplitMode( p1,p2,p3 ) | | | + | | BluetoothSerial.SetSplitMode( p1,p2,p3 ) | | |
- | |BluetoothSerial.SetTimeout( p1 ) | | | + | | BluetoothSerial.SetTimeout( p1 ) | | |
- | |BluetoothSerial.Clear() | | | + | | 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 ); | ||
+ | } | ||
+ | </ |