| | |
| | | } catch (Exception ignored) { |
| | | |
| | | } |
| | | if (ActivityCompat.checkSelfPermission(HDLApp.getInstance(), Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) { |
| | | // TODO: Consider calling |
| | | // ActivityCompat#requestPermissions |
| | | // here to request the missing permissions, and then overriding |
| | | // public void onRequestPermissionsResult(int requestCode, String[] permissions, |
| | | // int[] grantResults) |
| | | // to handle the case where the user grants the permission. See the documentation |
| | | // for ActivityCompat#requestPermissions for more details. |
| | | return; |
| | | } |
| | | HdlBluetoothLogic.getInstance().stopScan(); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | break; |
| | | case HDLUniMP.UNI_EVENT_REPLY_BLUETOOTH_Connect: { |
| | | //先停止吧,再连接 |
| | | HdlBluetoothLogic.getInstance().stopScan(); |
| | | //连接蓝牙 |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | HdlBluetoothLogic.getInstance().connect(mac, new BleWifiConfiguratorUtils.ConnectListener() { |
| | |
| | | HdlBluetoothLogic.getInstance().sendConfig(objString, new BleWifiConfiguratorUtils.WriteListener() { |
| | | @Override |
| | | public void onWriteSuccess() { |
| | | |
| | | Log.d("HdlUniLogic", "onWriteSuccess: "); |
| | | } |
| | | |
| | | @Override |
| | | public void onWriteComplete(boolean success) { |
| | | |
| | | Log.d("HdlUniLogic", "onWriteComplete: " + success); |
| | | } |
| | | |
| | | @Override |
| | | public void onWriteFailed(int status) { |
| | | Log.d("HdlUniLogic", "onWriteFailed: "); |
| | | uniCallbackData(type, status, -2, "write failed", callback); |
| | | } |
| | | |
| | | @Override |
| | | public void onDeviceResponse(String response) { |
| | | Log.d("HdlUniLogic", "onDeviceResponse: "); |
| | | uniSuccessCallback(mode_type, response, callback); |
| | | } |
| | | }); |