Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Go to the documentation of this file.
25 package org.direct_bt;
27 import java.io.PrintStream;
30 private static long t0;
32 t0 = startupTimeMillisImpl();
34 private static native
long startupTimeMillisImpl();
68 public static void fprintf_td(
final PrintStream out,
final String format,
final Object ... args) {
70 out.printf(format, args);
77 public static void println(
final PrintStream out,
final String msg) {
85 public static void print(
final PrintStream out,
final String msg) {
104 final int min_result_ms,
final int multiplier) {
105 return Math.max(min_result_ms,
106 ( 1 + conn_latency ) * conn_interval_max_ms * Math.max(2, multiplier)
123 public static String
bytesHexString(
final byte[] bytes,
final int offset,
final int length,
124 final boolean lsbFirst)
126 final int byte_len = 0 <= length ? length : bytes.length - offset;
127 if( byte_len > ( bytes.length - offset ) ) {
128 throw new IllegalArgumentException(
"byte[] ( "+bytes.length+
" - "+offset+
" ) < "+length+
" bytes");
131 final char[] hex_array = HEX_ARRAY_LOW;
132 final char[] hexChars;
133 final int char_offset;
138 hexChars =
new char[byte_len * 2];
139 for (
int j = 0; j < byte_len; j++) {
140 final int v = bytes[offset + j] & 0xFF;
141 hexChars[char_offset + j * 2] = hex_array[v >>> 4];
142 hexChars[char_offset + j * 2 + 1] = hex_array[v & 0x0F];
147 hexChars =
new char[2 + byte_len * 2];
150 for (
int j = byte_len-1; j >= 0; j--) {
151 final int v = bytes[offset + j] & 0xFF;
152 hexChars[char_offset + j * 2] = hex_array[v >>> 4];
153 hexChars[char_offset + j * 2 + 1] = hex_array[v & 0x0F];
156 return new String(hexChars);
158 private static final char[] HEX_ARRAY_LOW =
"0123456789abcdef".toCharArray();
159 private static final char[] HEX_ARRAY_BIG =
"0123456789ABCDEF".toCharArray();
168 public static StringBuilder
byteHexString(
final StringBuilder sb,
final byte value,
final boolean lowerCase)
170 final char[] hex_array = lowerCase ? HEX_ARRAY_LOW : HEX_ARRAY_BIG;
171 final int v = value & 0xFF;
172 sb.append(hex_array[v >>> 4]);
173 sb.append(hex_array[v & 0x0F]);
189 public static native String
decodeUTF8String(
final byte[] buffer,
final int offset,
final int size);
static int getHCIConnSupervisorTimeout(final int conn_latency, final int conn_interval_max_ms, final int min_result_ms, final int multiplier)
Defining the supervising timeout for LE connections to be a multiple of the maximum connection interv...
static void fprintf_td(final PrintStream out, final String format, final Object ... args)
Convenient PrintStream#printf(String, Object...) invocation, prepending the elapsedTimeMillis() times...
static void println(final PrintStream out, final String msg)
Convenient PrintStream#println(String) invocation, prepending the elapsedTimeMillis() timestamp.
static native long currentTimeMillis()
Returns current monotonic time in milliseconds.
static long startupTimeMillis()
Returns the startup time in monotonic time in milliseconds of the native module.
static void print(final PrintStream out, final String msg)
Convenient PrintStream#print(String) invocation, prepending the elapsedTimeMillis() timestamp.
static long elapsedTimeMillis(final long current_ts)
Returns elapsed monotonic time in milliseconds since module startup comparing against the given times...
static StringBuilder byteHexString(final StringBuilder sb, final byte value, final boolean lowerCase)
Produce a hexadecimal string representation of the given byte value.
static native String decodeUTF8String(final byte[] buffer, final int offset, final int size)
Returns all valid consecutive UTF-8 characters within buffer in the range offset -> size or until EOS...
static long elapsedTimeMillis()
Returns current elapsed monotonic time in milliseconds since module startup, see startupTimeMillis().
static native long wallClockSeconds()
Returns current wall-clock system time of day in seconds since Unix Epoch 00:00:00 UTC on 1 January 1...
static String bytesHexString(final byte[] bytes, final int offset, final int length, final boolean lsbFirst)
Produce a lower-case hexadecimal string representation of the given byte values.