Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
package com.afunx.ble.blelitelib.utils;
/* loaded from: classes.dex */
public class BleGattStateParser {
public static String parse(int i) {
return i != 0 ? i != 1 ? i != 2 ? i != 3 ? String.format("UNKNOWN (0x%04x)", Integer.valueOf(i & 65535)) : "STATE DISCONNECTING" : "STATE CONNECTED" : "STATE CONNECTING" : "STATE DISCONNECTED";
}
}

View File

@@ -0,0 +1,83 @@
package com.afunx.ble.blelitelib.utils;
import com.twitter.sdk.android.core.TwitterAuthConfig;
import com.ubtrobot.jimu.robotapi.PeripheralType;
/* loaded from: classes.dex */
public class BleGattStatusParser {
public static String parse(int i) {
switch (i) {
case 0:
return "GATT SUCCESS";
case 1:
return "GATT INVALID HANDLE";
case 2:
return "GATT READ NOT PERMIT";
case 3:
return "GATT WRITE NOT PERMIT";
case 4:
return "GATT INVALID PDU";
case 5:
return "GATT INSUF AUTHENTICATION";
case 6:
return "GATT REQ NOT SUPPORTED";
case 7:
return "GATT INVALID OFFSET";
case 8:
return "GATT INSUF AUTHORIZATION";
case 9:
return "GATT PREPARE Q FULL";
case 10:
return "GATT NOT FOUND";
case 11:
return "GATT NOT LONG";
case 12:
return "GATT INSUF KEY SIZE";
case 13:
return "GATT INVALID ATTR LEN";
case 14:
return "GATT ERR UNLIKELY";
case 15:
return "GATT INSUF ENCRYPTION";
case 16:
return "GATT UNSUPPORT GRP TYPE";
case 17:
return "GATT INSUF RESOURCE";
default:
switch (i) {
case PeripheralType.SERVO /* 128 */:
return "GATT NO RESOURCES";
case 129:
return "GATT INTERNAL ERROR";
case 130:
return "GATT WRONG STATE";
case 131:
return "GATT DB FULL";
case 132:
return "GATT BUSY";
case 133:
return "GATT ERROR";
case 134:
return "GATT CMD STARTED";
case 135:
return "GATT ILLEGAL PARAMETER";
case 136:
return "GATT PENDING";
case 137:
return "GATT AUTH FAIL";
case 138:
return "GATT MORE";
case 139:
return "GATT INVALID CFG";
case TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE /* 140 */:
return "GATT SERVICE STARTED";
case 141:
return "GATT ENCRYPED NO MITM";
case 142:
return "GATT NOT ENCRYPTED";
default:
return String.format("UNKNOWN (0x%04x)", Integer.valueOf(i & 65535));
}
}
}
}

View File

@@ -0,0 +1,29 @@
package com.afunx.ble.blelitelib.utils;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
/* loaded from: classes.dex */
public class BleUtils {
public static boolean disableBluetooth() {
return BluetoothAdapter.getDefaultAdapter().disable();
}
public static boolean enableBluetooth() {
return BluetoothAdapter.getDefaultAdapter().enable();
}
public static BluetoothDevice getRemoteDevice(String str) {
return BluetoothAdapter.getDefaultAdapter().getRemoteDevice(str);
}
public static boolean isBluetoothEnabled() {
return BluetoothAdapter.getDefaultAdapter().isEnabled();
}
public static void tryEnableBluetooth(Activity activity, int i) {
activity.startActivityForResult(new Intent("android.bluetooth.adapter.action.REQUEST_ENABLE"), i);
}
}

View File

@@ -0,0 +1,62 @@
package com.afunx.ble.blelitelib.utils;
import java.util.UUID;
/* loaded from: classes.dex */
public class BleUuidUtils {
private static String MAGIC_HEAD_STR = "0000";
private static String MAGIC_TAIL_STR = "49535343";
private static final int UUID_LENGTH = 36;
public static String int2str(int i) {
if (i < 0 || i > 65535) {
throw new IllegalArgumentException("uuid int range is [0x0000,0xffff]");
}
StringBuilder sb = new StringBuilder();
sb.append(MAGIC_HEAD_STR);
String hexString = Integer.toHexString(i);
for (int i2 = 0; i2 < 4 - hexString.length(); i2++) {
sb.append("0");
}
sb.append(hexString);
sb.append(MAGIC_TAIL_STR);
return sb.toString();
}
public static UUID int2uuid(int i) {
return UUID.fromString(int2str(i));
}
public static void setMagicHeadStr(String str) {
if (str.length() != MAGIC_HEAD_STR.length()) {
throw new IllegalArgumentException("magicHeadStr length is invalid");
}
MAGIC_HEAD_STR = str;
}
public static void setMagicTailStr(String str) {
if (str.length() != MAGIC_TAIL_STR.length()) {
throw new IllegalArgumentException("magicTailStr length is invalid");
}
MAGIC_TAIL_STR = str;
}
public static int str2int(String str) {
if (str != null && str.length() == 36 && str.startsWith(MAGIC_TAIL_STR)) {
return Integer.parseInt(str.substring(4, 8), 16);
}
throw new IllegalArgumentException("invalid uuid string");
}
public static UUID str2uuid(String str) {
return UUID.fromString(str);
}
public static int uuid2int(UUID uuid) {
return str2int(uuid.toString());
}
public static String uuid2str(UUID uuid) {
return uuid.toString();
}
}

View File

@@ -0,0 +1,49 @@
package com.afunx.ble.blelitelib.utils;
/* loaded from: classes.dex */
public class HexUtils {
private static final char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
public static String bytes2HexString(byte[] bArr) {
if (bArr == null) {
return null;
}
return bArr.length == 0 ? "" : bytes2HexString(bArr, 0, bArr.length);
}
public static String bytes2HexStringWithSpace(byte[] bArr) {
if (bArr == null) {
return null;
}
return bArr.length == 0 ? "" : bytes2HexStringWithSpace(bArr, 0, bArr.length);
}
public static String bytes2HexString(byte[] bArr, int i, int i2) {
if (bArr == null || i < 0 || i2 <= 0 || i2 - i > bArr.length) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i3 = 0; i3 < i2; i3++) {
int i4 = i3 + i;
sb.append(hexDigits[(bArr[i4] >>> 4) & 15]);
sb.append(hexDigits[bArr[i4] & 15]);
}
return sb.toString();
}
public static String bytes2HexStringWithSpace(byte[] bArr, int i, int i2) {
if (bArr == null || i < 0 || i2 <= 0 || i2 - i > bArr.length) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i3 = 0; i3 < i2; i3++) {
int i4 = i3 + i;
sb.append(hexDigits[(bArr[i4] >>> 4) & 15]);
sb.append(hexDigits[bArr[i4] & 15]);
if (i3 != i2 - 1) {
sb.append(" ");
}
}
return sb.toString();
}
}