Skip to content

Commit f9ba6bf

Browse files
committed
Improved bluetooth throughput from 50kBps to 60Bps
Updated camera FPS script to show FPS value
1 parent da25b14 commit f9ba6bf

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

source/application/bluetooth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ void bluetooth_setup(bool factory_reset)
368368
ble_cfg_t cfg;
369369
cfg.conn_cfg.conn_cfg_tag = 1;
370370
cfg.conn_cfg.params.gap_conn_cfg.conn_count = 1;
371-
cfg.conn_cfg.params.gap_conn_cfg.event_length = 300;
371+
cfg.conn_cfg.params.gap_conn_cfg.event_length = (15 * 1000) / 1250;
372372
check_error(sd_ble_cfg_set(BLE_CONN_CFG_GAP, &cfg, ram_start));
373373

374374
// Set BLE role to peripheral only

source/application/bluetooth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <stddef.h>
2929
#include <stdint.h>
3030

31-
#define BLE_PREFERRED_MAX_MTU 256
31+
#define BLE_PREFERRED_MAX_MTU 185
3232
extern uint16_t ble_negotiated_mtu;
3333

3434
void bluetooth_setup(bool factory_reset);

source/memory_layout.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ENTRY(Reset_Handler)
5151
MEMORY
5252
{
5353
APPLICATION_FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0xCE000
54-
APPLICATION_RAM (rwx) : ORIGIN = 0x20002A08, LENGTH = 256K - 0x2A08
54+
APPLICATION_RAM (rwx) : ORIGIN = 0x200026F8, LENGTH = 256K - 0x26F8
5555

5656
BOOTLOADER_FLASH (rx) : ORIGIN = 0xF5000, LENGTH = 0x9000
5757
BOOTLOADER_RAM (rwx) : ORIGIN = 0x20002AE8, LENGTH = 256K - 0x2AE8

tests/test_camera_fps.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from aioconsole import ainput
22
from frameutils import Bluetooth
33
import asyncio
4+
import time
45

56
header = bytearray(
67
[
@@ -631,20 +632,26 @@
631632
)
632633

633634
image_buffer = b""
635+
last_fps_time = time.time()
636+
fps = 0
634637

635638

636639
def receive_data(data):
637640
global image_buffer
641+
global last_fps_time
642+
global fps
638643

639644
if len(data) == 1:
640645
with open("temp_focus_image.jpg", "wb") as f:
641646
f.write(header + image_buffer)
642647
image_buffer = b""
648+
fps = 1 / (time.time() - last_fps_time)
649+
last_fps_time = time.time()
643650
return
644651

645652
image_buffer += data[1:]
646653
print(
647-
f"Received {str(len(image_buffer)-1)} bytes. Press enter to finish ",
654+
f"Received {str(len(image_buffer)-1)} bytes. FPS = {fps}. Press enter to finish ",
648655
end="\r",
649656
)
650657

@@ -658,11 +665,11 @@ async def main():
658665
659666
while true do
660667
if state == 'CAPTURE' then
661-
frame.camera.capture { quality_factor = 25 }
668+
frame.camera.capture { quality_factor = 50 }
662669
state_time = frame.time.utc()
663670
state = 'WAIT'
664671
elseif state == 'WAIT' then
665-
if frame.time.utc() > state_time + 0.2 then
672+
if frame.time.utc() > state_time + 0.1 then
666673
state = 'SEND'
667674
end
668675
elseif state == 'SEND' then

0 commit comments

Comments
 (0)