mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-05-02 00:07:23 +08:00
fix(bluetooth-classic-serial-port): support multiple simultaneous connections using the same protocol string (#5056)
* fix(bluetooth-classic-serial-port): update plugin * Update src/@awesome-cordova-plugins/plugins/bluetooth-classic-serial-port/index.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update src/@awesome-cordova-plugins/plugins/bluetooth-classic-serial-port/index.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update src/@awesome-cordova-plugins/plugins/bluetooth-classic-serial-port/index.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update src/@awesome-cordova-plugins/plugins/bluetooth-classic-serial-port/index.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update src/@awesome-cordova-plugins/plugins/bluetooth-classic-serial-port/index.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -22,10 +22,10 @@ export interface BluetoothClassicSerialPortDevice {
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* // Write a string
|
* // 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
|
* // 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
|
* // Typed Array
|
||||||
* var data = new Uint8Array(4);
|
* var data = new Uint8Array(4);
|
||||||
@@ -33,10 +33,10 @@ export interface BluetoothClassicSerialPortDevice {
|
|||||||
* data[1] = 0x42;
|
* data[1] = 0x42;
|
||||||
* data[2] = 0x43;
|
* data[2] = 0x43;
|
||||||
* data[3] = 0x44;
|
* data[3] = 0x44;
|
||||||
* this.bluetoothClassicSerialPort.write(interfaceId, data, success, failure);
|
* this.bluetoothClassicSerialPort.write(deviceId, interfaceId, data, success, failure);
|
||||||
*
|
*
|
||||||
* // Array Buffer
|
* // Array Buffer
|
||||||
* this.bluetoothClassicSerialPort.write(interfaceId, data.buffer, success, failure);
|
* this.bluetoothClassicSerialPort.write(deviceId, interfaceId, data.buffer, success, failure);
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* // iOS select accessory
|
* // iOS select accessory
|
||||||
@@ -76,61 +76,42 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin {
|
|||||||
/**
|
/**
|
||||||
* Connect to a Bluetooth device
|
* Connect to a Bluetooth device
|
||||||
*
|
*
|
||||||
* @param {string} deviceId Identifier of the remote device.
|
* @param deviceId Identifier of the remote device.
|
||||||
* @param {string} deviceId this is the MAC address.
|
* @param interfaceArray This identifies the serial port to connect to.
|
||||||
* @param {string|string[]} interfaceId Identifier of the remote device
|
|
||||||
* @param {string|string[]} interfaceId This identifies the serial port to connect to.
|
|
||||||
* @returns {Observable<any>} Subscribe to connect.
|
* @returns {Observable<any>} Subscribe to connect.
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'iOS'],
|
platforms: ['Android', 'iOS'],
|
||||||
observable: true,
|
observable: true,
|
||||||
})
|
})
|
||||||
connect(deviceId: string | number, interfaceId: string | string[]): Observable<any> {
|
connect(deviceId: string | number, interfaceArray: string[]): Observable<any> {
|
||||||
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<any>}
|
|
||||||
*/
|
|
||||||
@Cordova({
|
|
||||||
platforms: ['iOS'],
|
|
||||||
methodName: 'connect',
|
|
||||||
})
|
|
||||||
connectIos(deviceId: string | number, interfaceArray: string | string[]): Promise<any> {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect insecurely to a Bluetooth device
|
* Connect insecurely to a Bluetooth device
|
||||||
*
|
*
|
||||||
* @param {string} deviceId Identifier of the remote device. For Android this is the MAC address
|
* @param 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 interfaceArray This identifies the serial port to connect to. For Android this is the SPP_UUID.
|
||||||
* @returns {Promise<any>} Subscribe to connect.
|
* @returns {Promise<any>} Subscribe to connect.
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android'],
|
platforms: ['Android'],
|
||||||
observable: true,
|
observable: true,
|
||||||
})
|
})
|
||||||
connectInsecure(deviceId: string, interfaceArray: string | string[]): Promise<any> {
|
connectInsecure(deviceId: string | number, interfaceArray: string[]): Observable<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect from the connected device
|
* 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<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
disconnect(interfaceId: string | string[]): Promise<any> {
|
disconnect(deviceId: string | number, interfaceId: string): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,9 +120,7 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin {
|
|||||||
*
|
*
|
||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova()
|
||||||
methodName: 'connect',
|
|
||||||
})
|
|
||||||
disconnectAll(): Promise<any> {
|
disconnectAll(): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -149,122 +128,149 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin {
|
|||||||
/**
|
/**
|
||||||
* Writes data to the serial port
|
* Writes data to the serial port
|
||||||
*
|
*
|
||||||
* @param {string} interfaceId The interface to send the data to
|
* @param deviceId Identifier of the remote device. For Android this is the MAC address
|
||||||
* @param {ArrayBuffer | string | number[] | Uint8Array} data ArrayBuffer of data
|
* @param interfaceId The interface to send the data to
|
||||||
|
* @param data ArrayBuffer of data
|
||||||
* @returns {Promise<any>} returns a promise when data has been written
|
* @returns {Promise<any>} returns a promise when data has been written
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'iOS', 'Browser'],
|
platforms: ['Android', 'iOS', 'Browser'],
|
||||||
})
|
})
|
||||||
write(interfaceId: string, data: ArrayBuffer | string | number[] | Uint8Array): Promise<any> {
|
write(
|
||||||
|
deviceId: string | number,
|
||||||
|
interfaceId: string,
|
||||||
|
data: ArrayBuffer | string | number[] | Uint8Array
|
||||||
|
): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of bytes of data available
|
* 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<any>} returns a promise that contains the available bytes
|
* @returns {Promise<any>} returns a promise that contains the available bytes
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'Browser'],
|
platforms: ['Android', 'Browser'],
|
||||||
})
|
})
|
||||||
available(interfaceId: string): Promise<any> {
|
available(deviceId: string | number, interfaceId: string): Promise<any> {
|
||||||
return;
|
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.
|
* 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<any>} returns a promise with data from the buffer
|
* @returns {Promise<any>} returns a promise with data from the buffer
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'iOS', 'Browser'],
|
platforms: ['Android', 'iOS', 'Browser'],
|
||||||
})
|
})
|
||||||
read(interfaceId: string): Promise<any> {
|
read(deviceId: string | number, interfaceId: string): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads data from the buffer until it reaches a delimiter
|
* Reads data from the buffer until it reaches a delimiter
|
||||||
*
|
*
|
||||||
* @param {string} interfaceId The interface to read
|
* @param deviceId Identifier of the remote device. For Android this is the MAC address
|
||||||
* @param {string} delimiter string that you want to search until
|
* @param interfaceId The interface to read
|
||||||
|
* @param delimiter string that you want to search until
|
||||||
* @returns {Observable<any>} returns a promise
|
* @returns {Observable<any>} returns a promise
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'iOS', 'Browser'],
|
platforms: ['Android', 'iOS', 'Browser'],
|
||||||
})
|
})
|
||||||
readUntil(interfaceId: string, delimiter: string): Observable<any> {
|
readUntil(deviceId: string | number, interfaceId: string, delimiter: string): Observable<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe to be notified when data is received
|
* 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 {string} delimiter the string you want to watch for
|
* @param interfaceId The interface to subscribe to
|
||||||
|
* @param delimiter the string you want to watch for
|
||||||
* @returns {Observable<any>} returns an observable.
|
* @returns {Observable<any>} returns an observable.
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'iOS', 'Browser'],
|
platforms: ['Android', 'iOS', 'Browser'],
|
||||||
observable: true,
|
observable: true,
|
||||||
})
|
})
|
||||||
subscribe(interfaceId: string | string[], delimiter: string): Observable<any> {
|
subscribe(deviceId: string | number, interfaceId: string, delimiter: string): Observable<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribe from a subscription
|
* Unsubscribe from a subscription
|
||||||
*
|
*
|
||||||
* @param {string | string[]} interfaceId The interface to unsubscribe from
|
* @param deviceId Identifier of the remote device. For Android this is the MAC address
|
||||||
* @returns {Promise<any>} returns an promise.
|
* @param interfaceId The interface to unsubscribe from
|
||||||
|
* @returns {Promise<any>} returns a promise.
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'iOS', 'Browser'],
|
platforms: ['Android', 'iOS', 'Browser'],
|
||||||
})
|
})
|
||||||
unsubscribe(interfaceId: string | string[]): Promise<any> {
|
unsubscribe(deviceId: string | number, interfaceId: string): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe to be notified when data is received
|
* 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<any>} returns an observable
|
* @returns {Observable<any>} returns an observable
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'iOS', 'Browser'],
|
platforms: ['Android', 'iOS', 'Browser'],
|
||||||
observable: true,
|
observable: true,
|
||||||
})
|
})
|
||||||
subscribeRawData(interfaceId: string | string[]): Observable<any> {
|
subscribeRawData(deviceId: string | number, interfaceId: string): Observable<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribe from a subscription
|
* Unsubscribe from a subscription
|
||||||
*
|
*
|
||||||
* @param {string | string[]} interfaceId The interface to unsubscribe from
|
* @param deviceId Identifier of the remote device. For Android this is the MAC address
|
||||||
* @returns {Promise<any>} returns an promise.
|
* @param interfaceId The interface to unsubscribe from
|
||||||
|
* @returns {Promise<any>} returns a promise.
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'iOS', 'Browser'],
|
platforms: ['Android', 'iOS', 'Browser'],
|
||||||
})
|
})
|
||||||
unsubscribeRawData(interfaceId: string | string[]): Promise<any> {
|
unsubscribeRawData(deviceId: string | number, interfaceId: string): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears data in buffer
|
* 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<any>} returns a promise when completed
|
* @returns {Promise<any>} returns a promise when completed
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['Android', 'iOS', 'Browser'],
|
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<boolean>} returns a promise
|
||||||
|
*/
|
||||||
|
@Cordova({
|
||||||
|
platforms: ['Android', 'iOS', 'Browser'],
|
||||||
|
})
|
||||||
|
isConnected(deviceId: string | number, interfaceId: string): Promise<boolean> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,19 +286,6 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reports the connection status
|
|
||||||
*
|
|
||||||
* @param {string} interfaceId The interface to check
|
|
||||||
* @returns {Promise<boolean>} returns a promise
|
|
||||||
*/
|
|
||||||
@Cordova({
|
|
||||||
platforms: ['Android', 'iOS', 'Browser'],
|
|
||||||
})
|
|
||||||
isConnected(interfaceId: string): Promise<boolean> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports if bluetooth is enabled
|
* Reports if bluetooth is enabled
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user