diff --git a/src/@awesome-cordova-plugins/plugins/bluetooth-classic-serial-port/index.ts b/src/@awesome-cordova-plugins/plugins/bluetooth-classic-serial-port/index.ts index fb876b616..7706fefc0 100644 --- a/src/@awesome-cordova-plugins/plugins/bluetooth-classic-serial-port/index.ts +++ b/src/@awesome-cordova-plugins/plugins/bluetooth-classic-serial-port/index.ts @@ -22,10 +22,10 @@ export interface BluetoothClassicSerialPortDevice { * * * // Write a string - * this.bluetoothClassicSerialPort.write("00001101-0000-1000-8000-00805F9B34FB", "hello, world", success, failure); + * this.bluetoothClassicSerialPort.write(deviceId, "00001101-0000-1000-8000-00805F9B34FB", "hello, world", success, failure); * * // Array of int or bytes - * this.bluetoothClassicSerialPort.write("00001101-0000-1000-8000-00805F9B34FB", [186, 220, 222], success, failure); + * this.bluetoothClassicSerialPort.write(deviceId, "00001101-0000-1000-8000-00805F9B34FB", [186, 220, 222], success, failure); * * // Typed Array * var data = new Uint8Array(4); @@ -33,10 +33,10 @@ export interface BluetoothClassicSerialPortDevice { * data[1] = 0x42; * data[2] = 0x43; * data[3] = 0x44; - * this.bluetoothClassicSerialPort.write(interfaceId, data, success, failure); + * this.bluetoothClassicSerialPort.write(deviceId, interfaceId, data, success, failure); * * // Array Buffer - * this.bluetoothClassicSerialPort.write(interfaceId, data.buffer, success, failure); + * this.bluetoothClassicSerialPort.write(deviceId, interfaceId, data.buffer, success, failure); * ``` * * // iOS select accessory @@ -76,61 +76,42 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin { /** * Connect to a Bluetooth device * - * @param {string} deviceId Identifier of the remote device. - * @param {string} deviceId this is the MAC address. - * @param {string|string[]} interfaceId Identifier of the remote device - * @param {string|string[]} interfaceId This identifies the serial port to connect to. + * @param deviceId Identifier of the remote device. + * @param interfaceArray This identifies the serial port to connect to. * @returns {Observable} Subscribe to connect. */ @Cordova({ platforms: ['Android', 'iOS'], observable: true, }) - connect(deviceId: string | number, interfaceId: string | string[]): Observable { - return; - } - - /** - * Connect to a Bluetooth device - * - * @deprecated - * @param {string} deviceId Identifier of the remote device. - * @param {number} deviceId this is the connection ID - * @param {string|string[]} interfaceArray Identifier of the remote device - * @param {string|string[]} interfaceArray this is the Protocol String - * @returns {Promise} - */ - @Cordova({ - platforms: ['iOS'], - methodName: 'connect', - }) - connectIos(deviceId: string | number, interfaceArray: string | string[]): Promise { + connect(deviceId: string | number, interfaceArray: string[]): Observable { return; } /** * Connect insecurely to a Bluetooth device * - * @param {string} deviceId Identifier of the remote device. For Android this is the MAC address - * @param {string | string[]} interfaceArray This identifies the serial port to connect to. For Android this is the SPP_UUID. + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceArray This identifies the serial port to connect to. For Android this is the SPP_UUID. * @returns {Promise} Subscribe to connect. */ @Cordova({ platforms: ['Android'], observable: true, }) - connectInsecure(deviceId: string, interfaceArray: string | string[]): Promise { + connectInsecure(deviceId: string | number, interfaceArray: string[]): Observable { return; } /** * Disconnect from the connected device * - * @param {string} interfaceId The interface to Disconnect + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to Disconnect * @returns {Promise} */ @Cordova() - disconnect(interfaceId: string | string[]): Promise { + disconnect(deviceId: string | number, interfaceId: string): Promise { return; } @@ -139,9 +120,7 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin { * * @returns {Promise} */ - @Cordova({ - methodName: 'connect', - }) + @Cordova() disconnectAll(): Promise { return; } @@ -149,122 +128,149 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin { /** * Writes data to the serial port * - * @param {string} interfaceId The interface to send the data to - * @param {ArrayBuffer | string | number[] | Uint8Array} data ArrayBuffer of data + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to send the data to + * @param data ArrayBuffer of data * @returns {Promise} returns a promise when data has been written */ @Cordova({ platforms: ['Android', 'iOS', 'Browser'], }) - write(interfaceId: string, data: ArrayBuffer | string | number[] | Uint8Array): Promise { + write( + deviceId: string | number, + interfaceId: string, + data: ArrayBuffer | string | number[] | Uint8Array + ): Promise { return; } /** * Gets the number of bytes of data available * - * @param {string} interfaceId The interface to check + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to check * @returns {Promise} returns a promise that contains the available bytes */ @Cordova({ platforms: ['Android', 'Browser'], }) - available(interfaceId: string): Promise { + available(deviceId: string | number, interfaceId: string): Promise { return; } /** * Function read reads the data from the buffer. The data is passed to the success callback as a String. Calling read when no data is available will pass an empty String to the callback. * - * @param {string} interfaceId The interface to read + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to read * @returns {Promise} returns a promise with data from the buffer */ @Cordova({ platforms: ['Android', 'iOS', 'Browser'], }) - read(interfaceId: string): Promise { + read(deviceId: string | number, interfaceId: string): Promise { return; } /** * Reads data from the buffer until it reaches a delimiter * - * @param {string} interfaceId The interface to read - * @param {string} delimiter string that you want to search until + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to read + * @param delimiter string that you want to search until * @returns {Observable} returns a promise */ @Cordova({ platforms: ['Android', 'iOS', 'Browser'], }) - readUntil(interfaceId: string, delimiter: string): Observable { + readUntil(deviceId: string | number, interfaceId: string, delimiter: string): Observable { return; } /** * Subscribe to be notified when data is received * - * @param {string | string[]} interfaceId The interface to subscribe to - * @param {string} delimiter the string you want to watch for + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to subscribe to + * @param delimiter the string you want to watch for * @returns {Observable} returns an observable. */ @Cordova({ platforms: ['Android', 'iOS', 'Browser'], observable: true, }) - subscribe(interfaceId: string | string[], delimiter: string): Observable { + subscribe(deviceId: string | number, interfaceId: string, delimiter: string): Observable { return; } /** * Unsubscribe from a subscription * - * @param {string | string[]} interfaceId The interface to unsubscribe from - * @returns {Promise} returns an promise. + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to unsubscribe from + * @returns {Promise} returns a promise. */ @Cordova({ platforms: ['Android', 'iOS', 'Browser'], }) - unsubscribe(interfaceId: string | string[]): Promise { + unsubscribe(deviceId: string | number, interfaceId: string): Promise { return; } /** * Subscribe to be notified when data is received * - * @param {string | string[]} interfaceId The interface to subscribe to + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to subscribe to * @returns {Observable} returns an observable */ @Cordova({ platforms: ['Android', 'iOS', 'Browser'], observable: true, }) - subscribeRawData(interfaceId: string | string[]): Observable { + subscribeRawData(deviceId: string | number, interfaceId: string): Observable { return; } /** * Unsubscribe from a subscription * - * @param {string | string[]} interfaceId The interface to unsubscribe from - * @returns {Promise} returns an promise. + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to unsubscribe from + * @returns {Promise} returns a promise. */ @Cordova({ platforms: ['Android', 'iOS', 'Browser'], }) - unsubscribeRawData(interfaceId: string | string[]): Promise { + unsubscribeRawData(deviceId: string | number, interfaceId: string): Promise { return; } /** * Clears data in buffer * - * @param {string} interfaceId The interface to clear data + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to clear data * @returns {Promise} returns a promise when completed */ @Cordova({ platforms: ['Android', 'iOS', 'Browser'], }) - clear(interfaceId: string): Promise<[]> { + clear(deviceId: string | number, interfaceId: string): Promise<[]> { + return; + } + + /** + * Reports the connection status + * + * @param deviceId Identifier of the remote device. For Android this is the MAC address + * @param interfaceId The interface to check + * @returns {Promise} returns a promise + */ + @Cordova({ + platforms: ['Android', 'iOS', 'Browser'], + }) + isConnected(deviceId: string | number, interfaceId: string): Promise { return; } @@ -280,19 +286,6 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin { return; } - /** - * Reports the connection status - * - * @param {string} interfaceId The interface to check - * @returns {Promise} returns a promise - */ - @Cordova({ - platforms: ['Android', 'iOS', 'Browser'], - }) - isConnected(interfaceId: string): Promise { - return; - } - /** * Reports if bluetooth is enabled *