DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools


Sidebar

News

Version1.42 is out since December 2nd 2016


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

built_in:bluetoothserial

BluetoothSerial control

Methods

Method Description
BluetoothSerial.Clear()
BluetoothSerial.Connect( name,channel )
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)

//Called when application is started. 
function OnStart() 
{ 
	//Create a layout with objects vertically centered. 
	lay = app.CreateLayout( "linear", "VCenter,FillXY" );	 
 
	//Create a button 1/3 of screen width and 1/4 screen height. 
	btn = app.CreateButton( "Connect", 0.4, 0.15 ); 
	btn.SetOnTouch( btn_OnTouch ); 
	lay.AddChild( btn ); 
	app.AddLayout( lay ); 
 
	//Create Bluetooth serial object. 
	bt = app.CreateBluetoothSerial(); 
	bt.SetOnConnect( bt_OnConnect ) 
	bt.SetOnReceive( bt_OnReceive ); 
	bt.SetSplitMode( "End", "\n" ); 
} 
 
//Called when user touches the button. 
function btn_OnTouch()  
{ 
    bt.Connect( "HC-05" ); 
} 
 
//Called when we are connected. 
function bt_OnConnect( ok ) 
{ 
    if( ok ) bt.Write( "digitalWrite(LED1,1);\n" ); 
    else app.ShowPopup( "Failed to connect!" ); 
} 
 
//Called when we get data from device. 
function bt_OnReceive( data ) 
{ 
    app.ShowPopup( data ); 
} 
built_in/bluetoothserial.txt · Last modified: 2015/03/22 13:49 by octazid