@@ -151,7 +151,7 @@ Or more advanced usage with control of the connection
151
151
} ;
152
152
153
153
connection . write = function ( data , callback ) {
154
- if ( data ) txDataQueue . push ( { data :data , callback :callback } ) ;
154
+ if ( data ) txDataQueue . push ( { data :data , callback :callback , maxLength : data . length } ) ;
155
155
if ( connection . isOpen && ! connection . txInProgress ) writeChunk ( ) ;
156
156
157
157
function writeChunk ( ) {
@@ -160,8 +160,12 @@ Or more advanced usage with control of the connection
160
160
return ;
161
161
}
162
162
var chunk ;
163
- if ( ! txDataQueue . length ) return ;
163
+ if ( ! txDataQueue . length ) {
164
+ puck . writeProgress ( ) ;
165
+ return ;
166
+ }
164
167
var txItem = txDataQueue [ 0 ] ;
168
+ puck . writeProgress ( txItem . maxLength - txItem . data . length , txItem . maxLength ) ;
165
169
if ( txItem . data . length <= CHUNKSIZE ) {
166
170
chunk = txItem . data ;
167
171
txItem . data = undefined ;
@@ -356,6 +360,10 @@ Or more advanced usage with control of the connection
356
360
flowControl : true ,
357
361
/// Used internally to write log information - you can replace this with your own function
358
362
log : function ( level , s ) { if ( level <= this . debug ) console . log ( "<BLE> " + s ) } ,
363
+ /// Called with the current send progress or undefined when done - you can replace this with your own function
364
+ writeProgress : function ( charsSent , charsTotal ) {
365
+ //console.log(charsSent + "/" + charsTotal);
366
+ } ,
359
367
/** Connect to a new device - this creates a separate
360
368
connection to the one `write` and `eval` use. */
361
369
connect : connect ,
0 commit comments