Browse Source

移除蓝牙

panxingxin 5 years ago
parent
commit
a0d934e04d

+ 0 - 21
package-lock.json

@@ -743,22 +743,6 @@
         }
       }
     },
-    "@ionic-native/bluetooth-le": {
-      "version": "5.16.0",
-      "resolved": "https://registry.npmjs.org/@ionic-native/bluetooth-le/-/bluetooth-le-5.16.0.tgz",
-      "integrity": "sha512-I/qjw8rfvPJOqpfEU1ZdIMtR3YJOrijMpTpmsUfE/ycbso0MkWNyCNxpDnYqkwPRuEmlQHZGVOhNVADDZdU7Vg==",
-      "requires": {
-        "@types/cordova": "^0.0.34"
-      }
-    },
-    "@ionic-native/bluetooth-serial": {
-      "version": "5.16.0",
-      "resolved": "https://registry.npmjs.org/@ionic-native/bluetooth-serial/-/bluetooth-serial-5.16.0.tgz",
-      "integrity": "sha512-i/g4++WbdG+glpCK49v1qZ7bj6Xg/BRd4UiqA7/FsOEfM6ArNJXKeoKBkEC8+A9LbwWcA5iFUqJlMcNKYJJlMg==",
-      "requires": {
-        "@types/cordova": "^0.0.34"
-      }
-    },
     "@ionic-native/camera": {
       "version": "5.16.0",
       "resolved": "https://registry.npmjs.org/@ionic-native/camera/-/camera-5.16.0.tgz",
@@ -2844,11 +2828,6 @@
       "resolved": "https://registry.npmjs.org/cordova-plugin-badge/-/cordova-plugin-badge-0.8.8.tgz",
       "integrity": "sha512-RhIBtd5xhD/iLnxjt35jvOae28oNW/wtMZBOmQR3Rf0y4wirvA1bpAZEhBoFqL+rZGhsd6ddOdQXdex1T0DRyQ=="
     },
-    "cordova-plugin-bluetooth-serial": {
-      "version": "0.4.7",
-      "resolved": "https://registry.npmjs.org/cordova-plugin-bluetooth-serial/-/cordova-plugin-bluetooth-serial-0.4.7.tgz",
-      "integrity": "sha1-HkYG7G1Ct8I/YKdKh8fEpOw4KMA="
-    },
     "cordova-plugin-bluetoothle": {
       "version": "4.5.6",
       "resolved": "https://registry.npmjs.org/cordova-plugin-bluetoothle/-/cordova-plugin-bluetoothle-4.5.6.tgz",

+ 0 - 6
package.json

@@ -28,8 +28,6 @@
     "@ionic-native/app-version": "^5.16.0",
     "@ionic-native/barcode-scanner": "^5.16.0",
     "@ionic-native/base64": "^5.18.0",
-    "@ionic-native/bluetooth-le": "^5.15.1",
-    "@ionic-native/bluetooth-serial": "^5.15.1",
     "@ionic-native/camera": "^5.5.1",
     "@ionic-native/core": "^5.0.0",
     "@ionic-native/date-picker": "^5.17.1",
@@ -56,8 +54,6 @@
     "cordova-plugin-advanced-http": "2.0.9",
     "cordova-plugin-app-version": "^0.1.9",
     "cordova-plugin-badge": "^0.8.8",
-    "cordova-plugin-bluetooth-serial": "^0.4.7",
-    "cordova-plugin-bluetoothle": "^4.5.5",
     "cordova-plugin-camera": "4.0.3",
     "cordova-plugin-datepicker": "^0.9.3",
     "cordova-plugin-file": "6.0.1",
@@ -119,8 +115,6 @@
       "cordova-plugin-camera": {},
       "cordova-sqlite-storage": {},
       "cordova-plugin-advanced-http": {},
-      "cordova-plugin-bluetoothle": {},
-      "cordova-plugin-bluetooth-serial": {},
       "cordova-plugin-local-notification": {},
       "cordova-plugin-app-version": {},
       "cordova-plugin-file-opener2": {

+ 1 - 46
platforms/android/android.json

@@ -28,10 +28,6 @@
               "xml": "<feature name=\"AppVersion\"><param name=\"android-package\" value=\"uk.co.whiteoctober.cordova.AppVersion\" /></feature>",
               "count": 1
             },
-            {
-              "xml": "<feature name=\"BluetoothLePlugin\"><param name=\"android-package\" value=\"com.randdusing.bluetoothle.BluetoothLePlugin\" /></feature>",
-              "count": 1
-            },
             {
               "xml": "<feature name=\"Camera\"><param name=\"android-package\" value=\"org.apache.cordova.camera.CameraLauncher\" /></feature>",
               "count": 1
@@ -85,12 +81,7 @@
               "count": 1
             }
           ],
-          "/widget": [
-            {
-              "xml": "<feature name=\"BluetoothSerial\"><param name=\"android-package\" value=\"com.megster.cordova.BluetoothSerial\" /></feature>",
-              "count": 1
-            }
-          ]
+          "/widget": []
         }
       },
       "AndroidManifest.xml": {
@@ -146,18 +137,6 @@
               "xml": "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" />",
               "count": 1
             },
-            {
-              "xml": "<uses-permission android:name=\"android.permission.BLUETOOTH\" />",
-              "count": 2
-            },
-            {
-              "xml": "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" />",
-              "count": 2
-            },
-            {
-              "xml": "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />",
-              "count": 2
-            },
             {
               "xml": "<uses-permission android:name=\"android.permission.WAKE_LOCK\" />",
               "count": 1
@@ -250,12 +229,6 @@
     "cordova-plugin-badge": {
       "PACKAGE_NAME": "com.ionicframework.sgZongLi"
     },
-    "cordova-plugin-bluetooth-serial": {
-      "PACKAGE_NAME": "com.ionicframework.sgZongLi"
-    },
-    "cordova-plugin-bluetoothle": {
-      "PACKAGE_NAME": "com.ionicframework.sgZongLi"
-    },
     "cordova-plugin-camera": {
       "PACKAGE_NAME": "com.ionicframework.sgZongLi"
     },
@@ -562,22 +535,6 @@
         "cordova.plugins.notification.badge"
       ]
     },
-    {
-      "id": "cordova-plugin-bluetooth-serial.bluetoothSerial",
-      "file": "plugins/cordova-plugin-bluetooth-serial/www/bluetoothSerial.js",
-      "pluginId": "cordova-plugin-bluetooth-serial",
-      "clobbers": [
-        "window.bluetoothSerial"
-      ]
-    },
-    {
-      "id": "cordova-plugin-bluetoothle.BluetoothLe",
-      "file": "plugins/cordova-plugin-bluetoothle/www/bluetoothle.js",
-      "pluginId": "cordova-plugin-bluetoothle",
-      "clobbers": [
-        "window.bluetoothle"
-      ]
-    },
     {
       "id": "cordova-plugin-camera.Camera",
       "file": "plugins/cordova-plugin-camera/www/CameraConstants.js",
@@ -747,8 +704,6 @@
     "cordova-plugin-advanced-http": "2.0.9",
     "cordova-plugin-app-version": "0.1.9",
     "cordova-plugin-badge": "0.8.8",
-    "cordova-plugin-bluetooth-serial": "0.4.7",
-    "cordova-plugin-bluetoothle": "4.5.5",
     "cordova-plugin-camera": "4.0.3",
     "cordova-plugin-device": "2.0.2",
     "cordova-plugin-file-opener2": "2.2.1",

+ 0 - 3
platforms/android/app/src/main/AndroidManifest.xml

@@ -28,9 +28,6 @@
     </application>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
-    <uses-permission android:name="android.permission.BLUETOOTH" />
-    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
-    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="android.permission.CAMERA" />
     <uses-permission android:name="android.permission.FLASHLIGHT" />

+ 0 - 490
platforms/android/app/src/main/java/com/megster/cordova/BluetoothSerial.java

@@ -1,490 +0,0 @@
-package com.megster.cordova;
-
-import android.Manifest;
-import android.content.pm.PackageManager;
-
-import android.app.Activity;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Handler;
-import android.os.Message;
-import android.provider.Settings;
-import android.util.Log;
-import org.apache.cordova.CordovaArgs;
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.PluginResult;
-import org.apache.cordova.LOG;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.Set;
-
-/**
- * PhoneGap Plugin for Serial Communication over Bluetooth
- */
-public class BluetoothSerial extends CordovaPlugin {
-
-    // actions
-    private static final String LIST = "list";
-    private static final String CONNECT = "connect";
-    private static final String CONNECT_INSECURE = "connectInsecure";
-    private static final String DISCONNECT = "disconnect";
-    private static final String WRITE = "write";
-    private static final String AVAILABLE = "available";
-    private static final String READ = "read";
-    private static final String READ_UNTIL = "readUntil";
-    private static final String SUBSCRIBE = "subscribe";
-    private static final String UNSUBSCRIBE = "unsubscribe";
-    private static final String SUBSCRIBE_RAW = "subscribeRaw";
-    private static final String UNSUBSCRIBE_RAW = "unsubscribeRaw";
-    private static final String IS_ENABLED = "isEnabled";
-    private static final String IS_CONNECTED = "isConnected";
-    private static final String CLEAR = "clear";
-    private static final String SETTINGS = "showBluetoothSettings";
-    private static final String ENABLE = "enable";
-    private static final String DISCOVER_UNPAIRED = "discoverUnpaired";
-    private static final String SET_DEVICE_DISCOVERED_LISTENER = "setDeviceDiscoveredListener";
-    private static final String CLEAR_DEVICE_DISCOVERED_LISTENER = "clearDeviceDiscoveredListener";
-    private static final String SET_NAME = "setName";
-    private static final String SET_DISCOVERABLE = "setDiscoverable";
-
-    // callbacks
-    private CallbackContext connectCallback;
-    private CallbackContext dataAvailableCallback;
-    private CallbackContext rawDataAvailableCallback;
-    private CallbackContext enableBluetoothCallback;
-    private CallbackContext deviceDiscoveredCallback;
-
-    private BluetoothAdapter bluetoothAdapter;
-    private BluetoothSerialService bluetoothSerialService;
-
-    // Debugging
-    private static final String TAG = "BluetoothSerial";
-    private static final boolean D = true;
-
-    // Message types sent from the BluetoothSerialService Handler
-    public static final int MESSAGE_STATE_CHANGE = 1;
-    public static final int MESSAGE_READ = 2;
-    public static final int MESSAGE_WRITE = 3;
-    public static final int MESSAGE_DEVICE_NAME = 4;
-    public static final int MESSAGE_TOAST = 5;
-    public static final int MESSAGE_READ_RAW = 6;
-
-    // Key names received from the BluetoothChatService Handler
-    public static final String DEVICE_NAME = "device_name";
-    public static final String TOAST = "toast";
-
-    StringBuffer buffer = new StringBuffer();
-    private String delimiter;
-    private static final int REQUEST_ENABLE_BLUETOOTH = 1;
-
-    // Android 23 requires user to explicitly grant permission for location to discover unpaired
-    private static final String ACCESS_COARSE_LOCATION = Manifest.permission.ACCESS_COARSE_LOCATION;
-    private static final int CHECK_PERMISSIONS_REQ_CODE = 2;
-    private CallbackContext permissionCallback;
-
-    @Override
-    public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
-
-        LOG.d(TAG, "action = " + action);
-
-        if (bluetoothAdapter == null) {
-            bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
-        }
-
-        if (bluetoothSerialService == null) {
-            bluetoothSerialService = new BluetoothSerialService(mHandler);
-        }
-
-        boolean validAction = true;
-
-        if (action.equals(LIST)) {
-
-            listBondedDevices(callbackContext);
-
-        } else if (action.equals(CONNECT)) {
-
-            boolean secure = true;
-            connect(args, secure, callbackContext);
-
-        } else if (action.equals(CONNECT_INSECURE)) {
-
-            // see Android docs about Insecure RFCOMM http://goo.gl/1mFjZY
-            boolean secure = false;
-            connect(args, secure, callbackContext);
-
-        } else if (action.equals(DISCONNECT)) {
-
-            connectCallback = null;
-            bluetoothSerialService.stop();
-            callbackContext.success();
-
-        } else if (action.equals(WRITE)) {
-
-            byte[] data = args.getArrayBuffer(0);
-            bluetoothSerialService.write(data);
-            callbackContext.success();
-
-        } else if (action.equals(AVAILABLE)) {
-
-            callbackContext.success(available());
-
-        } else if (action.equals(READ)) {
-
-            callbackContext.success(read());
-
-        } else if (action.equals(READ_UNTIL)) {
-
-            String interesting = args.getString(0);
-            callbackContext.success(readUntil(interesting));
-
-        } else if (action.equals(SUBSCRIBE)) {
-
-            delimiter = args.getString(0);
-            dataAvailableCallback = callbackContext;
-
-            PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
-            result.setKeepCallback(true);
-            callbackContext.sendPluginResult(result);
-
-        } else if (action.equals(UNSUBSCRIBE)) {
-
-            delimiter = null;
-
-            // send no result, so Cordova won't hold onto the data available callback anymore
-            PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
-            dataAvailableCallback.sendPluginResult(result);
-            dataAvailableCallback = null;
-
-            callbackContext.success();
-
-        } else if (action.equals(SUBSCRIBE_RAW)) {
-
-            rawDataAvailableCallback = callbackContext;
-
-            PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
-            result.setKeepCallback(true);
-            callbackContext.sendPluginResult(result);
-
-        } else if (action.equals(UNSUBSCRIBE_RAW)) {
-
-            rawDataAvailableCallback = null;
-
-            callbackContext.success();
-
-        } else if (action.equals(IS_ENABLED)) {
-
-            if (bluetoothAdapter.isEnabled()) {
-                callbackContext.success();
-            } else {
-                callbackContext.error("Bluetooth is disabled.");
-            }
-
-        } else if (action.equals(IS_CONNECTED)) {
-
-            if (bluetoothSerialService.getState() == BluetoothSerialService.STATE_CONNECTED) {
-                callbackContext.success();
-            } else {
-                callbackContext.error("Not connected.");
-            }
-
-        } else if (action.equals(CLEAR)) {
-
-            buffer.setLength(0);
-            callbackContext.success();
-
-        } else if (action.equals(SETTINGS)) {
-
-            Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
-            cordova.getActivity().startActivity(intent);
-            callbackContext.success();
-
-        } else if (action.equals(ENABLE)) {
-
-            enableBluetoothCallback = callbackContext;
-            Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
-            cordova.startActivityForResult(this, intent, REQUEST_ENABLE_BLUETOOTH);
-
-        } else if (action.equals(DISCOVER_UNPAIRED)) {
-
-            if (cordova.hasPermission(ACCESS_COARSE_LOCATION)) {
-                discoverUnpairedDevices(callbackContext);
-            } else {
-                permissionCallback = callbackContext;
-                cordova.requestPermission(this, CHECK_PERMISSIONS_REQ_CODE, ACCESS_COARSE_LOCATION);
-            }
-
-        } else if (action.equals(SET_DEVICE_DISCOVERED_LISTENER)) {
-
-            this.deviceDiscoveredCallback = callbackContext;
-
-        } else if (action.equals(CLEAR_DEVICE_DISCOVERED_LISTENER)) {
-
-            this.deviceDiscoveredCallback = null;
-
-        } else if (action.equals(SET_NAME)) {
-
-            String newName = args.getString(0);
-            bluetoothAdapter.setName(newName);
-            callbackContext.success();
-
-        } else if (action.equals(SET_DISCOVERABLE)) {
-
-            int discoverableDuration = args.getInt(0);
-            Intent discoverIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
-            discoverIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, discoverableDuration);
-            cordova.getActivity().startActivity(discoverIntent);
-
-        } else {
-            validAction = false;
-
-        }
-
-        return validAction;
-    }
-
-    @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
-
-        if (requestCode == REQUEST_ENABLE_BLUETOOTH) {
-
-            if (resultCode == Activity.RESULT_OK) {
-                Log.d(TAG, "User enabled Bluetooth");
-                if (enableBluetoothCallback != null) {
-                    enableBluetoothCallback.success();
-                }
-            } else {
-                Log.d(TAG, "User did *NOT* enable Bluetooth");
-                if (enableBluetoothCallback != null) {
-                    enableBluetoothCallback.error("User did not enable Bluetooth");
-                }
-            }
-
-            enableBluetoothCallback = null;
-        }
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        if (bluetoothSerialService != null) {
-            bluetoothSerialService.stop();
-        }
-    }
-
-    private void listBondedDevices(CallbackContext callbackContext) throws JSONException {
-        JSONArray deviceList = new JSONArray();
-        Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
-
-        for (BluetoothDevice device : bondedDevices) {
-            deviceList.put(deviceToJSON(device));
-        }
-        callbackContext.success(deviceList);
-    }
-
-    private void discoverUnpairedDevices(final CallbackContext callbackContext) throws JSONException {
-
-        final CallbackContext ddc = deviceDiscoveredCallback;
-
-        final BroadcastReceiver discoverReceiver = new BroadcastReceiver() {
-
-            private JSONArray unpairedDevices = new JSONArray();
-
-            public void onReceive(Context context, Intent intent) {
-                String action = intent.getAction();
-                if (BluetoothDevice.ACTION_FOUND.equals(action)) {
-                    BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
-                    try {
-                    	JSONObject o = deviceToJSON(device);
-                        unpairedDevices.put(o);
-                        if (ddc != null) {
-                            PluginResult res = new PluginResult(PluginResult.Status.OK, o);
-                            res.setKeepCallback(true);
-                            ddc.sendPluginResult(res);
-                        }
-                    } catch (JSONException e) {
-                        // This shouldn't happen, log and ignore
-                        Log.e(TAG, "Problem converting device to JSON", e);
-                    }
-                } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
-                    callbackContext.success(unpairedDevices);
-                    cordova.getActivity().unregisterReceiver(this);
-                }
-            }
-        };
-
-        Activity activity = cordova.getActivity();
-        activity.registerReceiver(discoverReceiver, new IntentFilter(BluetoothDevice.ACTION_FOUND));
-        activity.registerReceiver(discoverReceiver, new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED));
-        bluetoothAdapter.startDiscovery();
-    }
-
-    private JSONObject deviceToJSON(BluetoothDevice device) throws JSONException {
-        JSONObject json = new JSONObject();
-        json.put("name", device.getName());
-        json.put("address", device.getAddress());
-        json.put("id", device.getAddress());
-        if (device.getBluetoothClass() != null) {
-            json.put("class", device.getBluetoothClass().getDeviceClass());
-        }
-        return json;
-    }
-
-    private void connect(CordovaArgs args, boolean secure, CallbackContext callbackContext) throws JSONException {
-        String macAddress = args.getString(0);
-        BluetoothDevice device = bluetoothAdapter.getRemoteDevice(macAddress);
-
-        if (device != null) {
-            connectCallback = callbackContext;
-            bluetoothSerialService.connect(device, secure);
-            buffer.setLength(0);
-
-            PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
-            result.setKeepCallback(true);
-            callbackContext.sendPluginResult(result);
-
-        } else {
-            callbackContext.error("Could not connect to " + macAddress);
-        }
-    }
-
-    // The Handler that gets information back from the BluetoothSerialService
-    // Original code used handler for the because it was talking to the UI.
-    // Consider replacing with normal callbacks
-    private final Handler mHandler = new Handler() {
-
-         public void handleMessage(Message msg) {
-             switch (msg.what) {
-                 case MESSAGE_READ:
-                    buffer.append((String)msg.obj);
-
-                    if (dataAvailableCallback != null) {
-                        sendDataToSubscriber();
-                    }
-
-                    break;
-                 case MESSAGE_READ_RAW:
-                    if (rawDataAvailableCallback != null) {
-                        byte[] bytes = (byte[]) msg.obj;
-                        sendRawDataToSubscriber(bytes);
-                    }
-                    break;
-                 case MESSAGE_STATE_CHANGE:
-
-                    if(D) Log.i(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
-                    switch (msg.arg1) {
-                        case BluetoothSerialService.STATE_CONNECTED:
-                            Log.i(TAG, "BluetoothSerialService.STATE_CONNECTED");
-                            notifyConnectionSuccess();
-                            break;
-                        case BluetoothSerialService.STATE_CONNECTING:
-                            Log.i(TAG, "BluetoothSerialService.STATE_CONNECTING");
-                            break;
-                        case BluetoothSerialService.STATE_LISTEN:
-                            Log.i(TAG, "BluetoothSerialService.STATE_LISTEN");
-                            break;
-                        case BluetoothSerialService.STATE_NONE:
-                            Log.i(TAG, "BluetoothSerialService.STATE_NONE");
-                            break;
-                    }
-                    break;
-                case MESSAGE_WRITE:
-                    //  byte[] writeBuf = (byte[]) msg.obj;
-                    //  String writeMessage = new String(writeBuf);
-                    //  Log.i(TAG, "Wrote: " + writeMessage);
-                    break;
-                case MESSAGE_DEVICE_NAME:
-                    Log.i(TAG, msg.getData().getString(DEVICE_NAME));
-                    break;
-                case MESSAGE_TOAST:
-                    String message = msg.getData().getString(TOAST);
-                    notifyConnectionLost(message);
-                    break;
-             }
-         }
-    };
-
-    private void notifyConnectionLost(String error) {
-        if (connectCallback != null) {
-            connectCallback.error(error);
-            connectCallback = null;
-        }
-    }
-
-    private void notifyConnectionSuccess() {
-        if (connectCallback != null) {
-            PluginResult result = new PluginResult(PluginResult.Status.OK);
-            result.setKeepCallback(true);
-            connectCallback.sendPluginResult(result);
-        }
-    }
-
-    private void sendRawDataToSubscriber(byte[] data) {
-        if (data != null && data.length > 0) {
-            PluginResult result = new PluginResult(PluginResult.Status.OK, data);
-            result.setKeepCallback(true);
-            rawDataAvailableCallback.sendPluginResult(result);
-        }
-    }
-
-    private void sendDataToSubscriber() {
-        String data = readUntil(delimiter);
-        if (data != null && data.length() > 0) {
-            PluginResult result = new PluginResult(PluginResult.Status.OK, data);
-            result.setKeepCallback(true);
-            dataAvailableCallback.sendPluginResult(result);
-
-            sendDataToSubscriber();
-        }
-    }
-
-    private int available() {
-        return buffer.length();
-    }
-
-    private String read() {
-        int length = buffer.length();
-        String data = buffer.substring(0, length);
-        buffer.delete(0, length);
-        return data;
-    }
-
-    private String readUntil(String c) {
-        String data = "";
-        int index = buffer.indexOf(c, 0);
-        if (index > -1) {
-            data = buffer.substring(0, index + c.length());
-            buffer.delete(0, index + c.length());
-        }
-        return data;
-    }
-
-    @Override
-    public void onRequestPermissionResult(int requestCode, String[] permissions,
-                                          int[] grantResults) throws JSONException {
-
-        for(int result:grantResults) {
-            if(result == PackageManager.PERMISSION_DENIED) {
-                LOG.d(TAG, "User *rejected* location permission");
-                this.permissionCallback.sendPluginResult(new PluginResult(
-                        PluginResult.Status.ERROR,
-                        "Location permission is required to discover unpaired devices.")
-                    );
-                return;
-            }
-        }
-
-        switch(requestCode) {
-            case CHECK_PERMISSIONS_REQ_CODE:
-                LOG.d(TAG, "User granted location permission");
-                discoverUnpairedDevices(permissionCallback);
-                break;
-        }
-    }
-}

+ 0 - 499
platforms/android/app/src/main/java/com/megster/cordova/BluetoothSerialService.java

@@ -1,499 +0,0 @@
-package com.megster.cordova;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.UUID;
-import java.util.Arrays;
-
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothServerSocket;
-import android.bluetooth.BluetoothSocket;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-
-/**
- * This class does all the work for setting up and managing Bluetooth
- * connections with other devices. It has a thread that listens for
- * incoming connections, a thread for connecting with a device, and a
- * thread for performing data transmissions when connected.
- *
- * This code was based on the Android SDK BluetoothChat Sample
- * $ANDROID_SDK/samples/android-17/BluetoothChat
- */
-public class BluetoothSerialService {
-
-    // Debugging
-    private static final String TAG = "BluetoothSerialService";
-    private static final boolean D = true;
-
-    // Name for the SDP record when creating server socket
-    private static final String NAME_SECURE = "PhoneGapBluetoothSerialServiceSecure";
-    private static final String NAME_INSECURE = "PhoneGapBluetoothSerialServiceInSecure";
-
-    // Unique UUID for this application
-    private static final UUID MY_UUID_SECURE = UUID.fromString("7A9C3B55-78D0-44A7-A94E-A93E3FE118CE");
-    private static final UUID MY_UUID_INSECURE = UUID.fromString("23F18142-B389-4772-93BD-52BDBB2C03E9");
-
-    // Well known SPP UUID
-    private static final UUID UUID_SPP = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
-
-    // Member fields
-    private final BluetoothAdapter mAdapter;
-    private final Handler mHandler;
-    private AcceptThread mSecureAcceptThread;
-    private AcceptThread mInsecureAcceptThread;
-    private ConnectThread mConnectThread;
-    private ConnectedThread mConnectedThread;
-    private int mState;
-
-    // Constants that indicate the current connection state
-    public static final int STATE_NONE = 0;       // we're doing nothing
-    public static final int STATE_LISTEN = 1;     // now listening for incoming connections
-    public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
-    public static final int STATE_CONNECTED = 3;  // now connected to a remote device
-
-    /**
-     * Constructor. Prepares a new BluetoothSerial session.
-     * @param handler  A Handler to send messages back to the UI Activity
-     */
-    public BluetoothSerialService(Handler handler) {
-        mAdapter = BluetoothAdapter.getDefaultAdapter();
-        mState = STATE_NONE;
-        mHandler = handler;
-    }
-
-    /**
-     * Set the current state of the chat connection
-     * @param state  An integer defining the current connection state
-     */
-    private synchronized void setState(int state) {
-        if (D) Log.d(TAG, "setState() " + mState + " -> " + state);
-        mState = state;
-
-        // Give the new state to the Handler so the UI Activity can update
-        mHandler.obtainMessage(BluetoothSerial.MESSAGE_STATE_CHANGE, state, -1).sendToTarget();
-    }
-
-    /**
-     * Return the current connection state. */
-    public synchronized int getState() {
-        return mState;
-    }
-
-    /**
-     * Start the chat service. Specifically start AcceptThread to begin a
-     * session in listening (server) mode. Called by the Activity onResume() */
-    public synchronized void start() {
-        if (D) Log.d(TAG, "start");
-
-        // Cancel any thread attempting to make a connection
-        if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
-
-        // Cancel any thread currently running a connection
-        if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
-
-        setState(STATE_NONE);
-
-//      Listen isn't working with Arduino. Ignore since assuming the phone will initiate the connection.
-//        setState(STATE_LISTEN);
-//
-//        // Start the thread to listen on a BluetoothServerSocket
-//        if (mSecureAcceptThread == null) {
-//            mSecureAcceptThread = new AcceptThread(true);
-//            mSecureAcceptThread.start();
-//        }
-//        if (mInsecureAcceptThread == null) {
-//            mInsecureAcceptThread = new AcceptThread(false);
-//            mInsecureAcceptThread.start();
-//        }
-    }
-
-    /**
-     * Start the ConnectThread to initiate a connection to a remote device.
-     * @param device  The BluetoothDevice to connect
-     * @param secure Socket Security type - Secure (true) , Insecure (false)
-     */
-    public synchronized void connect(BluetoothDevice device, boolean secure) {
-        if (D) Log.d(TAG, "connect to: " + device);
-
-        // Cancel any thread attempting to make a connection
-        if (mState == STATE_CONNECTING) {
-            if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
-        }
-
-        // Cancel any thread currently running a connection
-        if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
-
-        // Start the thread to connect with the given device
-        mConnectThread = new ConnectThread(device, secure);
-        mConnectThread.start();
-        setState(STATE_CONNECTING);
-    }
-
-    /**
-     * Start the ConnectedThread to begin managing a Bluetooth connection
-     * @param socket  The BluetoothSocket on which the connection was made
-     * @param device  The BluetoothDevice that has been connected
-     */
-    public synchronized void connected(BluetoothSocket socket, BluetoothDevice device, final String socketType) {
-        if (D) Log.d(TAG, "connected, Socket Type:" + socketType);
-
-        // Cancel the thread that completed the connection
-        if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
-
-        // Cancel any thread currently running a connection
-        if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
-
-        // Cancel the accept thread because we only want to connect to one device
-        if (mSecureAcceptThread != null) {
-            mSecureAcceptThread.cancel();
-            mSecureAcceptThread = null;
-        }
-        if (mInsecureAcceptThread != null) {
-            mInsecureAcceptThread.cancel();
-            mInsecureAcceptThread = null;
-        }
-
-        // Start the thread to manage the connection and perform transmissions
-        mConnectedThread = new ConnectedThread(socket, socketType);
-        mConnectedThread.start();
-
-        // Send the name of the connected device back to the UI Activity
-        Message msg = mHandler.obtainMessage(BluetoothSerial.MESSAGE_DEVICE_NAME);
-        Bundle bundle = new Bundle();
-        bundle.putString(BluetoothSerial.DEVICE_NAME, device.getName());
-        msg.setData(bundle);
-        mHandler.sendMessage(msg);
-
-        setState(STATE_CONNECTED);
-    }
-
-    /**
-     * Stop all threads
-     */
-    public synchronized void stop() {
-        if (D) Log.d(TAG, "stop");
-
-        if (mConnectThread != null) {
-            mConnectThread.cancel();
-            mConnectThread = null;
-        }
-
-        if (mConnectedThread != null) {
-            mConnectedThread.cancel();
-            mConnectedThread = null;
-        }
-
-        if (mSecureAcceptThread != null) {
-            mSecureAcceptThread.cancel();
-            mSecureAcceptThread = null;
-        }
-
-        if (mInsecureAcceptThread != null) {
-            mInsecureAcceptThread.cancel();
-            mInsecureAcceptThread = null;
-        }
-        setState(STATE_NONE);
-    }
-
-    /**
-     * Write to the ConnectedThread in an unsynchronized manner
-     * @param out The bytes to write
-     * @see ConnectedThread#write(byte[])
-     */
-    public void write(byte[] out) {
-        // Create temporary object
-        ConnectedThread r;
-        // Synchronize a copy of the ConnectedThread
-        synchronized (this) {
-            if (mState != STATE_CONNECTED) return;
-            r = mConnectedThread;
-        }
-        // Perform the write unsynchronized
-        r.write(out);
-    }
-
-    /**
-     * Indicate that the connection attempt failed and notify the UI Activity.
-     */
-    private void connectionFailed() {
-        // Send a failure message back to the Activity
-        Message msg = mHandler.obtainMessage(BluetoothSerial.MESSAGE_TOAST);
-        Bundle bundle = new Bundle();
-        bundle.putString(BluetoothSerial.TOAST, "Unable to connect to device");
-        msg.setData(bundle);
-        mHandler.sendMessage(msg);
-
-        // Start the service over to restart listening mode
-        BluetoothSerialService.this.start();
-    }
-
-    /**
-     * Indicate that the connection was lost and notify the UI Activity.
-     */
-    private void connectionLost() {
-        // Send a failure message back to the Activity
-        Message msg = mHandler.obtainMessage(BluetoothSerial.MESSAGE_TOAST);
-        Bundle bundle = new Bundle();
-        bundle.putString(BluetoothSerial.TOAST, "Device connection was lost");
-        msg.setData(bundle);
-        mHandler.sendMessage(msg);
-
-        // Start the service over to restart listening mode
-        BluetoothSerialService.this.start();
-    }
-
-    /**
-     * This thread runs while listening for incoming connections. It behaves
-     * like a server-side client. It runs until a connection is accepted
-     * (or until cancelled).
-     */
-    private class AcceptThread extends Thread {
-        // The local server socket
-        private final BluetoothServerSocket mmServerSocket;
-        private String mSocketType;
-
-        public AcceptThread(boolean secure) {
-            BluetoothServerSocket tmp = null;
-            mSocketType = secure ? "Secure":"Insecure";
-
-            // Create a new listening server socket
-            try {
-                if (secure) {
-                    tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
-                } else {
-                    tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
-                }
-            } catch (IOException e) {
-                Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
-            }
-            mmServerSocket = tmp;
-        }
-
-        public void run() {
-            if (D) Log.d(TAG, "Socket Type: " + mSocketType + "BEGIN mAcceptThread" + this);
-            setName("AcceptThread" + mSocketType);
-
-            BluetoothSocket socket;
-
-            // Listen to the server socket if we're not connected
-            while (mState != STATE_CONNECTED) {
-                try {
-                    // This is a blocking call and will only return on a
-                    // successful connection or an exception
-                    socket = mmServerSocket.accept();
-                } catch (IOException e) {
-                    Log.e(TAG, "Socket Type: " + mSocketType + "accept() failed", e);
-                    break;
-                }
-
-                // If a connection was accepted
-                if (socket != null) {
-                    synchronized (BluetoothSerialService.this) {
-                        switch (mState) {
-                            case STATE_LISTEN:
-                            case STATE_CONNECTING:
-                                // Situation normal. Start the connected thread.
-                                connected(socket, socket.getRemoteDevice(),
-                                        mSocketType);
-                                break;
-                            case STATE_NONE:
-                            case STATE_CONNECTED:
-                                // Either not ready or already connected. Terminate new socket.
-                                try {
-                                    socket.close();
-                                } catch (IOException e) {
-                                    Log.e(TAG, "Could not close unwanted socket", e);
-                                }
-                                break;
-                        }
-                    }
-                }
-            }
-            if (D) Log.i(TAG, "END mAcceptThread, socket Type: " + mSocketType);
-
-        }
-
-        public void cancel() {
-            if (D) Log.d(TAG, "Socket Type" + mSocketType + "cancel " + this);
-            try {
-                mmServerSocket.close();
-            } catch (IOException e) {
-                Log.e(TAG, "Socket Type" + mSocketType + "close() of server failed", e);
-            }
-        }
-    }
-
-
-    /**
-     * This thread runs while attempting to make an outgoing connection
-     * with a device. It runs straight through; the connection either
-     * succeeds or fails.
-     */
-    private class ConnectThread extends Thread {
-        private /*final*/ BluetoothSocket mmSocket;
-        private final BluetoothDevice mmDevice;
-        private String mSocketType;
-
-        public ConnectThread(BluetoothDevice device, boolean secure) {
-            mmDevice = device;
-            BluetoothSocket tmp = null;
-            mSocketType = secure ? "Secure" : "Insecure";
-
-            // Get a BluetoothSocket for a connection with the given BluetoothDevice
-            try {
-                if (secure) {
-                    // tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE);
-                    tmp = device.createRfcommSocketToServiceRecord(UUID_SPP);
-                } else {
-                    //tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID_INSECURE);
-                    tmp = device.createInsecureRfcommSocketToServiceRecord(UUID_SPP);
-                }
-            } catch (IOException e) {
-                Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
-            }
-            mmSocket = tmp;
-        }
-
-        public void run() {
-            Log.i(TAG, "BEGIN mConnectThread SocketType:" + mSocketType);
-            setName("ConnectThread" + mSocketType);
-
-            // Always cancel discovery because it will slow down a connection
-            mAdapter.cancelDiscovery();
-
-            // Make a connection to the BluetoothSocket
-            try {
-                // This is a blocking call and will only return on a successful connection or an exception
-                Log.i(TAG,"Connecting to socket...");
-                mmSocket.connect();
-                Log.i(TAG,"Connected");
-            } catch (IOException e) {
-                Log.e(TAG, e.toString());
-
-                // Some 4.1 devices have problems, try an alternative way to connect
-                // See https://github.com/don/BluetoothSerial/issues/89
-                try {
-                    Log.i(TAG,"Trying fallback...");
-                    mmSocket = (BluetoothSocket) mmDevice.getClass().getMethod("createRfcommSocket", new Class[] {int.class}).invoke(mmDevice,1);
-                    mmSocket.connect();
-                    Log.i(TAG,"Connected");
-                } catch (Exception e2) {
-                    Log.e(TAG, "Couldn't establish a Bluetooth connection.");
-                    try {
-                        mmSocket.close();
-                    } catch (IOException e3) {
-                        Log.e(TAG, "unable to close() " + mSocketType + " socket during connection failure", e3);
-                    }
-                    connectionFailed();
-                    return;
-                }
-            }
-
-            // Reset the ConnectThread because we're done
-            synchronized (BluetoothSerialService.this) {
-                mConnectThread = null;
-            }
-
-            // Start the connected thread
-            connected(mmSocket, mmDevice, mSocketType);
-        }
-
-        public void cancel() {
-            try {
-                mmSocket.close();
-            } catch (IOException e) {
-                Log.e(TAG, "close() of connect " + mSocketType + " socket failed", e);
-            }
-        }
-    }
-
-    /**
-     * This thread runs during a connection with a remote device.
-     * It handles all incoming and outgoing transmissions.
-     */
-    private class ConnectedThread extends Thread {
-        private final BluetoothSocket mmSocket;
-        private final InputStream mmInStream;
-        private final OutputStream mmOutStream;
-
-        public ConnectedThread(BluetoothSocket socket, String socketType) {
-            Log.d(TAG, "create ConnectedThread: " + socketType);
-            mmSocket = socket;
-            InputStream tmpIn = null;
-            OutputStream tmpOut = null;
-
-            // Get the BluetoothSocket input and output streams
-            try {
-                tmpIn = socket.getInputStream();
-                tmpOut = socket.getOutputStream();
-            } catch (IOException e) {
-                Log.e(TAG, "temp sockets not created", e);
-            }
-
-            mmInStream = tmpIn;
-            mmOutStream = tmpOut;
-        }
-
-        public void run() {
-            Log.i(TAG, "BEGIN mConnectedThread");
-            byte[] buffer = new byte[1024];
-            int bytes;
-
-            // Keep listening to the InputStream while connected
-            while (true) {
-                try {
-                    // Read from the InputStream
-                    bytes = mmInStream.read(buffer);
-                    String data = new String(buffer, 0, bytes);
-
-                    // Send the new data String to the UI Activity
-                    mHandler.obtainMessage(BluetoothSerial.MESSAGE_READ, data).sendToTarget();
-
-                    // Send the raw bytestream to the UI Activity.
-                    // We make a copy because the full array can have extra data at the end
-                    // when / if we read less than its size.
-                    if (bytes > 0) {
-                        byte[] rawdata = Arrays.copyOf(buffer, bytes);
-                        mHandler.obtainMessage(BluetoothSerial.MESSAGE_READ_RAW, rawdata).sendToTarget();
-                    }
-
-                } catch (IOException e) {
-                    Log.e(TAG, "disconnected", e);
-                    connectionLost();
-                    // Start the service over to restart listening mode
-                    BluetoothSerialService.this.start();
-                    break;
-                }
-            }
-        }
-
-        /**
-         * Write to the connected OutStream.
-         * @param buffer  The bytes to write
-         */
-        public void write(byte[] buffer) {
-            try {
-                mmOutStream.write(buffer);
-
-                // Share the sent message back to the UI Activity
-                mHandler.obtainMessage(BluetoothSerial.MESSAGE_WRITE, -1, -1, buffer).sendToTarget();
-
-            } catch (IOException e) {
-                Log.e(TAG, "Exception during write", e);
-            }
-        }
-
-        public void cancel() {
-            try {
-                mmSocket.close();
-            } catch (IOException e) {
-                Log.e(TAG, "close() of connect socket failed", e);
-            }
-        }
-    }
-}

File diff suppressed because it is too large
+ 0 - 4530
platforms/android/app/src/main/java/com/randdusing/bluetoothle/BluetoothLePlugin.java


+ 0 - 18
platforms/android/app/src/main/java/com/randdusing/bluetoothle/Operation.java

@@ -1,18 +0,0 @@
-package com.randdusing.bluetoothle;
-
-import org.apache.cordova.CallbackContext;
-import org.json.JSONArray;
-import android.bluetooth.BluetoothDevice;
-
-public class Operation {
-  public String type;
-  public JSONArray args;
-  public CallbackContext callbackContext;
-  public BluetoothDevice device;
-
-  public Operation(String type, JSONArray args, CallbackContext callbackContext) {
-    this.type = type;
-    this.args = args;
-    this.callbackContext = callbackContext;
-  }
-}

+ 0 - 6
platforms/android/app/src/main/res/xml/config.xml

@@ -14,9 +14,6 @@
     <feature name="AppVersion">
         <param name="android-package" value="uk.co.whiteoctober.cordova.AppVersion" />
     </feature>
-    <feature name="BluetoothLePlugin">
-        <param name="android-package" value="com.randdusing.bluetoothle.BluetoothLePlugin" />
-    </feature>
     <feature name="Camera">
         <param name="android-package" value="org.apache.cordova.camera.CameraLauncher" />
     </feature>
@@ -59,9 +56,6 @@
     <feature name="Base64">
         <param name="android-package" value="com.badrit.Base64.Base64Plugin" />
     </feature>
-    <feature name="BluetoothSerial">
-        <param name="android-package" value="com.megster.cordova.BluetoothSerial" />
-    </feature>
     <feature name="Badge">
         <param name="android-package" value="de.appplant.cordova.plugin.badge.Badge" />
     </feature>

+ 10 - 19
platforms/android/platform_www/cordova_plugins.js

@@ -255,22 +255,6 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
         "cordova.plugins.notification.badge"
       ]
     },
-    {
-      "id": "cordova-plugin-bluetooth-serial.bluetoothSerial",
-      "file": "plugins/cordova-plugin-bluetooth-serial/www/bluetoothSerial.js",
-      "pluginId": "cordova-plugin-bluetooth-serial",
-      "clobbers": [
-        "window.bluetoothSerial"
-      ]
-    },
-    {
-      "id": "cordova-plugin-bluetoothle.BluetoothLe",
-      "file": "plugins/cordova-plugin-bluetoothle/www/bluetoothle.js",
-      "pluginId": "cordova-plugin-bluetoothle",
-      "clobbers": [
-        "window.bluetoothle"
-      ]
-    },
     {
       "id": "cordova-plugin-camera.Camera",
       "file": "plugins/cordova-plugin-camera/www/CameraConstants.js",
@@ -432,6 +416,14 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
       "clobbers": [
         "navigator.Base64"
       ]
+    },
+    {
+      "id": "cordova-plugin-bluetoothle.BluetoothLe",
+      "file": "plugins/cordova-plugin-bluetoothle/www/bluetoothle.js",
+      "pluginId": "cordova-plugin-bluetoothle",
+      "clobbers": [
+        "window.bluetoothle"
+      ]
     }
   ];
   module.exports.metadata = {
@@ -440,8 +432,6 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
     "cordova-plugin-advanced-http": "2.0.9",
     "cordova-plugin-app-version": "0.1.9",
     "cordova-plugin-badge": "0.8.8",
-    "cordova-plugin-bluetooth-serial": "0.4.7",
-    "cordova-plugin-bluetoothle": "4.5.5",
     "cordova-plugin-camera": "4.0.3",
     "cordova-plugin-device": "2.0.2",
     "cordova-plugin-file-opener2": "2.2.1",
@@ -456,6 +446,7 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
     "cordova-plugin-image-picker": "1.1.1",
     "cordova-plugin-ionic-keyboard": "2.2.0",
     "cordova-plugin-datepicker": "0.9.3",
-    "com-badrit-base64": "0.2.0"
+    "com-badrit-base64": "0.2.0",
+    "cordova-plugin-bluetoothle": "4.5.6"
   };
 });

+ 0 - 1
src/app/app-routing.module.ts

@@ -15,7 +15,6 @@ const routes: Routes = [
   { path: 'enter-store', loadChildren: './enter-store/enter-store.module#EnterStorePageModule' },
   { path: 'store-sample', loadChildren: './store-sample/store-sample.module#StoreSamplePageModule' },
   { path: 'store-sample-barcode', loadChildren: './store-sample-barcode/store-sample-barcode.module#StoreSampleBarcodePageModule' },
-  // { path: 'bluetooth', loadChildren: './bluetooth/bluetooth.module#BluetoothPageModule' },
   { path: 'store-sample-binding', loadChildren: './store-sample-binding/store-sample-binding.module#StoreSampleBindingPageModule' },
   { path: 'store-pending', loadChildren: './store-pending/store-pending.module#StorePendingPageModule' },
   { path: 'store-qc', loadChildren: './store-qc/store-qc.module#StoreQCPageModule' },

+ 0 - 4
src/app/app.module.ts

@@ -24,8 +24,6 @@ import { queryForm } from '../providers/query'
 import { AppVersion } from '@ionic-native/app-version/ngx'; 
 import { WebSocketService } from '../providers/WebSocketService';
 import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx';
-// import { BluetoothLE } from '@ionic-native/bluetooth-le/ngx'
-// import { BluetoothSerial } from '@ionic-native/bluetooth-serial/ngx';
 import { NativeService } from "../providers/native.service"
 import { Device } from '@ionic-native/device/ngx';
 import { LocalNotifications } from '@ionic-native/local-notifications/ngx';
@@ -53,8 +51,6 @@ import { FileTransfer, FileTransferObject } from '@ionic-native/file-transfer/ng
     FileTransfer,
     FileTransferObject,
     BarcodeScanner,
-    // BluetoothLE,
-    // BluetoothSerial,
     Keyboard,
     HttpserviceService,
     LocalNotifications,

+ 0 - 26
src/app/bluetooth/bluetooth.module.ts

@@ -1,26 +0,0 @@
-import { NgModule } from '@angular/core';
-import { CommonModule } from '@angular/common';
-import { FormsModule } from '@angular/forms';
-import { Routes, RouterModule } from '@angular/router';
-
-import { IonicModule } from '@ionic/angular';
-
-import { BluetoothPage } from './bluetooth.page';
-
-const routes: Routes = [
-  {
-    path: '',
-    component: BluetoothPage
-  }
-];
-
-@NgModule({
-  imports: [
-    CommonModule,
-    FormsModule,
-    IonicModule,
-    RouterModule.forChild(routes)
-  ],
-  declarations: [BluetoothPage]
-})
-export class BluetoothPageModule {}

+ 0 - 79
src/app/bluetooth/bluetooth.page.html

@@ -1,79 +0,0 @@
-<ion-header>
-  <ion-toolbar>
-    <ion-buttons slot="start">
-      <ion-menu-button></ion-menu-button>
-    </ion-buttons>
-
-    <ion-title>蓝牙</ion-title>
-
-  </ion-toolbar>
-</ion-header>
-
-<ion-content>
-  <ion-list #scheduleList>
-    <ion-item-group>
-      <ion-item>
-        <ion-label>
-          蓝牙
-        </ion-label>
-        <ion-toggle slot="end" [(ngModel)]='blueStatus' (ionChange)='changeBlueStatus()'></ion-toggle>
-      </ion-item>
-      <ion-item-divider sticky *ngIf='blueStatus && connectList.length !== 0'>
-        <ion-label>
-          已连接的设备
-        </ion-label>
-      </ion-item-divider>  
-      <ion-item-sliding *ngFor='let l of connectList'>
-        <ion-item  (click)='cutLinkPrint()'>
-          <ion-label>
-            <span *ngIf='l.name'>{{l.name}}</span>
-            <span>(已连接)</span>
-          </ion-label>
-          <ion-note slot="end">
-            <ion-icon name="ios-alert-outline"></ion-icon>
-          </ion-note>
-        </ion-item>
-      </ion-item-sliding>
-      <ion-item-divider sticky>
-        <ion-label>
-          已配对设备
-        </ion-label>
-      </ion-item-divider>  
-      <ion-item-sliding *ngFor='let l of mateList'>
-        <ion-item button (click)='linkPrint(l)'>
-          <ion-label>
-            <span *ngIf='l.name'>{{l.name}}</span>
-            <span>{{l.address}}</span>
-          </ion-label>
-          <ion-note slot="end">
-            <ion-spinner icon="spiral" *ngIf='l.connectLoadingStatus'></ion-spinner>
-            <span *ngIf='l.connectStatus'>已连接</span>
-            <span *ngIf='!l.connectStatus'>未连接</span>
-          </ion-note>
-        </ion-item>
-      </ion-item-sliding>
-      <ion-item-divider sticky>
-        <ion-label>
-          搜索到的设备
-        </ion-label>
-        <ion-note color="primary" slot="end">
-          <span *ngIf='!blueStatus' (click)='getDiscoverList()'>开始搜索</span>
-          <span *ngIf='blueStatus' (click)='getDiscoverList()'>{{discoverWord}}</span>
-        </ion-note>
-      </ion-item-divider>
-      <ion-item-sliding (click)='linkPrint(device)' *ngFor="let device of discoverList">
-        <ion-item button>
-          <ion-label>
-            <h3>{{device.name}} {{device.id}}</h3>
-          </ion-label>
-          <ion-note slot="end" *ngIf='device.connectLoadingStatus'>
-            <ion-spinner icon="spiral"></ion-spinner>
-          </ion-note>
-        </ion-item>
-      </ion-item-sliding>
-    </ion-item-group>
-  </ion-list>
-</ion-content>
-<ion-footer>
-  <ion-button color="primary" type="submit" expand="block" (click)="write()">打印测试</ion-button>
-</ion-footer>

+ 0 - 19
src/app/bluetooth/bluetooth.page.scss

@@ -1,19 +0,0 @@
-$categories: (
-  ionic: var(--ion-color-primary),
-  angular: #ac282b,
-  communication: #8e8d93,
-  tooling: #fe4c52,
-  services: #fd8b2d,
-  design: #fed035,
-  workshop: #69bb7b,
-  food: #3bc7c4,
-  documentation: #b16be3,
-  navigation: #6600cc
-);
-
-@each $track, $value in map-remove($categories) {
-  ion-item-sliding[track='#{$track}'] ion-label {
-    border-left: 2px solid $value;
-    padding-left: 10px;
-  }
-}

+ 0 - 27
src/app/bluetooth/bluetooth.page.spec.ts

@@ -1,27 +0,0 @@
-import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
-import { BluetoothPage } from './bluetooth.page';
-
-describe('BluetoothPage', () => {
-  let component: BluetoothPage;
-  let fixture: ComponentFixture<BluetoothPage>;
-
-  beforeEach(async(() => {
-    TestBed.configureTestingModule({
-      declarations: [ BluetoothPage ],
-      schemas: [CUSTOM_ELEMENTS_SCHEMA],
-    })
-    .compileComponents();
-  }));
-
-  beforeEach(() => {
-    fixture = TestBed.createComponent(BluetoothPage);
-    component = fixture.componentInstance;
-    fixture.detectChanges();
-  });
-
-  it('should create', () => {
-    expect(component).toBeTruthy();
-  });
-});

File diff suppressed because it is too large
+ 0 - 354
src/app/bluetooth/bluetooth.page.ts


+ 0 - 5
src/app/store-sample-barcode/store-sample-barcode.page.ts

@@ -1,7 +1,5 @@
 import { Component, OnInit } from '@angular/core';
 import { UserData } from '../../providers/user-data';
-import { BluetoothLE } from '@ionic-native/bluetooth-le/ngx'
-import { BluetoothSerial } from '@ionic-native/bluetooth-serial/ngx';
 import { Platform } from '@ionic/angular';
 
 @Component({
@@ -14,10 +12,7 @@ export class StoreSampleBarcodePage implements OnInit {
   public code: string
 
   constructor(public userData: UserData,
-    public bluetoothle: BluetoothLE,
-    private bluetoothSerial: BluetoothSerial,
     public plt: Platform) {
-      bluetoothSerial.enable();
   }
 
   ngOnInit() {