4040
4141const char *_spp_server_name = " ESP32SPP" ;
4242
43- #define RX_QUEUE_SIZE 512
44- #define TX_QUEUE_SIZE 32
43+ // #define RX_QUEUE_SIZE 512
44+ // #define TX_QUEUE_SIZE 32
4545#define SPP_TX_QUEUE_TIMEOUT 1000
4646#define SPP_TX_DONE_TIMEOUT 1000
4747#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) {
347347 } else if (_spp_rx_queue != NULL ) {
348348 for (int i = 0 ; i < param->data_ind .len ; i++) {
349349 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);
351351 break ;
352352 }
353353 }
@@ -616,7 +616,7 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
616616 }
617617}
618618
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 ) {
620620 if (!_bt_event_group) {
621621 _bt_event_group = xEventGroupCreate ();
622622 if (!_bt_event_group) {
@@ -637,14 +637,16 @@ static bool _init_bt(const char *deviceName, bt_mode mode) {
637637 xEventGroupSetBits (_spp_event_group, SPP_CLOSED);
638638 }
639639 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
641642 if (_spp_rx_queue == NULL ) {
642643 log_e (" RX Queue Create Failed" );
643644 return false ;
644645 }
645646 }
646647 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
648650 if (_spp_tx_queue == NULL ) {
649651 log_e (" TX Queue Create Failed" );
650652 return false ;
@@ -820,12 +822,13 @@ BluetoothSerial::~BluetoothSerial(void) {
820822 * @param isMaster set to true if you want to connect to an other device
821823 * @param disableBLE if BLE is not used, its ram can be freed to get +10kB free ram
822824 */
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) {
824827 _isMaster = isMaster;
825828 if (localName.length ()) {
826829 local_name = localName;
827830 }
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 );
829832}
830833
831834int BluetoothSerial::available (void ) {
0 commit comments