40
40
41
41
const char *_spp_server_name = " ESP32SPP" ;
42
42
43
- #define RX_QUEUE_SIZE 512
44
- #define TX_QUEUE_SIZE 32
43
+ // #define RX_QUEUE_SIZE 512
44
+ // #define TX_QUEUE_SIZE 32
45
45
#define SPP_TX_QUEUE_TIMEOUT 1000
46
46
#define SPP_TX_DONE_TIMEOUT 1000
47
47
#define SPP_CONGESTED_TIMEOUT 1000
@@ -347,7 +347,7 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) {
347
347
} else if (_spp_rx_queue != NULL ) {
348
348
for (int i = 0 ; i < param->data_ind .len ; i++) {
349
349
if (xQueueSend (_spp_rx_queue, param->data_ind .data + i, (TickType_t)0 ) != pdTRUE) {
350
- log_e (" RX Full! Discarding %u bytes" , param->data_ind .len - i);
350
+ Serial. printf (" RX Full! Discarding %u bytes\r\n " , param->data_ind .len - i);
351
351
break ;
352
352
}
353
353
}
@@ -616,7 +616,7 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
616
616
}
617
617
}
618
618
619
- static bool _init_bt (const char *deviceName, bt_mode mode) {
619
+ static bool _init_bt (const char *deviceName, bt_mode mode, uint16_t rxQueueSize, uint16_t txQueueSize ) {
620
620
if (!_bt_event_group) {
621
621
_bt_event_group = xEventGroupCreate ();
622
622
if (!_bt_event_group) {
@@ -637,14 +637,16 @@ static bool _init_bt(const char *deviceName, bt_mode mode) {
637
637
xEventGroupSetBits (_spp_event_group, SPP_CLOSED);
638
638
}
639
639
if (_spp_rx_queue == NULL ) {
640
- _spp_rx_queue = xQueueCreate (RX_QUEUE_SIZE, sizeof (uint8_t )); // initialize the queue
640
+ // _spp_rx_queue = xQueueCreate(RX_QUEUE_SIZE, sizeof(uint8_t)); //initialize the queue
641
+ _spp_rx_queue = xQueueCreate (rxQueueSize, sizeof (uint8_t )); // initialize the queue
641
642
if (_spp_rx_queue == NULL ) {
642
643
log_e (" RX Queue Create Failed" );
643
644
return false ;
644
645
}
645
646
}
646
647
if (_spp_tx_queue == NULL ) {
647
- _spp_tx_queue = xQueueCreate (TX_QUEUE_SIZE, sizeof (spp_packet_t *)); // initialize the queue
648
+ // _spp_tx_queue = xQueueCreate(TX_QUEUE_SIZE, sizeof(spp_packet_t *)); //initialize the queue
649
+ _spp_tx_queue = xQueueCreate (txQueueSize, sizeof (spp_packet_t *)); // initialize the queue
648
650
if (_spp_tx_queue == NULL ) {
649
651
log_e (" TX Queue Create Failed" );
650
652
return false ;
@@ -820,12 +822,13 @@ BluetoothSerial::~BluetoothSerial(void) {
820
822
* @param isMaster set to true if you want to connect to an other device
821
823
* @param disableBLE if BLE is not used, its ram can be freed to get +10kB free ram
822
824
*/
823
- bool BluetoothSerial::begin (String localName, bool isMaster, bool disableBLE) {
825
+ // bool BluetoothSerial::begin(String localName, bool isMaster, bool disableBLE) {
826
+ bool BluetoothSerial::begin (String localName, bool isMaster, bool disableBLE, uint16_t rxQueueSize, uint16_t txQueueSize) {
824
827
_isMaster = isMaster;
825
828
if (localName.length ()) {
826
829
local_name = localName;
827
830
}
828
- return _init_bt (local_name.c_str (), disableBLE ? BT_MODE_CLASSIC_BT : BT_MODE_BTDM);
831
+ return _init_bt (local_name.c_str (), disableBLE ? BT_MODE_CLASSIC_BT : BT_MODE_BTDM, rxQueueSize, txQueueSize );
829
832
}
830
833
831
834
int BluetoothSerial::available (void ) {
0 commit comments