Skip to content

Commit d81599d

Browse files
committed
increase ada callback queue size from 20 to 40
- fox adacallback queue overflow with large image - fix issue with tft draw bitmap
1 parent dee231e commit d81599d

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

cores/nRF5/utility/AdaCallback.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ void adafruit_callback_task(void* arg)
4747
ada_callback_t* cb_data;
4848
if ( xQueueReceive(_cb_queue, (void*) &cb_data, portMAX_DELAY) )
4949
{
50-
// PRINT_HEX(cb_data);
51-
// PRINT_HEX(cb_data->malloced_data);
52-
5350
const void* func = cb_data->callback_func;
5451
uint32_t* args = cb_data->arguments;
5552

@@ -85,7 +82,10 @@ void ada_callback_queue(ada_callback_t* cb_item)
8582
xQueueSendFromISR(_cb_queue, (void*) &cb_item, NULL);
8683
}else
8784
{
88-
xQueueSend(_cb_queue, (void*) &cb_item, CFG_CALLBACK_TIMEOUT);
85+
if ( !xQueueSend(_cb_queue, (void*) &cb_item, CFG_CALLBACK_TIMEOUT) )
86+
{
87+
LOG_LV1("MEMORY", "AdaCallback run out of queue item, increase CFG_CALLBACK_QUEUE_LENGTH");
88+
}
8989
}
9090
}
9191

cores/nRF5/utility/AdaCallback.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#endif
4444

4545
#ifndef CFG_CALLBACK_QUEUE_LENGTH
46-
#define CFG_CALLBACK_QUEUE_LENGTH 20
46+
#define CFG_CALLBACK_QUEUE_LENGTH 40
4747
#endif
4848

4949
#ifndef CFG_CALLBACK_TIMEOUT

libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ BLEUart bleuart(1024*10);
6868

6969
uint16_t imageWidth = 0;
7070
uint16_t imageHeight = 0;
71-
uint16_t imageX = 0;
72-
uint16_t imageY = 0;
7371

7472
uint32_t totalPixel = 0; // received pixel
7573

@@ -172,6 +170,19 @@ void loop()
172170
// Chop pixel number to multiple of image width
173171
pixelNum = (pixelNum / imageWidth) * imageWidth;
174172

173+
#if 0
174+
static uint32_t last_available = 0;
175+
if ( last_available != bleuart.available() )
176+
{
177+
last_available = bleuart.available();
178+
179+
PRINT_INT(totalPixel);
180+
PRINT_INT(last_available);
181+
PRINT_INT(pixelNum);
182+
Serial.println();
183+
}
184+
#endif
185+
175186
if ( pixelNum )
176187
{
177188
for ( uint16_t i=0; i < pixelNum; i++)
@@ -183,12 +194,8 @@ void loop()
183194
color_buf[i] = ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | ( blue >> 3);
184195
}
185196

186-
tft.drawRGBBitmap(imageX, imageY, color_buf, imageWidth, imageHeight - imageY);
187-
197+
tft.drawRGBBitmap(0, totalPixel/imageWidth, color_buf, imageWidth, pixelNum/imageWidth);
188198
totalPixel += pixelNum;
189-
190-
imageX = totalPixel % imageWidth;
191-
imageY = totalPixel / imageWidth;
192199
}
193200
}
194201

@@ -265,7 +272,6 @@ void bleuart_rx_callback(uint16_t conn_hdl)
265272

266273
tft.fillScreen(COLOR_BLACK);
267274
tft.setCursor(0, 0);
268-
imageX = imageY = 0;
269275
}
270276
}
271277

libraries/Bluefruit52Lib/src/BLECharacteristic.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,11 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
468468
{
469469
ble_gatts_evt_write_t* request = &event->evt.gatts_evt.params.write;
470470

471-
LOG_LV2_BUFFER(NULL, request->data, request->len);
472-
473471
// Value write
474472
if (request->handle == _handles.value_handle)
475473
{
476-
LOG_LV2("GATTS", "attr's value, uuid = 0x%04X", request->uuid.uuid);
474+
LOG_LV2("GATTS", "attr's value, uuid = 0x%04X, len = %d", request->uuid.uuid, request->len);
475+
LOG_LV2_BUFFER(NULL, request->data, request->len);
477476

478477
if (_wr_cb)
479478
{
@@ -490,13 +489,13 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
490489
// CCCD write
491490
if ( request->handle == _handles.cccd_handle )
492491
{
493-
LOG_LV2("GATTS", "attr's cccd");
492+
uint16_t value;
493+
memcpy(&value, request->data, 2);
494+
495+
LOG_LV1("GATTS", "attr's cccd = 0x%04X", value);
494496

495497
if (_cccd_wr_cb)
496498
{
497-
uint16_t value;
498-
memcpy(&value, request->data, 2);
499-
500499
if ( _use_ada_cb.cccd_write )
501500
{
502501
ada_callback(NULL, 0, _cccd_wr_cb, conn_hdl, this, value);

0 commit comments

Comments
 (0)