[ble-oad-android-source-code/ble-oad-android-source-code.git] / app / src / main / java / com / example / ti / oadexample / Util.java
1 package com.example.ti.oadexample;
3 /**
4 * Utility class
5 */
6 public class Util
7 {
8 // Choose loglevel
9 public static int LOGLEVEL = 1;
10 public static boolean ERROR = LOGLEVEL > 0;
11 public static boolean WARN = LOGLEVEL > 1;
12 public static boolean INFO = LOGLEVEL > 2;
13 public static boolean DEBUG = LOGLEVEL > 3;
15 /**
16 * Get lower byte of an uint16
17 */
18 public static byte loUint16(short v) {
19 return (byte) (v & 0xFF);
20 }
22 /**
23 * Get high byte of an uint16
24 */
25 public static byte hiUint16(short v) {
26 return (byte) (v >> 8);
27 }
29 /**
30 * Build a uint16 from two bytes
31 */
32 public static short buildUint16(byte hi, byte lo) {
33 return (short) ((hi << 8) + (lo & 0xff));
34 }
35 }