This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
built_in:bluetoothserial [2014/12/18 20:21] bcarroll created |
built_in:bluetoothserial [2015/03/22 13:49] octazid completed |
||
---|---|---|---|
Line 2: | Line 2: | ||
===== Methods ===== | ===== Methods ===== | ||
- | ^Method ^Description ^ | + | ^ Method |
- | |BluetoothSerial.Connect( name, | + | | BluetoothSerial.Clear() |
- | |BluetoothSerial.Write( p1 ) | | | + | | BluetoothSerial.Connect( name, |
- | |BluetoothSerial.SetOnReceive( p1 ) | | | + | | 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 ); | ||
+ | } | ||
+ | </ |