User Tools

Site Tools


built_in:nxt_getbtname

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

built_in:nxt_getbtname [2015/03/11 10:16]
madlyr created GetBtName
built_in:nxt_getbtname [2015/03/11 18:25]
Line 1: Line 1:
-====== GetBtName ====== 
  
-The **GetBtName** function returns Bluetooth name of a connected NXT brick.  
-<code>btName = nxt.GetBtName();</code> 
- 
-====Example - GetBtName / GetBtAddress of connected NXT==== 
-<code javascript> 
-var nxt, lay, btnConnect; 
-function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "VCenter, FillXY" ); 
-  btnConnect = app.CreateButton( "Connect", 0.5, 0.1 ); 
-  btnConnect.SetOnTouch( btnConnect_OnTouch );   
-  lay.AddChild( btnConnect ); 
-  app.AddLayout( lay ); 
-  nxt = app.CreateNxt(); 
-  nxt.SetOnConnected(onNXTConnected); 
-}  
- 
-function onNXTConnected()  
-{ 
-  if (nxt.IsConnected()) { 
-    app.ShowPopup("Connected to: "+nxt.GetBtName()+" : "+nxt.GetBtAddress()); 
-  } 
-} 
- 
-function btnConnect_OnTouch() 
-{         
-  if (!nxt.IsConnected()) { 
-    //Show list of NXT devices. 
-    nxt.ShowDevices(); 
-  } 
-} 
-</code> 
built_in/nxt_getbtname.txt · Last modified: 2015/03/11 18:25 (external edit)