Skip to content

Commit 1b93325

Browse files
committed
Increase SPP_TX_MAX buffer size. Move congested message to debug level. Report more heap info.
1 parent a8a93ff commit 1b93325

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

Firmware/RTK_Surveyor/System.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ void reportHeap()
654654
if (millis() - lastHeapReport > 1000)
655655
{
656656
lastHeapReport = millis();
657-
Serial.printf("FreeHeap: %d\n\r", ESP.getFreeHeap());
657+
Serial.printf("FreeHeap: %d / HeapLowestPoint: %d / LargestBlock: %d\n\r", ESP.getFreeHeap(), xPortGetMinimumEverFreeHeapSize(), heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
658658
}
659659
}
660660
}

Firmware/RTK_Surveyor/src/BluetoothSerial/BluetoothSerial.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,18 @@ static esp_err_t _spp_queue_packet(uint8_t *data, size_t len){
158158
return ESP_OK;
159159
}
160160

161-
const uint16_t SPP_TX_MAX = 330;
161+
//SPP_TX_MAX seems to default to a lower amount (330) until there is congestion it then
162+
//tries to catch up but at 330, it cannot and the heap begins to take the hit.
163+
//Increasing the max to 2048 we see normal verbose xfers of 512 until congestion
164+
//when it increases briefly to 2048 then returns to 512 with no heap hit.
165+
//The rate at which we congest is dependant on how much we are attempting to TX and
166+
//how much is coming in RX from the phone.
167+
//At ~25kBps heap lowest point is 100k and stable
168+
//At ~50kBps heap lowest point is ~78k and stable
169+
//Above 50kbps it becomes unstable
170+
171+
//const uint16_t SPP_TX_MAX = 330; //Original
172+
const uint16_t SPP_TX_MAX = 512*4;
162173
static uint8_t _spp_tx_buffer[SPP_TX_MAX];
163174
static uint16_t _spp_tx_buffer_len = 0;
164175

@@ -288,10 +299,13 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
288299
case ESP_SPP_CONG_EVT://connection congestion status changed
289300
if(param->cong.cong){
290301
xEventGroupClearBits(_spp_event_group, SPP_CONGESTED);
291-
} else {
302+
log_d("ESP_SPP_CONG_EVT: CONGESTED");
303+
}
304+
else
305+
{
292306
xEventGroupSetBits(_spp_event_group, SPP_CONGESTED);
293307
}
294-
log_v("ESP_SPP_CONG_EVT: %s", param->cong.cong?"CONGESTED":"FREE");
308+
//log_v("ESP_SPP_CONG_EVT: %s", param->cong.cong ? "CONGESTED" : "FREE");
295309
break;
296310

297311
case ESP_SPP_WRITE_EVT://write operation completed

Firmware/RTK_Surveyor/src/BluetoothSerial/BluetoothSerial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BluetoothSerial: public Stream
3535
BluetoothSerial(void);
3636
~BluetoothSerial(void);
3737

38-
bool begin(String localName=String(), bool isMaster=false, uint16_t rxQueueSize = 512, uint16_t txQueueSize = 512);
38+
bool begin(String localName=String(), bool isMaster=false, uint16_t rxQueueSize = 512 * 4, uint16_t txQueueSize = 512);
3939
int available(void);
4040
int peek(void);
4141
bool hasClient(void);

0 commit comments

Comments
 (0)