[android-developers] Android bluetooth communication

2012-04-02 Thread dusslk
I need to send 10-bit data from the Analog to digital converter(ADC)
from a dsPIC at 2Mbps through UART interface, to the bluetooth module.
Then the bluetooth module should read this data through its UART
interface and transmit this data via bluetooth which will be finally
received by an Android phone. An application in the phone will take
this data and plot a waveform on the screen.

So basically the phone will recieve data at 2 Mbps via bluetooth. Is
this practically possible ?

Most bluetooth modules say they can transfer data only around 300 kbps
using RFCOMM protocol. To go upto 2Mbps it is needed to use the HCI
protocol. So then can the Android phone read data sent in HCI
protocol. Is there any support available. Currently all transfers done
in Android which I found are in RFCOMM.

Is there any way either using RFCOMM or any other means to for Android
phone to aquire atleast 1.5 Mbps data via bluetooth.

Thank you,
Best Regards.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Android - Bluetooth communication with Lego NXT brick

2011-05-18 Thread damienb2
Hello everybody!

i'm developping an android application to remote control a lego
mindstorm NXT.
The NXT let the mobile control motors, and sensors (ultrasonic, light,
temperature,...)
The android mobile is linked to the nxt by bluetooth.

I success in controling the motors, but now i've got one problem :
accessing the sensors.
I tried to get informations from the ultrasonic sensor since a long
time, but no success!

how i do it :

1) i send first the information my ultrasonic sensor is linked to the
port 1 according to instructions of the bluetooth Lego NXT developper
kit:

setUp

void initUltrasonicSensor(int sensorPort){

byte[] message = new byte[5];

message[0]= LCPMessage.DIRECT_COMMAND_NOREPLY;  // DirectCommand, byte
constant : 0x00
message[1]= LCPMessage.SET_INPUT_MODE;  // 
SetInputMode, byte
constant : 0x05
message[2] =  (byte) sensorPort;// 
Input Port, 0 1 2 or 3
message[3]= typePort ;  
// Type Port, ultrasonic = 0x0B
message[4]= (byte) 0x00;
// Sensor mode

sendMessage(message);
}


/**
 * Sends a message on the opened OutputStream
 * @param message, the message as a byte array
 */
void sendMessage(byte[] message) throws IOException {
if (nxtOutputStream == null)
throw new IOException();

// send message length
int messageLength = message.length;
nxtOutputStream.write(messageLength);
nxtOutputStream.write(messageLength  8);
nxtOutputStream.write(message, 0, message.length);
}



2) then, i send the informtion get distance from the ultrasonic
sensor :

public void getInputValues(int sensor) {

byte[] request = new byte[3];

request[0] = LCPMessage.DIRECT_COMMAND_REPLY;   // DirectCommand, byte
constant : 0x00
request[1] = LCPMessage.GET_INPUT_VALUES;   // 
getInputValues, byte
constant : 0x07
request[2] = (byte) sensor; 
// input port, 0 1 2 or 3

sendMessage(message);
}


3) when i reveived the reply information from the NXT, i get it :

05-18 10:33:53.652: INFO/(8885): Values received from
UltrasonicSensor : [ 2 7 0 0 1 0 B 0 0 0 0 0 0 0 0 0 ]

the expected response, according to instructions of the bluetooth Lego
NXT developper kit:
byte 0: 0x02
byte 1: 0x07
byte 2: status byte
byte 3: input port (range: 0-3)
byte 4: valid? (boolean TRUE if new data value should be seen as valid
data)
byte 5: calibrated? (boolean TRUE if calibration file found and used
for Calibrated Value field below)
byte 6: sensor type (enumerated)
byte 7: sensor mode (enumerated)
byte 8-9: Row A/D value(UWORD; device dependent)
byte 10-11: Normalized A/D value(UWORD; device dependent; Range:
0-1023)
byte 12-13: Scaled value (SWORD; mode dependent)
byte 14-15: Calibrated value (SWORD; value scaled according to
calibration. CURENTLY UNUSED.)


So i'm supposed to get the information about the distance from the 8-9
byte, but i get 0!

Could anyone help me ?
thanks for all!
(sorry for my english, i'm french!)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en