UART Bluetooth Terminal

321 views
Skip to first unread message

HHBT

unread,
Jun 6, 2021, 2:09:10 AM6/6/21
to DroidScript
Can I build an app like this with Droidscript using uart plug-in?

HHBT

unread,
Jun 6, 2021, 3:57:11 AM6/6/21
to DroidScript
Device connect and no receive data... 

app.LoadPlugin( "BluetoothLE" );

var address1 = "E2:F1:18:93:94:AA";
var conectado = false;
 var sid = "6E400001-B5A3-F393-E0A9-E50E24DCCA9E";  // My Service-ID
 var ctx = "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"; // My Characteristic ID
 var crx = "6E400002-B5A3-F393-E0A9-E50E24DCCA9E"; // My Characteristic ID


function OnStart()
{
  lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

  btn = app.CreateButton( "Connect", 0.4, 0.1 );
  btn2 = app.CreateButton( "Send Something", 0.4, 0.1 );
  
  btn.SetOnTouch( btn_OnTouch );
  btn2.SetOnTouch( OnSend );
  
  lay.AddChild( btn );
  lay.AddChild( btn2 );

  app.AddLayout( lay );

  ble = app.CreateBluetoothLE();
  ble.SetOnConnect(OnConnect);
  ble.SetOnUartReceive(OnUartReceive);
  ble.SetSplitMode( "End", "\n" );
  ble.SetUartMode( "Text" );
  ble.SetUartIds(sid,ctx,crx);
}

function btn_OnTouch()
{
 ble.Connect(address1,"UART");
}

function OnConnect()
{
  app.ShowPopup( "Connected!" );
  conectado = true;
   }

function OnSend()
{
  ble.SendUart("?");
}

function OnUartReceive(data)
{
  app.ShowPopup(data);
}

HHBT

unread,
Jun 6, 2021, 3:59:05 AM6/6/21
to DroidScript
Screenshot_2021-06-06-03-58-14-655_com.smartphoneremote.androidscriptfree.jpg

Dave

unread,
Jun 6, 2021, 8:09:31 AM6/6/21
to DroidScript
You probably need to send "?\n" instead of just "?" as the device will probably need a line/command termination character.

What device are you talking to?

Note:  HC-05, HC-06 devices expect classic Bluetooth not BLE

HHBT

unread,
Jun 6, 2021, 11:02:58 AM6/6/21
to DroidScript
Screenshot_2021-06-06-10-49-52-440_de.kai_morich.serial_bluetooth_terminal.jpg
In simple Bluetooth terminal app, my device works very well. 


Screenshot_2021-06-06-10-49-39-664_de.kai_morich.serial_bluetooth_terminal.jpg
I want just send data to my device with Droidscript app.

Screenshot_2021-06-06-10-58-48-626_no.nordicsemi.android.mcp.jpg
Device information. 

Dave

unread,
Jun 8, 2021, 5:52:56 AM6/8/21
to DroidScript
Looks like you have your Tx and Rx the wrong way round.  They should be opposite to the device you are contacting.

Swap them round and include the '\n' character at the end of your commands.

Hiago Henrique

unread,
Jun 8, 2021, 9:22:16 PM6/8/21
to DroidScript
Yeah! Works fine now!
Reply all
Reply to author
Forward
0 new messages