lejos.hardware.Bluetooth Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lejos-ev3-api Show documentation
Show all versions of lejos-ev3-api Show documentation
leJOS (pronounced like the Spanish word "lejos" for "far") is a tiny Java Virtual Machine. In 2013 it was ported to the LEGO EV3 brick.
The newest version!
package lejos.hardware;
import lejos.remote.nxt.BTConnector;
import lejos.remote.nxt.NXTCommConnector;
public class Bluetooth {
public static NXTCommConnector getNXTCommConnector() {
return new BTConnector();
}
public static LocalBTDevice getLocalDevice() {
return new LocalBTDevice();
}
// Utility methods
/**
* Return a Bluetooth binary address given a String version of the address
* @param address String address
* @return Binary address
*/
public static byte[] getAddress(String address) {
byte[] bdaddr = new byte[6];
for(int i=0;i=0;j--) {
String hex = Integer.toHexString(address[j] & 0xFF).toUpperCase();
if (hex.length() == 1) sb.append('0');
sb.append(hex);
if (j>0) sb.append(':');
}
return sb.toString();
}
}