Skip to content

Commit

Permalink
Improved bluetooth throughput from 50kBps to 60Bps
Browse files Browse the repository at this point in the history
Updated camera FPS script to show FPS value
  • Loading branch information
siliconwitch committed Aug 27, 2024
1 parent da25b14 commit f9ba6bf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion source/application/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void bluetooth_setup(bool factory_reset)
ble_cfg_t cfg;
cfg.conn_cfg.conn_cfg_tag = 1;
cfg.conn_cfg.params.gap_conn_cfg.conn_count = 1;
cfg.conn_cfg.params.gap_conn_cfg.event_length = 300;
cfg.conn_cfg.params.gap_conn_cfg.event_length = (15 * 1000) / 1250;
check_error(sd_ble_cfg_set(BLE_CONN_CFG_GAP, &cfg, ram_start));

// Set BLE role to peripheral only
Expand Down
2 changes: 1 addition & 1 deletion source/application/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <stddef.h>
#include <stdint.h>

#define BLE_PREFERRED_MAX_MTU 256
#define BLE_PREFERRED_MAX_MTU 185
extern uint16_t ble_negotiated_mtu;

void bluetooth_setup(bool factory_reset);
Expand Down
2 changes: 1 addition & 1 deletion source/memory_layout.ld
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ENTRY(Reset_Handler)
MEMORY
{
APPLICATION_FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0xCE000
APPLICATION_RAM (rwx) : ORIGIN = 0x20002A08, LENGTH = 256K - 0x2A08
APPLICATION_RAM (rwx) : ORIGIN = 0x200026F8, LENGTH = 256K - 0x26F8

BOOTLOADER_FLASH (rx) : ORIGIN = 0xF5000, LENGTH = 0x9000
BOOTLOADER_RAM (rwx) : ORIGIN = 0x20002AE8, LENGTH = 256K - 0x2AE8
Expand Down
13 changes: 10 additions & 3 deletions tests/test_camera_fps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from aioconsole import ainput
from frameutils import Bluetooth
import asyncio
import time

header = bytearray(
[
Expand Down Expand Up @@ -631,20 +632,26 @@
)

image_buffer = b""
last_fps_time = time.time()
fps = 0


def receive_data(data):
global image_buffer
global last_fps_time
global fps

if len(data) == 1:
with open("temp_focus_image.jpg", "wb") as f:
f.write(header + image_buffer)
image_buffer = b""
fps = 1 / (time.time() - last_fps_time)
last_fps_time = time.time()
return

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

Expand All @@ -658,11 +665,11 @@ async def main():
while true do
if state == 'CAPTURE' then
frame.camera.capture { quality_factor = 25 }
frame.camera.capture { quality_factor = 50 }
state_time = frame.time.utc()
state = 'WAIT'
elseif state == 'WAIT' then
if frame.time.utc() > state_time + 0.2 then
if frame.time.utc() > state_time + 0.1 then
state = 'SEND'
end
elseif state == 'SEND' then
Expand Down

0 comments on commit f9ba6bf

Please sign in to comment.