Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Static Public Member Functions | List of all members
org.direct_bt.BTUtils Class Reference
Collaboration diagram for org.direct_bt.BTUtils:

Static Public Member Functions

static native long currentTimeMillis ()
 Returns current monotonic time in milliseconds. More...
 
static native long wallClockSeconds ()
 Returns current wall-clock system time of day in seconds since Unix Epoch 00:00:00 UTC on 1 January 1970. More...
 
static long startupTimeMillis ()
 Returns the startup time in monotonic time in milliseconds of the native module. More...
 
static long elapsedTimeMillis ()
 Returns current elapsed monotonic time in milliseconds since module startup, see startupTimeMillis(). More...
 
static long elapsedTimeMillis (final long current_ts)
 Returns elapsed monotonic time in milliseconds since module startup comparing against the given timestamp, see startupTimeMillis(). More...
 
static void fprintf_td (final PrintStream out, final String format, final Object ... args)
 Convenient PrintStream#printf(String, Object...) invocation, prepending the elapsedTimeMillis() timestamp. More...
 
static void println (final PrintStream out, final String msg)
 Convenient PrintStream#println(String) invocation, prepending the elapsedTimeMillis() timestamp. More...
 
static void print (final PrintStream out, final String msg)
 Convenient PrintStream#print(String) invocation, prepending the elapsedTimeMillis() timestamp. More...
 
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 interval as follows: More...
 
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. More...
 
static StringBuilder byteHexString (final StringBuilder sb, final byte value, final boolean lowerCase)
 Produce a hexadecimal string representation of the given byte value. More...
 
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. More...
 

Detailed Description

Definition at line 29 of file BTUtils.java.

Member Function Documentation

◆ byteHexString()

static StringBuilder org.direct_bt.BTUtils.byteHexString ( final StringBuilder  sb,
final byte  value,
final boolean  lowerCase 
)
static

Produce a hexadecimal string representation of the given byte value.

Parameters
sbthe StringBuilder destination to append
valuethe byte value to represent
lowerCasetrue to use lower case hex-chars, otherwise capital letters are being used.
Returns
the given StringBuilder for chaining

Definition at line 168 of file BTUtils.java.

Here is the caller graph for this function:

◆ bytesHexString()

static String org.direct_bt.BTUtils.bytesHexString ( final byte[]  bytes,
final int  offset,
final int  length,
final boolean  lsbFirst 
)
static

Produce a lower-case hexadecimal string representation of the given byte values.

If lsbFirst is true, orders LSB left -> MSB right, usual for byte streams.
Otherwise orders MSB left -> LSB right, usual for readable integer values.

Parameters
bytesthe byte array to represent
offsetoffset in byte array to the first byte to print.
lengthnumber of bytes to print. If negative, will use
bytes.length - offset
.
lsbFirsttrue having the least significant byte printed first (lowest addressed byte to highest), otherwise have the most significant byte printed first (highest addressed byte to lowest).
Returns
the hex-string representation of the data

Definition at line 123 of file BTUtils.java.

Here is the caller graph for this function:

◆ currentTimeMillis()

static native long org.direct_bt.BTUtils.currentTimeMillis ( )
static

Returns current monotonic time in milliseconds.

Here is the caller graph for this function:

◆ decodeUTF8String()

static native String org.direct_bt.BTUtils.decodeUTF8String ( final byte[]  buffer,
final int  offset,
final int  size 
)
static

Returns all valid consecutive UTF-8 characters within buffer in the range offset -> size or until EOS.

In case a non UTF-8 character has been detected, the content will be cut off and the decoding loop ends.

Method utilizes a finite state machine detecting variable length UTF-8 codes. See Bjoern Hoehrmann's site for details.

◆ elapsedTimeMillis() [1/2]

static long org.direct_bt.BTUtils.elapsedTimeMillis ( )
static

Returns current elapsed monotonic time in milliseconds since module startup, see startupTimeMillis().

Definition at line 55 of file BTUtils.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ elapsedTimeMillis() [2/2]

static long org.direct_bt.BTUtils.elapsedTimeMillis ( final long  current_ts)
static

Returns elapsed monotonic time in milliseconds since module startup comparing against the given timestamp, see startupTimeMillis().

Definition at line 60 of file BTUtils.java.

◆ fprintf_td()

static void org.direct_bt.BTUtils.fprintf_td ( final PrintStream  out,
final String  format,
final Object ...  args 
)
static

Convenient PrintStream#printf(String, Object...) invocation, prepending the elapsedTimeMillis() timestamp.

Parameters
outthe output stream
formatthe format
argsthe arguments

Definition at line 68 of file BTUtils.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHCIConnSupervisorTimeout()

static int org.direct_bt.BTUtils.getHCIConnSupervisorTimeout ( final int  conn_latency,
final int  conn_interval_max_ms,
final int  min_result_ms,
final int  multiplier 
)
static

Defining the supervising timeout for LE connections to be a multiple of the maximum connection interval as follows:

 ( 1 + conn_latency ) * conn_interval_max_ms * max(2, multiplier) [ms]

If above result is smaller than the given min_result_ms, min_result_ms/10 will be returned.

Parameters
conn_latencythe connection latency
conn_interval_max_msthe maximum connection interval in [ms]
min_result_msthe minimum resulting supervisor timeout, defaults to 500ms. If above formula results in a smaller value, min_result_ms/10 will be returned.
multiplierrecommendation is 6, we use 10 as default for safety.
Returns
the resulting supervising timeout in 1/10 [ms], suitable for the BTDevice#connectLE(short, short, short, short, short, short).
See also
BTDevice::connectLE(short, short, short, short, short, short)

Definition at line 103 of file BTUtils.java.

◆ print()

static void org.direct_bt.BTUtils.print ( final PrintStream  out,
final String  msg 
)
static

Convenient PrintStream#print(String) invocation, prepending the elapsedTimeMillis() timestamp.

Parameters
outthe output stream
msgthe string message

Definition at line 85 of file BTUtils.java.

Here is the call graph for this function:

◆ println()

static void org.direct_bt.BTUtils.println ( final PrintStream  out,
final String  msg 
)
static

Convenient PrintStream#println(String) invocation, prepending the elapsedTimeMillis() timestamp.

Parameters
outthe output stream
msgthe string message

Definition at line 77 of file BTUtils.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startupTimeMillis()

static long org.direct_bt.BTUtils.startupTimeMillis ( )
static

Returns the startup time in monotonic time in milliseconds of the native module.

Definition at line 50 of file BTUtils.java.

◆ wallClockSeconds()

static native long org.direct_bt.BTUtils.wallClockSeconds ( )
static

Returns current wall-clock system time of day in seconds since Unix Epoch 00:00:00 UTC on 1 January 1970.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: