12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331 |
- package com.epson.mobilephone.common.ble;
- import android.app.Activity;
- import android.bluetooth.BluetoothAdapter;
- import android.bluetooth.BluetoothDevice;
- import android.bluetooth.BluetoothGatt;
- import android.bluetooth.BluetoothGattCallback;
- import android.bluetooth.BluetoothGattCharacteristic;
- import android.bluetooth.BluetoothGattDescriptor;
- import android.bluetooth.BluetoothGattService;
- import android.bluetooth.BluetoothManager;
- import android.content.Context;
- import android.os.AsyncTask;
- import android.os.Build;
- import android.os.Handler;
- import com.epson.mobilephone.common.ble.util.BLEUtility;
- import com.epson.mobilephone.common.ble.util.BLEUuid;
- import com.epson.mobilephone.common.ble.util.ScannedDevice;
- import com.epson.mobilephone.common.escpr.EscprLib;
- import com.epson.mobilephone.common.escpr.MIBCommand;
- import com.epson.mobilephone.common.wifidirect.ActivityRequestLocationPermission;
- import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
- import com.epson.mobilephone.common.wifidirect.WiFiNetworkManager;
- import com.evernote.edam.limits.Constants;
- import java.nio.ByteBuffer;
- import java.nio.charset.Charset;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import java.util.Objects;
- import java.util.UUID;
- import java.util.concurrent.TimeUnit;
- import epson.print.IprintApplication;
- import epson.print.MyPrinter;
- public class BleWork {
- private static final int EPS_COMM_BID = 2;
- private static final int GATT_DELAY = 0;
- private static final int GATT_DELAY2 = 500;
- private static final int RETRY_NUMS = 3;
- private static final int SCAN_ADVERTISING_PACKET_TIMEOUT = 10000;
- Handler handlerRead;
- Handler handlerWrite;
- private BluetoothAdapter mBTAdapter;
- /* access modifiers changed from: private */
- @Nullable
- public BluetoothGatt mConnGatt;
- private Context mContext;
- private BluetoothDevice mDevice;
- private String mDeviceMacAddress;
- private String mDevicePassword;
- private final byte[] mEngineID;
- private EscprLib mEscprlib;
- /* access modifiers changed from: private */
- @Nullable
- public BLEUtility.BleWorkCallback mFailed;
- private BluetoothGattCallback mGattcallback;
- private boolean mInSequence;
- private byte mIndex;
- /* access modifiers changed from: private */
- @NonNull
- public MIBCommand mMibCommand;
- private boolean mReconnect;
- /* access modifiers changed from: private */
- @Nullable
- public BLEUtility.BleWorkCallback mResposne;
- private int mRetry;
- private String mSSID;
- private String mSSIDPassword;
- private short mSecurityType;
- private ScannedDevice mSelectItem;
- public jobSequence mSequence;
- @Nullable
- private BLEUtility.BleWorkCallback mSequenceCallbackFailed;
- /* access modifiers changed from: private */
- @Nullable
- public BLEUtility.BleWorkCallback mSequenceCallbackSuccess;
- /* access modifiers changed from: private */
- @NonNull
- public List<String> mSsidLis;
- public int mStatus;
- /* access modifiers changed from: private */
- @Nullable
- public BLEUtility.BleWorkCallback mSuccess;
- private long mTimeOut;
- public enum jobSequence {
- UNINITIALIZED,
- DISCONNECTED,
- FAILED,
- INITIALIZE,
- GET_VERSION,
- CHECK_SSID,
- SET_PASSWORD,
- MIB_GET_MACADDRESS,
- MIB_GET_SSID_LIST,
- MIB_SET_SSID,
- MIB_SET_SECURITY_TYPE,
- MIB_SEC_LOGIN,
- MIB_SEC_SET_PASS,
- MIB_SEC_LOGOUT,
- MIB_REBOOT_NW,
- COMPLETION,
- MIB_SEC_SKIP,
- AFTER_SETTING_PASSWORD,
- BEFORE_CHECK_SSID
- }
- public static int getScanAdvertisingPacketTimeout() {
- return 10000;
- }
- private void showStatus(String str, int i) {
- }
- static /* synthetic */ int access$508(BleWork bleWork) {
- int i = bleWork.mRetry;
- bleWork.mRetry = i + 1;
- return i;
- }
- @NonNull
- public List<String> getSsidLis() {
- return mSsidLis;
- }
- public void setSSID(String str) {
- mSSID = str;
- }
- public void setRetryFinish() {
- mRetry = 3;
- }
- public String getSSID() {
- return mSSID;
- }
- public synchronized void setSecurityType(short s) {
- mSecurityType = s;
- }
- public synchronized short getSecurityType() {
- return mSecurityType;
- }
- public void setSSIDPassword(String str) {
- mSSIDPassword = str;
- }
- public String getSSIDPassword() {
- String str = mSSIDPassword;
- return str != null ? str : "";
- }
- public void setTimeOut(long j) {
- mTimeOut = j;
- }
- public String getDeviceMacAddress() {
- String str = mDeviceMacAddress;
- if (str == null) {
- return "";
- }
- return str.replace("\"", "");
- }
- public String getDeviceName() {
- return mSelectItem.getDisplayName();
- }
- private BleWork() {
- mSuccess = null;
- mFailed = null;
- mSequenceCallbackSuccess = null;
- mSequenceCallbackFailed = null;
- mResposne = null;
- mSsidLis = new ArrayList();
- mTimeOut = -1;
- mEscprlib = EscprLib.getInstance();
- mMibCommand = new MIBCommand();
- mIndex = 0;
- mInSequence = false;
- mEngineID = mEscprlib.getEngineId(IprintApplication.getInstance());
- mReconnect = false;
- mSequence = jobSequence.UNINITIALIZED;
- mGattcallback = null;
- if (mGattcallback != null) {
- EPLog.e("mGattcallback != null");
- }
- mGattcallback = new BluetoothGattCallback() {
- public void onMtuChanged(BluetoothGatt bluetoothGatt, int i, int i2) {
- super.onMtuChanged(bluetoothGatt, i, i2);
- EPLog.i("onMtuChanged " + i);
- }
- public void onDescriptorWrite(BluetoothGatt bluetoothGatt, BluetoothGattDescriptor bluetoothGattDescriptor, int i) {
- super.onDescriptorWrite(bluetoothGatt, bluetoothGattDescriptor, i);
- showStatus("DescriptorWrite", i);
- if (i != 0) {
- sequenceError();
- } else if (BleWork.mResposne != null) {
- BleWork.mResposne.call(bluetoothGattDescriptor);
- }
- }
- public void onConnectionStateChange(BluetoothGatt bluetoothGatt, int i, int i2) {
- EPLog.i("status = " + i + " newState = " + i2);
- if (i == 0 && i2 == 2) {
- EPLog.i("STATE_CONNECTED -- " + BleWork.mSequence);
- BleWork bleWork = BleWork.this;
- bleWork.mStatus = i2;
- if (bleWork.mConnGatt == null) {
- EPLog.e("mConnGatt NULL !");
- }
- if (bluetoothGatt == null) {
- EPLog.e("gatt NULL !");
- }
- BluetoothGatt unused = BleWork.mConnGatt = bluetoothGatt;
- handlerWrite.removeCallbacks((Runnable) null);
- handlerWrite.postDelayed(new Runnable() {
- public void run() {
- EPLog.i("discoverServices");
- try {
- if (!((BluetoothGatt) Objects.requireNonNull(BleWork.mConnGatt)).discoverServices()) {
- EPLog.e("discoverServices error");
- }
- } catch (NullPointerException unused) {
- EPLog.e("mConnGatt NULL !");
- }
- }
- }, 500);
- } else if (i != 0 || i2 == 0) {
- EPLog.i("STATE_DISCONNECTED " + BleWork.mSequence + " mReconnect = " + BleWork.mReconnect + " mRetry " + BleWork.mRetry);
- if (!BleWork.mReconnect && BleWork.mSequence == jobSequence.UNINITIALIZED) {
- failedProcessing();
- } else if (BleWork.mReconnect || BleWork.mSequence == jobSequence.UNINITIALIZED || BleWork.mSequence == jobSequence.MIB_REBOOT_NW || BleWork.mSequence == jobSequence.DISCONNECTED || BleWork.mSequence == jobSequence.MIB_SET_SSID || BleWork.mSequence == jobSequence.AFTER_SETTING_PASSWORD) {
- EPLog.d("★ stopScan");
- BleScanWork.getInstace().stopScan();
- BleWork bleWork2 = BleWork.this;
- bleWork2.mStatus = i2;
- if ((bleWork2.mSequence == jobSequence.AFTER_SETTING_PASSWORD || BleWork.mSequence == jobSequence.BEFORE_CHECK_SSID || BleWork.mSequence == jobSequence.MIB_SET_SSID || BleWork.mSequence == jobSequence.MIB_REBOOT_NW) && !BleWork.mReconnect) {
- if (BleWork.mSequence == jobSequence.MIB_REBOOT_NW) {
- gattClose();
- }
- EPLog.i(" BREAK ★ mSequence " + BleWork.mSequence);
- return;
- }
- gattClose();
- if (BleWork.mSequence != jobSequence.UNINITIALIZED && !BleWork.mReconnect) {
- return;
- }
- if (BleWork.mRetry < 3) {
- try {
- TimeUnit.SECONDS.sleep(5);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- EPLog.m82w("retry " + BleWork.mRetry);
- BleWork.access$508(BleWork.this);
- EPLog.e("init");
- boolean unused2 = init();
- return;
- }
- failedProcessing();
- } else {
- failedProcessing();
- }
- } else if (i2 == 1) {
- EPLog.i("STATE_CONNECTING");
- } else if (i2 == 3) {
- EPLog.i("STATE_DISCONNECTING");
- }
- }
- public void onServicesDiscovered(BluetoothGatt bluetoothGatt, int i) {
- EPLog.i();
- try {
- for (BluetoothGattService next : bluetoothGatt.getServices()) {
- if (next != null) {
- if (next.getUuid() != null) {
- if (BLEUuid.SERVICE_SNMP.equalsIgnoreCase(next.getUuid().toString())) {
- EPLog.i("発見!! EPSON SNMP サービス");
- for (Map.Entry next2 : BLEUuid.GattCharsMap.entrySet()) {
- next2.setValue(next.getCharacteristic(UUID.fromString((String) next2.getKey())));
- }
- if (!BLEUuid.GattCharsMap.containsValue((Object) null)) {
- boolean unused = BleWork.mReconnect = false;
- BleWork.mSequenceCallbackSuccess.call(BleWork.mSequence);
- new NotifySetThread().execute(new Void[0]);
- } else {
- throw new BleException(1, "getCharacteristic Error !");
- }
- } else {
- continue;
- }
- }
- }
- }
- } catch (BleException e) {
- EPLog.e(e.getMessage());
- e.printStackTrace();
- failedProcessing();
- }
- }
- public void onCharacteristicChanged(BluetoothGatt bluetoothGatt, @NonNull BluetoothGattCharacteristic bluetoothGattCharacteristic) {
- super.onCharacteristicChanged(bluetoothGatt, bluetoothGattCharacteristic);
- EPLog.d("onCharacteristicChanged");
- if (BLEUuid.CHAR_SNMP_STATUS_STRING.equals(bluetoothGattCharacteristic.getUuid().toString())) {
- Short valueOf = Short.valueOf(bluetoothGattCharacteristic.getIntValue(17, 0).shortValue());
- String sh = valueOf.toString();
- if (valueOf.shortValue() == 0) {
- EPLog.i("[Notify]SNMP Status" + sh);
- characteristicRead();
- return;
- }
- EPLog.e("[Notify]SNMP Status" + sh);
- failedProcessing();
- } else if (BLEUuid.CHAR_SECURITY_TYPE_STRING.equals(bluetoothGattCharacteristic.getUuid().toString())) {
- Short valueOf2 = Short.valueOf(bluetoothGattCharacteristic.getIntValue(17, 0).shortValue());
- setSecurityType(valueOf2.shortValue());
- String sh2 = valueOf2.toString();
- EPLog.i("[Notify]Security Type " + sh2);
- if (valueOf2.shortValue() <= 0) {
- BleWork.mSsidLis.clear();
- getSSIDList();
- } else if (BleWork.mSequenceCallbackSuccess != null) {
- BleWork.mSequenceCallbackSuccess.call(BleWork.mSequence);
- }
- } else {
- String sh3 = Short.valueOf(bluetoothGattCharacteristic.getIntValue(17, 0).shortValue()).toString();
- EPLog.e("[Notify]unKnown type" + sh3);
- }
- }
- public void onCharacteristicRead(BluetoothGatt bluetoothGatt, @NonNull BluetoothGattCharacteristic bluetoothGattCharacteristic, int i) {
- showStatus("Read", i);
- if (i == 0) {
- readCharacteristicData(bluetoothGattCharacteristic);
- } else {
- byte unused = BleWork.mIndex = (byte) 0;
- }
- }
- /* JADX WARNING: Can't fix incorrect switch cases order */
- /* Code decompiled incorrectly, please refer to instructions dump. */
- private void readCharacteristicData(@android.support.annotation.NonNull android.bluetooth.BluetoothGattCharacteristic r7) {
- /*
- r6 = this;
- java.util.UUID r0 = r7.getUuid()
- java.lang.String r0 = r0.toString()
- if (r0 != 0) goto L_0x0011
- java.lang.String r7 = "characteristic NULL !!"
- com.epson.mobilephone.common.EPLog.e((java.lang.String) r7)
- goto L_0x03a1
- L_0x0011:
- java.lang.String r0 = r0.toLowerCase()
- int r1 = r0.hashCode()
- r2 = -1
- r3 = 1
- r4 = 0
- switch(r1) {
- case -929193779: goto L_0x0048;
- case -881344628: goto L_0x003e;
- case 593366729: goto L_0x0034;
- case 641215880: goto L_0x002a;
- case 1286468426: goto L_0x0020;
- default: goto L_0x001f;
- }
- L_0x001f:
- goto L_0x0052
- L_0x0020:
- java.lang.String r1 = "802a0002-4ef4-4e59-b573-2bed4a4ac158"
- boolean r0 = r0.equals(r1)
- if (r0 == 0) goto L_0x0052
- r0 = 3
- goto L_0x0053
- L_0x002a:
- java.lang.String r1 = "00002a25-0000-1000-8000-00805f9b34fb"
- boolean r0 = r0.equals(r1)
- if (r0 == 0) goto L_0x0052
- r0 = 1
- goto L_0x0053
- L_0x0034:
- java.lang.String r1 = "802a0001-4ef4-4e59-b573-2bed4a4ac158"
- boolean r0 = r0.equals(r1)
- if (r0 == 0) goto L_0x0052
- r0 = 2
- goto L_0x0053
- L_0x003e:
- java.lang.String r1 = "00002a29-0000-1000-8000-00805f9b34fb"
- boolean r0 = r0.equals(r1)
- if (r0 == 0) goto L_0x0052
- r0 = 0
- goto L_0x0053
- L_0x0048:
- java.lang.String r1 = "802a0005-4ef4-4e59-b573-2bed4a4ac158"
- boolean r0 = r0.equals(r1)
- if (r0 == 0) goto L_0x0052
- r0 = 4
- goto L_0x0053
- L_0x0052:
- r0 = -1
- L_0x0053:
- r1 = 18
- switch(r0) {
- case 0: goto L_0x0389;
- case 1: goto L_0x0370;
- case 2: goto L_0x032e;
- case 3: goto L_0x02bd;
- case 4: goto L_0x005a;
- default: goto L_0x0058;
- }
- L_0x0058:
- goto L_0x03a1
- L_0x005a:
- byte[] r7 = r7.getValue()
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.MIBCommand r0 = r0.mMibCommand
- com.epson.mobilephone.common.escpr.MIBDataBlock r0 = r0.commandBlock
- int r1 = r7.length
- r0.bufSize = r1
- r0 = 0
- L_0x006a:
- com.epson.mobilephone.common.ble.BleWork r1 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.MIBCommand r1 = r1.mMibCommand
- com.epson.mobilephone.common.escpr.MIBDataBlock r1 = r1.commandBlock
- int r1 = r1.bufSize
- if (r0 >= r1) goto L_0x0087
- com.epson.mobilephone.common.ble.BleWork r1 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.MIBCommand r1 = r1.mMibCommand
- com.epson.mobilephone.common.escpr.MIBDataBlock r1 = r1.commandBlock
- byte[] r1 = r1.buf
- byte r5 = r7[r0]
- r1[r0] = r5
- int r0 = r0 + 1
- goto L_0x006a
- L_0x0087:
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- boolean r7 = r7.mInSequence
- if (r7 == 0) goto L_0x00e7
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.EscprLib r7 = r7.mEscprlib
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.MIBCommand r0 = r0.mMibCommand
- java.lang.String r7 = r7.mibParseResponseAsStr(r0)
- boolean r0 = r7.isEmpty()
- if (r0 == 0) goto L_0x00c3
- java.lang.String r7 = "[Read]SNMP Response :end!"
- com.epson.mobilephone.common.EPLog.i(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- boolean unused = r7.mInSequence = r4
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- byte unused = r7.mIndex = r4
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.util.BLEUtility$BleWorkCallback r7 = r7.mSequenceCallbackSuccess
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = r0.mSequence
- r7.call(r0)
- goto L_0x03a1
- L_0x00c3:
- java.lang.StringBuilder r0 = new java.lang.StringBuilder
- r0.<init>()
- java.lang.String r1 = "[Read]SNMP Response :"
- r0.append(r1)
- r0.append(r7)
- java.lang.String r0 = r0.toString()
- com.epson.mobilephone.common.EPLog.i(r0)
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- java.util.List r0 = r0.mSsidLis
- r0.add(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- r7.getSSIDList()
- goto L_0x03a1
- L_0x00e7:
- java.lang.StringBuilder r7 = new java.lang.StringBuilder
- r7.<init>()
- java.lang.String r0 = "mSequence "
- r7.append(r0)
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = r0.mSequence
- r7.append(r0)
- java.lang.String r7 = r7.toString()
- com.epson.mobilephone.common.EPLog.i(r7)
- int[] r7 = com.epson.mobilephone.common.ble.BleWork.C10195.$SwitchMap$com$epson$mobilephone$common$ble$BleWork$jobSequence
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = r0.mSequence
- int r0 = r0.ordinal()
- r7 = r7[r0]
- switch(r7) {
- case 1: goto L_0x026e;
- case 2: goto L_0x0226;
- case 3: goto L_0x019f;
- case 4: goto L_0x019f;
- case 5: goto L_0x019f;
- case 6: goto L_0x0110;
- case 7: goto L_0x0110;
- case 8: goto L_0x0110;
- default: goto L_0x010e;
- }
- L_0x010e:
- goto L_0x03a1
- L_0x0110:
- int[] r7 = new int[r3]
- r7[r4] = r2
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.EscprLib r0 = r0.mEscprlib
- com.epson.mobilephone.common.ble.BleWork r1 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.MIBCommand r1 = r1.mMibCommand
- int r0 = r0.mibParseResponseAsInt(r1, r7)
- if (r0 != 0) goto L_0x0198
- java.lang.StringBuilder r0 = new java.lang.StringBuilder
- r0.<init>()
- java.lang.String r1 = "[Read]SNMP Response :sucess mSequence "
- r0.append(r1)
- com.epson.mobilephone.common.ble.BleWork r1 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r1 = r1.mSequence
- r0.append(r1)
- java.lang.String r1 = " val:"
- r0.append(r1)
- r7 = r7[r4]
- r0.append(r7)
- java.lang.String r7 = r0.toString()
- com.epson.mobilephone.common.EPLog.i(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r7 = r7.mSequence
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = com.epson.mobilephone.common.ble.BleWork.jobSequence.MIB_SEC_SKIP
- if (r7 != r0) goto L_0x0157
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = com.epson.mobilephone.common.ble.BleWork.jobSequence.MIB_SEC_LOGOUT
- r7.mSequence = r0
- goto L_0x0166
- L_0x0157:
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r7 = r7.mSequence
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = com.epson.mobilephone.common.ble.BleWork.jobSequence.MIB_REBOOT_NW
- if (r7 != r0) goto L_0x0166
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- boolean unused = r7.mReconnect = r4
- goto L_0x03a1
- L_0x0166:
- r6.IncrementSequence()
- java.lang.StringBuilder r7 = new java.lang.StringBuilder
- r7.<init>()
- java.lang.String r0 = "mSequence "
- r7.append(r0)
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = r0.mSequence
- r7.append(r0)
- java.lang.String r7 = r7.toString()
- com.epson.mobilephone.common.EPLog.i(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r7 = r7.mSequence
- int r7 = r7.ordinal()
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = com.epson.mobilephone.common.ble.BleWork.jobSequence.MIB_REBOOT_NW
- int r0 = r0.ordinal()
- if (r7 > r0) goto L_0x03a1
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- r7.setSSIDWork()
- goto L_0x03a1
- L_0x0198:
- java.lang.String r7 = "[Read]SNMP Response :error "
- com.epson.mobilephone.common.EPLog.e((java.lang.String) r7)
- goto L_0x03a1
- L_0x019f:
- java.lang.StringBuilder r7 = new java.lang.StringBuilder
- r7.<init>()
- java.lang.String r0 = "mibIdentifier requestId = "
- r7.append(r0)
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.MIBCommand r0 = r0.mMibCommand
- com.epson.mobilephone.common.escpr.MIBIdentifier r0 = r0.mibIdentifier
- int r0 = r0.requestId
- r7.append(r0)
- java.lang.String r7 = r7.toString()
- com.epson.mobilephone.common.EPLog.d(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.EscprLib r7 = r7.mEscprlib
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.MIBCommand r0 = r0.mMibCommand
- com.epson.mobilephone.common.ble.BleWork r1 = com.epson.mobilephone.common.ble.BleWork.this
- byte[] r1 = r1.mEngineID
- int r7 = r7.mibParseSecResponse(r0, r1)
- java.lang.StringBuilder r0 = new java.lang.StringBuilder
- r0.<init>()
- java.lang.String r1 = "mSequence "
- r0.append(r1)
- com.epson.mobilephone.common.ble.BleWork r1 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r1 = r1.mSequence
- r0.append(r1)
- java.lang.String r1 = " ret = "
- r0.append(r1)
- r0.append(r7)
- java.lang.String r0 = r0.toString()
- com.epson.mobilephone.common.EPLog.i(r0)
- if (r7 == 0) goto L_0x01fc
- java.lang.String r7 = "[Read]SNMP Response :end!"
- com.epson.mobilephone.common.EPLog.i(r7)
- goto L_0x03a1
- L_0x01fc:
- r6.IncrementSequence()
- java.lang.StringBuilder r0 = new java.lang.StringBuilder
- r0.<init>()
- java.lang.String r1 = "[Read]SNMP Response :"
- r0.append(r1)
- r0.append(r7)
- java.lang.String r7 = " mSequence "
- r0.append(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r7 = r7.mSequence
- r0.append(r7)
- java.lang.String r7 = r0.toString()
- com.epson.mobilephone.common.EPLog.i(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- r7.setSSIDWork()
- goto L_0x03a1
- L_0x0226:
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.EscprLib r7 = r7.mEscprlib
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.MIBCommand r0 = r0.mMibCommand
- java.lang.String r7 = r7.mibParseResponseAsStr(r0)
- boolean r0 = r7.isEmpty()
- r0 = r0 ^ r3
- if (r0 != 0) goto L_0x0244
- java.lang.String r7 = "[Read]SNMP Response :end!"
- com.epson.mobilephone.common.EPLog.i(r7)
- goto L_0x03a1
- L_0x0244:
- r6.IncrementSequence()
- java.lang.StringBuilder r0 = new java.lang.StringBuilder
- r0.<init>()
- java.lang.String r1 = "[Read]SNMP Response :"
- r0.append(r1)
- r0.append(r7)
- java.lang.String r7 = " mSequence "
- r0.append(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r7 = r7.mSequence
- r0.append(r7)
- java.lang.String r7 = r0.toString()
- com.epson.mobilephone.common.EPLog.i(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- r7.setSSIDWork()
- goto L_0x03a1
- L_0x026e:
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.EscprLib r7 = r7.mEscprlib
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.escpr.MIBCommand r0 = r0.mMibCommand
- java.lang.String r7 = r7.mibParseResponseAsMacaddress(r0)
- boolean r0 = r7.isEmpty()
- if (r0 != 0) goto L_0x02b6
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- java.lang.String unused = r0.mDeviceMacAddress = r7
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r1 = com.epson.mobilephone.common.ble.BleWork.jobSequence.MIB_SET_SSID
- r0.mSequence = r1
- java.lang.StringBuilder r0 = new java.lang.StringBuilder
- r0.<init>()
- java.lang.String r1 = "[Read]SNMP Response :sucess:MacAddress ★"
- r0.append(r1)
- r0.append(r7)
- java.lang.String r7 = "★ mSequence "
- r0.append(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r7 = r7.mSequence
- r0.append(r7)
- java.lang.String r7 = r0.toString()
- com.epson.mobilephone.common.EPLog.i(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- r7.setSSIDWork()
- goto L_0x03a1
- L_0x02b6:
- java.lang.String r7 = "[Read]SNMP Response :failed"
- com.epson.mobilephone.common.EPLog.e((java.lang.String) r7)
- goto L_0x03a1
- L_0x02bd:
- java.lang.Integer r7 = r7.getIntValue(r1, r4)
- java.lang.String r7 = r7.toString()
- java.lang.StringBuilder r0 = new java.lang.StringBuilder
- r0.<init>()
- java.lang.String r1 = "[Read]Version "
- r0.append(r1)
- r0.append(r7)
- java.lang.String r7 = r0.toString()
- com.epson.mobilephone.common.EPLog.i(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- java.lang.String r7 = r7.mSSID
- if (r7 == 0) goto L_0x03a1
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- java.lang.String r7 = r7.mSSID
- boolean r7 = r7.isEmpty()
- if (r7 != 0) goto L_0x03a1
- r6.IncrementSequence()
- java.lang.String r7 = " @@ checkSSID @@ "
- com.epson.mobilephone.common.EPLog.d(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- android.bluetooth.BluetoothGatt r7 = r7.mConnGatt
- if (r7 != 0) goto L_0x0302
- java.lang.String r7 = "mConnGatt NULL !"
- com.epson.mobilephone.common.EPLog.e((java.lang.String) r7)
- L_0x0302:
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- short r7 = r7.getSecurityType()
- r0 = 255(0xff, float:3.57E-43)
- if (r7 != r0) goto L_0x0328
- java.lang.String r7 = " skip "
- com.epson.mobilephone.common.EPLog.d(r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.util.BLEUtility$BleWorkCallback r7 = r7.mSequenceCallbackSuccess
- if (r7 == 0) goto L_0x03a1
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.util.BLEUtility$BleWorkCallback r7 = r7.mSequenceCallbackSuccess
- com.epson.mobilephone.common.ble.BleWork r0 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = r0.mSequence
- r7.call(r0)
- goto L_0x03a1
- L_0x0328:
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- r7.checkSSID()
- goto L_0x03a1
- L_0x032e:
- java.lang.Integer r7 = r7.getIntValue(r1, r4)
- short r7 = r7.shortValue()
- java.lang.Short r7 = java.lang.Short.valueOf(r7)
- java.lang.String r0 = r7.toString()
- java.lang.StringBuilder r1 = new java.lang.StringBuilder
- r1.<init>()
- java.lang.String r2 = "802a0001-4ef4-4e59-b573-2bed4a4ac158\n[Read]Password "
- r1.append(r2)
- r1.append(r0)
- java.lang.String r0 = r1.toString()
- com.epson.mobilephone.common.EPLog.i(r0)
- short r7 = r7.shortValue()
- r0 = 65535(0xffff, float:9.1834E-41)
- if (r7 != r0) goto L_0x0367
- java.lang.String r7 = "password error !"
- com.epson.mobilephone.common.EPLog.e((java.lang.String) r7)
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- com.epson.mobilephone.common.ble.BleWork$jobSequence r0 = com.epson.mobilephone.common.ble.BleWork.jobSequence.FAILED
- r7.mSequence = r0
- goto L_0x03a1
- L_0x0367:
- r6.IncrementSequence()
- com.epson.mobilephone.common.ble.BleWork r7 = com.epson.mobilephone.common.ble.BleWork.this
- r7.checkVersion()
- goto L_0x03a1
- L_0x0370:
- java.lang.String r7 = r7.getStringValue(r4)
- java.lang.StringBuilder r0 = new java.lang.StringBuilder
- r0.<init>()
- java.lang.String r1 = "00002a29-0000-1000-8000-00805f9b34fb\n[Read]Serial Number "
- r0.append(r1)
- r0.append(r7)
- java.lang.String r7 = r0.toString()
- com.epson.mobilephone.common.EPLog.i(r7)
- goto L_0x03a1
- L_0x0389:
- java.lang.String r7 = r7.getStringValue(r4)
- java.lang.StringBuilder r0 = new java.lang.StringBuilder
- r0.<init>()
- java.lang.String r1 = "00002a29-0000-1000-8000-00805f9b34fb\n[Read]Manufacturer Name "
- r0.append(r1)
- r0.append(r7)
- java.lang.String r7 = r0.toString()
- com.epson.mobilephone.common.EPLog.i(r7)
- L_0x03a1:
- return
- */
- throw new UnsupportedOperationException("Method not decompiled: com.epson.mobilephone.common.ble.BleWork.C10141.readCharacteristicData(android.bluetooth.BluetoothGattCharacteristic):void");
- }
- private void IncrementSequence() {
- int ordinal = BleWork.mSequence.ordinal();
- jobSequence[] values = jobSequence.values();
- BleWork.mSequence = values[ordinal + 1];
- EPLog.i("ΔΔ mSequence = " + BleWork.mSequence);
- }
- public void onCharacteristicWrite(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic bluetoothGattCharacteristic, int i) {
- showStatus("Write", i);
- if (i != 0) {
- byte unused = BleWork.mIndex = (byte) 0;
- if (BleWork.mSequence == jobSequence.INITIALIZE) {
- failedProcessing();
- } else if (BleWork.mSequence == jobSequence.MIB_REBOOT_NW) {
- if (BleWork.mSuccess != null) {
- BleWork.mSuccess.call(BleWork.mSequence);
- }
- } else if (BleWork.mFailed != null) {
- BleWork.mFailed.call(BleWork.mSequence);
- }
- } else if (BleWork.mSequence == jobSequence.INITIALIZE) {
- characteristicRead();
- } else if (BleWork.mSequence == jobSequence.MIB_REBOOT_NW && BleWork.mSuccess != null) {
- BleWork.mSuccess.call(BleWork.mSequence);
- }
- }
- private void notifySet(@NonNull BluetoothGattCharacteristic bluetoothGattCharacteristic) {
- if (!BleWork.mConnGatt.setCharacteristicNotification(bluetoothGattCharacteristic, true)) {
- EPLog.e("Notification set ERROR");
- }
- BluetoothGattDescriptor descriptor = bluetoothGattCharacteristic.getDescriptor(UUID.fromString(BLEUuid.CLIENT_CHARACTERISTIC_CONFIG));
- descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
- EPLog.i("notify set");
- if (!BleWork.mConnGatt.writeDescriptor(descriptor)) {
- EPLog.e("Notification write ERROR");
- }
- }
- };
- handlerRead = new Handler();
- handlerWrite = new Handler();
- }
- @NonNull
- public static BleWork getInstace() {
- return SingletonHolder.INSTANCE;
- }
- private static final class SingletonHolder {
- private static final BleWork INSTANCE = new BleWork();
- private SingletonHolder() {
- }
- }
- public void resetSequence() {
- mSequence = jobSequence.UNINITIALIZED;
- mDevice = null;
- mSSIDPassword = null;
- mSsidLis.clear();
- mReconnect = false;
- mConnGatt = null;
- }
- @NonNull
- public static String getSSID(@NonNull Context context) {
- String curSSID = WiFiDirectManager.getCurSSID(context);
- EPLog.i("" + curSSID);
- return (curSSID == null || curSSID.equals("<unknown ssid>")) ? "" : curSSID;
- }
- public static boolean chechSSIDforBle(@NonNull Context context) {
- if (Build.VERSION.SDK_INT <= 28 || ActivityRequestLocationPermission.canAccessWiFiInfo(context, 4)) {
- return !getSSID(context).isEmpty() && !WiFiDirectManager.isSimpleAP(context);
- }
- return WiFiNetworkManager.getInsetance(context).isWiFiValidated();
- }
- public static boolean isStartBleProcess(@NonNull Context context, Boolean bool) {
- BluetoothAdapter adapter;
- BluetoothManager manager = BLEUtility.getManager(context);
- if ((manager != null && ((adapter = manager.getAdapter()) == null || !adapter.isEnabled())) || !BLEUtility.isBLESupported(context)) {
- return false;
- }
- if ((!bool.booleanValue() || MyPrinter.getCurPrinter(context).getName() == null) && chechSSIDforBle(context)) {
- return true;
- }
- return false;
- }
- private void setSequenceCallback(BLEUtility.BleWorkCallback bleWorkCallback, BLEUtility.BleWorkCallback bleWorkCallback2) {
- mSequenceCallbackSuccess = bleWorkCallback;
- mSequenceCallbackFailed = bleWorkCallback2;
- }
- private void setNotifyCallback(BLEUtility.BleWorkCallback bleWorkCallback) {
- mResposne = bleWorkCallback;
- }
- private void setSSID(BLEUtility.BleWorkCallback bleWorkCallback, BLEUtility.BleWorkCallback bleWorkCallback2) {
- mSuccess = bleWorkCallback;
- mFailed = bleWorkCallback2;
- mSequence = jobSequence.MIB_GET_MACADDRESS;
- setSSIDWork();
- }
- public void disconnect(boolean z) {
- EPLog.i("mSequence == " + mSequence + ":: " + mStatus);
- mSequence = z ? jobSequence.DISCONNECTED : mSequence;
- if (mConnGatt != null) {
- int i = mStatus;
- if (!(i == 3 || i == 0)) {
- EPLog.d(" !! mConnGatt disconnect");
- mConnGatt.disconnect();
- }
- EPLog.d(" !! mConnGatt close " + mSequence + " " + mStatus);
- mReconnect = false;
- if (z) {
- gattClose();
- }
- }
- }
- private void gattClose() {
- EPLog.d(" !! mConnGatt close");
- BluetoothGatt bluetoothGatt = mConnGatt;
- if (bluetoothGatt != null) {
- bluetoothGatt.close();
- mConnGatt = null;
- }
- }
- public void disconnect() {
- disconnect(true);
- }
- public void connect() {
- EPLog.i("再接続");
- mReconnect = true;
- mRetry = 0;
- EPLog.e("init");
- init();
- }
- private void setSSIDWork() {
- ((Activity) mContext).runOnUiThread(new Runnable() {
- public void run() {
- startSetSSID();
- }
- });
- }
- private void notifySet(@NonNull BluetoothGattCharacteristic bluetoothGattCharacteristic) {
- if (!mConnGatt.setCharacteristicNotification(bluetoothGattCharacteristic, true)) {
- EPLog.e("Notification set ERROR");
- }
- BluetoothGattDescriptor descriptor = bluetoothGattCharacteristic.getDescriptor(UUID.fromString(BLEUuid.CLIENT_CHARACTERISTIC_CONFIG));
- descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
- EPLog.i("notify set");
- if (!mConnGatt.writeDescriptor(descriptor)) {
- EPLog.e(" writeDescriptor ERROR");
- }
- }
- public class NotifySetThread extends AsyncTask<Void, Void, Boolean> {
- boolean stop;
- boolean success;
- private NotifySetThread() {
- stop = false;
- success = false;
- }
- protected void onPreExecute() {
- super.onPreExecute();
- EPLog.i();
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- setNotifyCallback(new BLEUtility.BleWorkCallback() {
- public void call(@NonNull Object obj) {
- EPLog.i(" -- NotifySetThread call");
- BluetoothGattCharacteristic bluetoothGattCharacteristic = BLEUuid.GattCharsMap.get(BLEUuid.CHAR_SECURITY_TYPE_STRING);
- BluetoothGattCharacteristic bluetoothGattCharacteristic2 = BLEUuid.GattCharsMap.get(BLEUuid.CHAR_SNMP_STATUS_STRING);
- BluetoothGattDescriptor bluetoothGattDescriptor = (BluetoothGattDescriptor) obj;
- if (bluetoothGattCharacteristic == bluetoothGattDescriptor.getCharacteristic()) {
- notifySet(bluetoothGattCharacteristic2);
- } else if (bluetoothGattCharacteristic2 == bluetoothGattDescriptor.getCharacteristic()) {
- NotifySetThread notifySetThread = NotifySetThread.this;
- notifySetThread.stop = true;
- notifySetThread.success = true;
- } else {
- stop = true;
- }
- }
- });
- }
- /* access modifiers changed from: protected */
- @Nullable
- public Boolean doInBackground(Void... voidArr) {
- notifySet(BLEUuid.GattCharsMap.get(BLEUuid.CHAR_SECURITY_TYPE_STRING));
- long currentTimeMillis = System.currentTimeMillis();
- while (System.currentTimeMillis() - currentTimeMillis <= 30000) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- if (stop) {
- }
- }
- if (stop) {
- EPLog.i(" set ended ");
- EPLog.i();
- return Boolean.valueOf(success);
- }
- }
- EPLog.e(" set failed! ");
- return false;
- }
- protected void onPostExecute(Boolean bool) {
- super.onPostExecute(bool);
- if (bool.booleanValue()) {
- try {
- TimeUnit.MILLISECONDS.sleep(500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- BleWork.mSequence = jobSequence.INITIALIZE;
- checkPassword();
- return;
- }
- EPLog.e("setNotify");
- failedProcessing();
- }
- }
- private void characteristicRead() {
- EPLog.i("read " + mSequence);
- if (mSequence != jobSequence.MIB_REBOOT_NW) {
- final int[] iArr = {0};
- handlerRead.postDelayed(new Runnable() {
- public void run() {
- switch (C10195.$SwitchMap$com$epson$mobilephone$common$ble$BleWork$jobSequence[BleWork.mSequence.ordinal()]) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 11:
- try {
- if (!((BluetoothGatt) Objects.requireNonNull(BleWork.mConnGatt)).readCharacteristic(BLEUuid.GattCharsMap.get(BLEUuid.CHAR_SNMP_RESPONSE_STRING))) {
- int[] iArr = iArr;
- int i = iArr[0] + 1;
- iArr[0] = i;
- if (i < 3) {
- EPLog.e("FALSE !! retry " + iArr[0]);
- handlerRead.removeCallbacks((Runnable) null);
- handlerRead.postDelayed(this, (long) (iArr[0] * 500));
- return;
- }
- EPLog.e("FALSE !!!");
- sequenceError();
- return;
- }
- return;
- } catch (NullPointerException unused) {
- EPLog.e("mConnGatt NULL !");
- return;
- }
- case 9:
- if (!BleWork.mConnGatt.readCharacteristic(BLEUuid.GattCharsMap.get(BLEUuid.CHAR_PASSWORD_STRING))) {
- EPLog.e("FALSE !! ");
- return;
- }
- return;
- case 10:
- if (!BleWork.mConnGatt.readCharacteristic(BLEUuid.GattCharsMap.get(BLEUuid.CHAR_VERSION_STRING))) {
- EPLog.e("FALSE !! ");
- return;
- }
- return;
- default:
- return;
- }
- }
- }, 0);
- }
- }
- private boolean init() {
- int i;
- mEscprlib.epsWrapperInitDriver(mContext.getApplicationContext(), 2);
- if (!BLEUtility.isBLESupported(mContext)) {
- return false;
- }
- BluetoothManager manager = BLEUtility.getManager(mContext);
- if (manager != null) {
- mBTAdapter = manager.getAdapter();
- }
- if (mBTAdapter == null) {
- return false;
- }
- if (mDevice == null) {
- mDevice = mSelectItem.getDevice();
- if (mDevice == null) {
- EPLog.e("mDevice is null !!!");
- return false;
- }
- }
- byte[] hardwareType = mSelectItem.getHardwareType();
- if (hardwareType.length >= 3) {
- i = 4096 - ByteBuffer.wrap(new byte[]{0, 0, hardwareType[2], hardwareType[1]}).getInt();
- } else {
- i = Constants.EDAM_APPLICATIONDATA_ENTRY_LEN_MAX;
- }
- EPLog.d("password = " + i);
- mDevicePassword = String.valueOf(i);
- if (mConnGatt == null && mStatus == 0) {
- EPLog.i("connectGatt");
- mConnGatt = mDevice.connectGatt(mContext, false, mGattcallback);
- mStatus = 1;
- if (!mReconnect) {
- mSequence = jobSequence.UNINITIALIZED;
- }
- } else if (mConnGatt != null) {
- EPLog.i("re-connect and re-discover Services");
- mConnGatt.close();
- mConnGatt = mDevice.connectGatt(mContext, false, mGattcallback);
- mConnGatt.connect();
- mConnGatt.discoverServices();
- if (!mReconnect) {
- mSequence = jobSequence.INITIALIZE;
- }
- } else {
- EPLog.i(" STATE_CONNECTING");
- mConnGatt = mDevice.connectGatt(mContext, false, mGattcallback);
- mStatus = 1;
- if (!mReconnect) {
- mSequence = jobSequence.DISCONNECTED;
- }
- }
- return true;
- }
- public boolean init(@NonNull Context context, @NonNull ScannedDevice scannedDevice) {
- mContext = context;
- mSelectItem = scannedDevice;
- mRetry = 0;
- mSequence = jobSequence.UNINITIALIZED;
- setSecurityType(0);
- mReconnect = true;
- mSSID = getSSID(mContext);
- EPLog.i(mSSID);
- EPLog.e("init");
- return init();
- }
- public void checkPassword() {
- EPLog.i();
- String str = mDevicePassword;
- if (!str.isEmpty()) {
- BluetoothGattCharacteristic bluetoothGattCharacteristic = BLEUuid.GattCharsMap.get(BLEUuid.CHAR_PASSWORD_STRING);
- bluetoothGattCharacteristic.setValue(Short.parseShort(str), 18, 0);
- EPLog.i("Password write :" + str);
- gattWriteCharacter(bluetoothGattCharacteristic);
- }
- }
- private void gattWriteCharacter(final BluetoothGattCharacteristic bluetoothGattCharacteristic) {
- final int[] iArr = {0};
- handlerWrite.removeCallbacks((Runnable) null);
- handlerWrite.postDelayed(new Runnable() {
- public void run() {
- if (BleWork.mConnGatt == null) {
- EPLog.e("mConnGatt NULL !");
- }
- if (bluetoothGattCharacteristic == null) {
- EPLog.e("characteristic NULL !");
- }
- try {
- if (!((BluetoothGatt) Objects.requireNonNull(BleWork.mConnGatt)).writeCharacteristic(bluetoothGattCharacteristic)) {
- int[] iArr = iArr;
- int i = iArr[0] + 1;
- iArr[0] = i;
- if (i <= 3) {
- EPLog.e("writeCharacteristic error ! retry " + iArr[0]);
- handlerWrite.removeCallbacks((Runnable) null);
- handlerWrite.postDelayed(this, (long) (iArr[0] * 500));
- return;
- }
- EPLog.e("writeCharacteristic error !! retry failed !!");
- failedProcessing();
- }
- } catch (NullPointerException unused) {
- EPLog.e("mConnGatt NULL !");
- }
- }
- }, 0);
- }
- public void checkVersion() {
- characteristicRead();
- }
- public void getSSIDList() {
- mInSequence = true;
- mSequence = jobSequence.MIB_GET_SSID_LIST;
- EscprLib escprLib = mEscprlib;
- MIBCommand mIBCommand = mMibCommand;
- byte b = (byte) (mIndex + 1);
- mIndex = b;
- int mibGetESSIDList = escprLib.mibGetESSIDList(mIBCommand, b);
- if (mibGetESSIDList != 0) {
- EPLog.e("mibGetESSIDList ret = " + mibGetESSIDList);
- return;
- }
- byte[] bArr = new byte[mMibCommand.commandBlock.bufSize];
- System.arraycopy(mMibCommand.commandBlock.buf, 0, bArr, 0, mMibCommand.commandBlock.bufSize);
- BluetoothGattCharacteristic bluetoothGattCharacteristic = BLEUuid.GattCharsMap.get(BLEUuid.CHAR_SNMP_REQUEST_STRING);
- bluetoothGattCharacteristic.setValue(bArr);
- gattWriteCharacter(bluetoothGattCharacteristic);
- }
- private void checkSSID() {
- try {
- TimeUnit.SECONDS.sleep(1);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- byte[] bytes = mSSID.getBytes(Charset.forName("UTF8"));
- BluetoothGattCharacteristic bluetoothGattCharacteristic = BLEUuid.GattCharsMap.get(BLEUuid.CHAR_SSID_STRING);
- bluetoothGattCharacteristic.setValue(bytes);
- EPLog.i("SSID write :" + mSSID);
- gattWriteCharacter(bluetoothGattCharacteristic);
- }
- public void setSSIDType() {
- mSequence = jobSequence.CHECK_SSID;
- if (mConnGatt == null) {
- EPLog.e("mConnGatt NULL !");
- }
- checkSSID();
- }
- private void startSetSSID() {
- int i;
- EPLog.i("mSequence = " + mSequence + " mSSID = " + mSSID);
- mInSequence = false;
- String str = "";
- String str2 = "";
- switch (mSequence) {
- case MIB_GET_MACADDRESS:
- str = "epsGetMacAddress";
- str2 = "mibGetMacadress";
- i = mEscprlib.mibGetMacadress(mMibCommand);
- break;
- case MIB_SET_SSID:
- str = "epsWlanConfSSID";
- str2 = "mibSetSSID";
- EPLog.i("mSSID " + mSSID);
- if (!mSSID.isEmpty()) {
- i = mEscprlib.mibSetSSID(mMibCommand, mSSID);
- break;
- } else {
- EPLog.m82w("set SSID : empty");
- return;
- }
- case MIB_SEC_LOGIN:
- str = "epsAdminMibAccessLoginOperation";
- str2 = "mibSecLogin ";
- if (mEngineID == null) {
- EPLog.e("mEngineID");
- failedProcessing();
- }
- i = mEscprlib.mibSecLogin(mMibCommand, mEngineID);
- break;
- case MIB_SEC_SET_PASS:
- str = "epsWlanCommonPassPhrase";
- str2 = "mibSecSetPass ";
- String str3 = mSSIDPassword;
- EPLog.i("mSSIDPassword " + mSSIDPassword);
- if (str3.isEmpty()) {
- EPLog.m82w("SSIDPassword is empty");
- }
- if (mEngineID == null) {
- EPLog.e("mEngineID");
- failedProcessing();
- }
- i = mEscprlib.mibSecSetPassword(mMibCommand, mEngineID, str3);
- break;
- case MIB_SEC_LOGOUT:
- str = "epsAdminMibAccessLogOutOperation";
- str2 = "mibSecLogout ";
- if (mEngineID == null) {
- EPLog.e("mEngineID");
- failedProcessing();
- }
- i = mEscprlib.mibSecLogout(mMibCommand, mEngineID);
- break;
- case MIB_SET_SECURITY_TYPE:
- str = "epsWlanSecurityType";
- str2 = "mibSetSecurityType ";
- if (mSSIDPassword == null) {
- mSSIDPassword = "";
- }
- int i2 = mSSIDPassword.isEmpty() ? 0 : 255;
- EPLog.i("MIB_SET_SECURITY_TYPE SecurityType = " + i2);
- int mibSetSecurityType = mEscprlib.mibSetSecurityType(mMibCommand, i2);
- if (i2 == 0) {
- mSequence = jobSequence.MIB_SEC_SKIP;
- }
- i = mibSetSecurityType;
- break;
- case MIB_REBOOT_NW:
- str = "epsBluetoothOperationSetupEnd";
- str2 = "mibRebootNW ";
- i = mEscprlib.mibRebootNWwithBLE(mMibCommand);
- break;
- default:
- i = 0;
- break;
- }
- if (i != 0) {
- EPLog.e(str2 + " ret = " + i);
- sequenceError();
- return;
- }
- byte[] bArr = new byte[mMibCommand.commandBlock.bufSize];
- System.arraycopy(mMibCommand.commandBlock.buf, 0, bArr, 0, mMibCommand.commandBlock.bufSize);
- EPLog.i("SNMP Request write :" + str + " mSequence " + mSequence);
- BluetoothGattCharacteristic bluetoothGattCharacteristic = BLEUuid.GattCharsMap.get(BLEUuid.CHAR_SNMP_REQUEST_STRING);
- bluetoothGattCharacteristic.setValue(bArr);
- gattWriteCharacter(bluetoothGattCharacteristic);
- }
- private void sequenceError() {
- failedProcessing();
- }
- private void failedProcessing() {
- disconnect();
- if (mSequenceCallbackFailed != null) {
- EPLog.e(" " + mSequence);
- mSequenceCallbackFailed.call(mSequence);
- }
- }
- }
|