File tree Expand file tree Collapse file tree 1 file changed +34
-24
lines changed Expand file tree Collapse file tree 1 file changed +34
-24
lines changed Original file line number Diff line number Diff line change @@ -246,39 +246,49 @@ size_t GSMClient::write(const uint8_t* buf, size_t size)
246
246
return 0 ;
247
247
}
248
248
249
- if (size > 512 ) {
250
- size = 512 ;
251
- }
252
-
249
+ size_t written = 0 ;
253
250
String command;
254
- command.reserve (19 + size * 2 );
255
251
256
- command += " AT+USOWR=" ;
257
- command += _socket;
258
- command += " ," ;
259
- command += size;
260
- command += " ,\" " ;
261
252
262
- for ( size_t i = 0 ; i < size; i++ ) {
263
- byte b = buf[i] ;
253
+ while ( size) {
254
+ size_t chunkSize = size ;
264
255
265
- byte n1 = (b >> 4 ) & 0x0f ;
266
- byte n2 = (b & 0x0f );
256
+ if (chunkSize > 256 ) {
257
+ chunkSize = 256 ;
258
+ }
267
259
268
- command += (char )(n1 > 9 ? ' A' + n1 - 10 : ' 0' + n1);
269
- command += (char )(n2 > 9 ? ' A' + n2 - 10 : ' 0' + n2);
270
- }
260
+ command.reserve (19 + chunkSize * 2 );
271
261
272
- command += " \" " ;
273
-
274
- MODEM.send (command);
275
- if (_writeSync) {
276
- if (MODEM.waitForResponse (10000 ) != 1 ) {
277
- return 0 ;
262
+ command += " AT+USOWR=" ;
263
+ command += _socket;
264
+ command += " ," ;
265
+ command += chunkSize;
266
+ command += " ,\" " ;
267
+
268
+ for (size_t i = 0 ; i < chunkSize; i++) {
269
+ byte b = buf[i + written];
270
+
271
+ byte n1 = (b >> 4 ) & 0x0f ;
272
+ byte n2 = (b & 0x0f );
273
+
274
+ command += (char )(n1 > 9 ? ' A' + n1 - 10 : ' 0' + n1);
275
+ command += (char )(n2 > 9 ? ' A' + n2 - 10 : ' 0' + n2);
276
+ }
277
+
278
+ command += " \" " ;
279
+
280
+ MODEM.send (command);
281
+ if (_writeSync) {
282
+ if (MODEM.waitForResponse (10000 ) != 1 ) {
283
+ break ;
284
+ }
278
285
}
286
+
287
+ written += chunkSize;
288
+ size -= chunkSize;
279
289
}
280
290
281
- return size ;
291
+ return written ;
282
292
}
283
293
284
294
void GSMClient::endWrite (bool /* sync*/ )
You can’t perform that action at this time.
0 commit comments