File tree 1 file changed +12
-9
lines changed
libraries/BluetoothSerial/src
1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -220,21 +220,24 @@ int BluetoothSerial::read(void)
220
220
221
221
size_t BluetoothSerial::write (uint8_t c)
222
222
{
223
- if (_spp_client){
224
- uint8_t buffer[1 ];
225
- buffer[0 ] = c;
226
- esp_spp_write (_spp_client, 1 , buffer);
227
- return 1 ;
223
+ if (!_spp_client){
224
+ return 0 ;
228
225
}
229
- return -1 ;
226
+
227
+ uint8_t buffer[1 ];
228
+ buffer[0 ] = c;
229
+ esp_err_t err = esp_spp_write (_spp_client, 1 , buffer);
230
+ return (err == ESP_OK) ? 1 : 0 ;
230
231
}
231
232
232
233
size_t BluetoothSerial::write (const uint8_t *buffer, size_t size)
233
234
{
234
- if (_spp_client){
235
- esp_spp_write (_spp_client, size, ( uint8_t *)buffer) ;
235
+ if (! _spp_client){
236
+ return 0 ;
236
237
}
237
- return size;
238
+
239
+ esp_err_t err = esp_spp_write (_spp_client, size, (uint8_t *)buffer);
240
+ return (err == ESP_OK) ? size : 0 ;
238
241
}
239
242
240
243
void BluetoothSerial::flush ()
You can’t perform that action at this time.
0 commit comments