Yes you can use the "Hex" mode of the Bluetooth serial component. Here is an example class I wrote to control a "FlowPaw" Bluetooth module from DroidScript Apps:-
function FlowPaw()
{
//Private variables.
var onConnect, onButtons;
var buttons = [false,false,false,false];
var lastBtns = 0;
//Initialise the object (constructor).
var bt = app.CreateBluetoothSerial("hex");
bt.SetOnConnect( _Cb(this,"OnConnect") );
bt.SetOnReceive( _Cb(this,"OnData") );
//Use EOF+data header as delimeter because this is more
//reliable than using fixed data size if we get out of sync.
bt.SetSplitMode( "End", "23452342" );
//bt.SetSplitMode( "Size", 64+1 );
//Callbacks setters.
this.SetOnConnect = function( cb ) { onConnect = cb; }
this.SetOnButtons = function( cb ) { onButtons = cb; }
//Connect to BT module.
this.Connect = function( btName )
{
bt.Connect( btName );
}
//Handle connection.
this.OnConnect = function( ok )
{
if( ok )
{
//PI mode - only speak when spoken to.
//bt.Write("23,51,23,45");
//Setup buzzer on claw 1.
bt.Write( "23,58,01,01,23,45" );
}
//Fire users callback if set.
if( onConnect ) onConnect( ok );
}
//Handle data from device.
this.OnData = function( data )
{
data = data.split(",");
//console.log( data );
//Read buttons states.
var btns = parseInt("0x"+data[0]);
buttons[0] = (btns & 1) > 0 ? 1 : 0;
buttons[1] = (btns & 2) > 0 ? 1 : 0;
buttons[2] = (btns & 4) > 0 ? 1 : 0;
buttons[3] = (btns & 8) > 0 ? 1 : 0;
//Fire button callback if required.
if( onButtons && btns!=lastBtns ) onButtons( buttons );
lastBtns = btns;
}
//Play tone of given freqency.
this.PlayTone = function( Hz )
{
var hex = Hex( Hz ,4 );
var hi = hex.substr(0,2);
var lo = hex.substr(2,2);
bt.Write( "23,43,01,01,"+hi+","+lo+",23,45" );
}
//Turn LEDs on or off.
//paw.SetLEDs( [1,1,1,0] );
this.SetLEDs = function( leds )
{
var byte = 0;
if( leds[0] ) byte |= 1;
if( leds[1] ) byte |= 2;
if( leds[2] ) byte |= 4;
if( leds[3] ) byte |= 8;
var hex = Hex( byte, 2 );
bt.Write( "23,4C,"+hex+",23,45" );
}
//Set a servos position (posn 0.0 - 1.0).
this.SetServo = function( num, posn )
{
var hex = Hex( posn*999, 4 );
var hi = hex.substr(0,2);
var lo = hex.substr(2,2);
var num = Hex( num, 4 );
bt.Write( "23,53,"+num+","+hi+","+lo+",23,45" );
}
//Set global servo speed (0.0 - 1.0).
this.SetServoSpeed = function( speed )
{
var hex = Hex( speed*99, 4 );
var hi = hex.substr(0,2);
var lo = hex.substr(2,2);
bt.Write( "23,50,"+hi+","+lo+",23,45" );
}
//Convert number to hex string of given length.
function Hex( num, len )
{
num = Math.round( num );
var s = "000000000" + num.toString(16);
return s.substr(s.length-len);
}
}