This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
built_in:bluetoothserial [2015/03/22 08:43] octazid [Table] |
built_in:bluetoothserial [2015/03/22 13:49] octazid completed |
||
---|---|---|---|
Line 15: | Line 15: | ||
| 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 ); | ||
+ | } | ||
+ | </ |