====== Connect ======
The **Connect** method connects to the Bluetooth device with given **name**.
nxt.Connect( name );
==== Example - auto connect to NXT brick on application start ====
Code by Dave Smart from AndroidScript forum.
//Called when application is started.
function OnStart()
{
//Create our screen layout.
//CreateLayout();
//Create NXT controller object.
nxt = app.CreateNxt();
//Connect to NXT by name.
var deviceName = "myNXTbrick";
var paired = nxt.IsPaired( deviceName );
if (paired)
{
app.ShowProgress( "Connecting to "+deviceName+"..." );
nxt.SetOnConnect( nxt_OnConnect );
nxt.Connect( deviceName );
}
}
//Handle successful brick connection.
function nxt_OnConnect( success, nxt )
{
if( success ) nxt.Beep( 2000, 200 );
else app.Alert( "Failed to connect!" );
app.HideProgress();
}