This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
built_in:bluetoothserial [2015/03/22 08:43] octazid [Table] |
built_in:bluetoothserial [2019/02/25 14:32] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== BluetoothSerial control ====== | ====== BluetoothSerial control ====== | ||
+ | ===== Syntax ===== | ||
+ | app.CreateBluetoothSerial(mode) | ||
+ | Possible modes are | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
===== Methods ===== | ===== Methods ===== | ||
^ Method | ^ Method | ||
Line 15: | Line 21: | ||
| BluetoothSerial.SetTimeout( p1 ) | | | | BluetoothSerial.SetTimeout( p1 ) | | | ||
| BluetoothSerial.Write( 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 ); | ||
+ | } | ||
+ | </ |