@@ -22,21 +22,21 @@ export interface BluetoothClassicSerialPortDevice {
22
22
*
23
23
*
24
24
* // Write a string
25
- * this.bluetoothClassicSerialPort.write("00001101-0000-1000-8000-00805F9B34FB", "hello, world", success, failure);
25
+ * this.bluetoothClassicSerialPort.write(deviceId, "00001101-0000-1000-8000-00805F9B34FB", "hello, world", success, failure);
26
26
*
27
27
* // Array of int or bytes
28
- * this.bluetoothClassicSerialPort.write("00001101-0000-1000-8000-00805F9B34FB", [186, 220, 222], success, failure);
28
+ * this.bluetoothClassicSerialPort.write(deviceId, "00001101-0000-1000-8000-00805F9B34FB", [186, 220, 222], success, failure);
29
29
*
30
30
* // Typed Array
31
31
* var data = new Uint8Array(4);
32
32
* data[0] = 0x41;
33
33
* data[1] = 0x42;
34
34
* data[2] = 0x43;
35
35
* data[3] = 0x44;
36
- * this.bluetoothClassicSerialPort.write(interfaceId, data, success, failure);
36
+ * this.bluetoothClassicSerialPort.write(deviceId, interfaceId, data, success, failure);
37
37
*
38
38
* // Array Buffer
39
- * this.bluetoothClassicSerialPort.write(interfaceId, data.buffer, success, failure);
39
+ * this.bluetoothClassicSerialPort.write(deviceId, interfaceId, data.buffer, success, failure);
40
40
* ```
41
41
*
42
42
* // iOS select accessory
@@ -76,61 +76,42 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin {
76
76
/**
77
77
* Connect to a Bluetooth device
78
78
*
79
- * @param {string } deviceId Identifier of the remote device.
80
- * @param {string } deviceId this is the MAC address.
81
- * @param {string|string[] } interfaceId Identifier of the remote device
82
- * @param {string|string[] } interfaceId This identifies the serial port to connect to.
79
+ * @param deviceId Identifier of the remote device.
80
+ * @param interfaceArray This identifies the serial port to connect to.
83
81
* @returns {Observable<any> } Subscribe to connect.
84
82
*/
85
83
@Cordova ( {
86
84
platforms : [ 'Android' , 'iOS' ] ,
87
85
observable : true ,
88
86
} )
89
- connect ( deviceId : string | number , interfaceId : string | string [ ] ) : Observable < any > {
90
- return ;
91
- }
92
-
93
- /**
94
- * Connect to a Bluetooth device
95
- *
96
- * @deprecated
97
- * @param {string } deviceId Identifier of the remote device.
98
- * @param {number } deviceId this is the connection ID
99
- * @param {string|string[] } interfaceArray Identifier of the remote device
100
- * @param {string|string[] } interfaceArray this is the Protocol String
101
- * @returns {Promise<any> }
102
- */
103
- @Cordova ( {
104
- platforms : [ 'iOS' ] ,
105
- methodName : 'connect' ,
106
- } )
107
- connectIos ( deviceId : string | number , interfaceArray : string | string [ ] ) : Promise < any > {
87
+ connect ( deviceId : string | number , interfaceArray : string [ ] ) : Observable < any > {
108
88
return ;
109
89
}
110
90
111
91
/**
112
92
* Connect insecurely to a Bluetooth device
113
93
*
114
- * @param { string } deviceId Identifier of the remote device. For Android this is the MAC address
115
- * @param { string | string[] } interfaceArray This identifies the serial port to connect to. For Android this is the SPP_UUID.
94
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
95
+ * @param interfaceArray This identifies the serial port to connect to. For Android this is the SPP_UUID.
116
96
* @returns {Promise<any> } Subscribe to connect.
117
97
*/
118
98
@Cordova ( {
119
99
platforms : [ 'Android' ] ,
120
100
observable : true ,
121
101
} )
122
- connectInsecure ( deviceId : string , interfaceArray : string | string [ ] ) : Promise < any > {
102
+ connectInsecure ( deviceId : string | number , interfaceArray : string [ ] ) : Observable < any > {
123
103
return ;
124
104
}
125
105
126
106
/**
127
107
* Disconnect from the connected device
128
108
*
129
- * @param {string } interfaceId The interface to Disconnect
109
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
110
+ * @param interfaceId The interface to Disconnect
130
111
* @returns {Promise<any> }
131
112
*/
132
113
@Cordova ( )
133
- disconnect ( interfaceId : string | string [ ] ) : Promise < any > {
114
+ disconnect ( deviceId : string | number , interfaceId : string ) : Promise < any > {
134
115
return ;
135
116
}
136
117
@@ -139,157 +120,169 @@ export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin {
139
120
*
140
121
* @returns {Promise<any> }
141
122
*/
142
- @Cordova ( {
143
- methodName : 'connect' ,
144
- } )
123
+ @Cordova ( )
145
124
disconnectAll ( ) : Promise < any > {
146
125
return ;
147
126
}
148
127
149
128
/**
150
129
* Writes data to the serial port
151
130
*
152
- * @param {string } interfaceId The interface to send the data to
153
- * @param {ArrayBuffer | string | number[] | Uint8Array } data ArrayBuffer of data
131
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
132
+ * @param interfaceId The interface to send the data to
133
+ * @param data ArrayBuffer of data
154
134
* @returns {Promise<any> } returns a promise when data has been written
155
135
*/
156
136
@Cordova ( {
157
137
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
158
138
} )
159
- write ( interfaceId : string , data : ArrayBuffer | string | number [ ] | Uint8Array ) : Promise < any > {
139
+ write (
140
+ deviceId : string | number ,
141
+ interfaceId : string ,
142
+ data : ArrayBuffer | string | number [ ] | Uint8Array
143
+ ) : Promise < any > {
160
144
return ;
161
145
}
162
146
163
147
/**
164
148
* Gets the number of bytes of data available
165
149
*
166
- * @param {string } interfaceId The interface to check
150
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
151
+ * @param interfaceId The interface to check
167
152
* @returns {Promise<any> } returns a promise that contains the available bytes
168
153
*/
169
154
@Cordova ( {
170
155
platforms : [ 'Android' , 'Browser' ] ,
171
156
} )
172
- available ( interfaceId : string ) : Promise < any > {
157
+ available ( deviceId : string | number , interfaceId : string ) : Promise < any > {
173
158
return ;
174
159
}
175
160
176
161
/**
177
162
* 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.
178
163
*
179
- * @param {string } interfaceId The interface to read
164
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
165
+ * @param interfaceId The interface to read
180
166
* @returns {Promise<any> } returns a promise with data from the buffer
181
167
*/
182
168
@Cordova ( {
183
169
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
184
170
} )
185
- read ( interfaceId : string ) : Promise < any > {
171
+ read ( deviceId : string | number , interfaceId : string ) : Promise < any > {
186
172
return ;
187
173
}
188
174
189
175
/**
190
176
* Reads data from the buffer until it reaches a delimiter
191
177
*
192
- * @param {string } interfaceId The interface to read
193
- * @param {string } delimiter string that you want to search until
178
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
179
+ * @param interfaceId The interface to read
180
+ * @param delimiter string that you want to search until
194
181
* @returns {Observable<any> } returns a promise
195
182
*/
196
183
@Cordova ( {
197
184
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
198
185
} )
199
- readUntil ( interfaceId : string , delimiter : string ) : Observable < any > {
186
+ readUntil ( deviceId : string | number , interfaceId : string , delimiter : string ) : Observable < any > {
200
187
return ;
201
188
}
202
189
203
190
/**
204
191
* Subscribe to be notified when data is received
205
192
*
206
- * @param {string | string[] } interfaceId The interface to subscribe to
207
- * @param {string } delimiter the string you want to watch for
193
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
194
+ * @param interfaceId The interface to subscribe to
195
+ * @param delimiter the string you want to watch for
208
196
* @returns {Observable<any> } returns an observable.
209
197
*/
210
198
@Cordova ( {
211
199
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
212
200
observable : true ,
213
201
} )
214
- subscribe ( interfaceId : string | string [ ] , delimiter : string ) : Observable < any > {
202
+ subscribe ( deviceId : string | number , interfaceId : string , delimiter : string ) : Observable < any > {
215
203
return ;
216
204
}
217
205
218
206
/**
219
207
* Unsubscribe from a subscription
220
208
*
221
- * @param {string | string[] } interfaceId The interface to unsubscribe from
222
- * @returns {Promise<any> } returns an promise.
209
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
210
+ * @param interfaceId The interface to unsubscribe from
211
+ * @returns {Promise<any> } returns a promise.
223
212
*/
224
213
@Cordova ( {
225
214
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
226
215
} )
227
- unsubscribe ( interfaceId : string | string [ ] ) : Promise < any > {
216
+ unsubscribe ( deviceId : string | number , interfaceId : string ) : Promise < any > {
228
217
return ;
229
218
}
230
219
231
220
/**
232
221
* Subscribe to be notified when data is received
233
222
*
234
- * @param {string | string[] } interfaceId The interface to subscribe to
223
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
224
+ * @param interfaceId The interface to subscribe to
235
225
* @returns {Observable<any> } returns an observable
236
226
*/
237
227
@Cordova ( {
238
228
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
239
229
observable : true ,
240
230
} )
241
- subscribeRawData ( interfaceId : string | string [ ] ) : Observable < any > {
231
+ subscribeRawData ( deviceId : string | number , interfaceId : string ) : Observable < any > {
242
232
return ;
243
233
}
244
234
245
235
/**
246
236
* Unsubscribe from a subscription
247
237
*
248
- * @param {string | string[] } interfaceId The interface to unsubscribe from
249
- * @returns {Promise<any> } returns an promise.
238
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
239
+ * @param interfaceId The interface to unsubscribe from
240
+ * @returns {Promise<any> } returns a promise.
250
241
*/
251
242
@Cordova ( {
252
243
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
253
244
} )
254
- unsubscribeRawData ( interfaceId : string | string [ ] ) : Promise < any > {
245
+ unsubscribeRawData ( deviceId : string | number , interfaceId : string ) : Promise < any > {
255
246
return ;
256
247
}
257
248
258
249
/**
259
250
* Clears data in buffer
260
251
*
261
- * @param {string } interfaceId The interface to clear data
252
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
253
+ * @param interfaceId The interface to clear data
262
254
* @returns {Promise<any> } returns a promise when completed
263
255
*/
264
256
@Cordova ( {
265
257
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
266
258
} )
267
- clear ( interfaceId : string ) : Promise < [ ] > {
259
+ clear ( deviceId : string | number , interfaceId : string ) : Promise < [ ] > {
268
260
return ;
269
261
}
270
262
271
263
/**
272
- * Lists bonded devices
264
+ * Reports the connection status
273
265
*
274
- * @returns {Promise<BluetoothClassicSerialPortDevice> } returns a promise
266
+ * @param deviceId Identifier of the remote device. For Android this is the MAC address
267
+ * @param interfaceId The interface to check
268
+ * @returns {Promise<boolean> } returns a promise
275
269
*/
276
270
@Cordova ( {
277
271
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
278
272
} )
279
- list ( ) : Promise < BluetoothClassicSerialPortDevice [ ] > {
273
+ isConnected ( deviceId : string | number , interfaceId : string ) : Promise < boolean > {
280
274
return ;
281
275
}
282
276
283
277
/**
284
- * Reports the connection status
278
+ * Lists bonded devices
285
279
*
286
- * @param {string } interfaceId The interface to check
287
- * @returns {Promise<boolean> } returns a promise
280
+ * @returns {Promise<BluetoothClassicSerialPortDevice> } returns a promise
288
281
*/
289
282
@Cordova ( {
290
283
platforms : [ 'Android' , 'iOS' , 'Browser' ] ,
291
284
} )
292
- isConnected ( interfaceId : string ) : Promise < boolean > {
285
+ list ( ) : Promise < BluetoothClassicSerialPortDevice [ ] > {
293
286
return ;
294
287
}
295
288
0 commit comments