Skip to content

feat(ble): add pauseable transport lifecycle - #1041

Draft
hitsmaxft wants to merge 2 commits into
rmk-rs:mainfrom
hitsmaxft:agent/ble-transport-lifecycle
Draft

feat(ble): add pauseable transport lifecycle#1041
hitsmaxft wants to merge 2 commits into
rmk-rs:mainfrom
hitsmaxft:agent/ble-transport-lifecycle

Conversation

@hitsmaxft

Copy link
Copy Markdown
Contributor

Outcome

Add an opt-in control handle that lets applications pause and resume a non-split BLE transport without canceling and rebuilding its trouble-host runner.

Context

BleTransport::run() owns the controller and constructs the BLE stack internally. Applications that cancel the future to hand radio time to another transport cannot run the same transport again because the controller has already been taken.

Changes

  • add BleTransportControl::{new,new_paused,pause,resume} and BleTransport::with_control
  • keep the trouble-host runner alive while the host advertising/connection loop is paused
  • drop an active advertiser or request and observe disconnection before parking the host loop
  • continue servicing BLE profile changes while paused so the private profile queue cannot block producers
  • preserve existing behavior when no control handle is attached
  • keep the API limited to non-split transports; transition details remain private

Validation

  • release Clippy with -D warnings across all 19 RMK CI feature sets
  • 488 release nextest cases with vial,_ble,std
  • focused enabled and initially-paused lifecycle tests
  • downstream nRF52833 EC and MX tri-mode release checks against this exact commit
  • downstream protocol tests: 45 passed
  • downstream transport/profile tests: 13 passed

Evidence boundary

This validates the lifecycle state machine, feature compatibility, and downstream Cortex-M4 builds. It does not claim physical BLE reconnection, external-radio coexistence, or HID-host delivery; those remain hardware acceptance gates.

@github-actions

Copy link
Copy Markdown

Size Report

Example main PR Diff .text .data .bss
use_config/nrf52832_ble 397.6 KiB 398.1 KiB +0.13% ⬆️ +512 0 +40
use_config/nrf52840_ble 439.6 KiB 439.9 KiB +0.05% ⬆️ +192 0 +48
use_config/nrf52840_ble_split (central) 500.8 KiB 501.8 KiB +0.20% ⬆️ +1032 0 +32
use_config/nrf52840_ble_split (peripheral) 318.8 KiB 318.8 KiB +0.00% 0 0 0
use_config/pi_pico_w_ble 672.7 KiB 673.7 KiB +0.15% ⬆️ +1048 0 +40
use_config/rp2040 146.3 KiB 146.3 KiB +0.00% 0 0 0
use_config/rp2040_split (central) 159.9 KiB 159.9 KiB +0.00% ⬇️ -4 0 0
use_config/rp2040_split (peripheral) 27.9 KiB 27.9 KiB +0.00% 0 0 0
use_config/stm32f1 62.6 KiB 62.6 KiB +0.00% ⬆️ +4 0 0
use_config/stm32h7 100.4 KiB 100.4 KiB +0.00% 0 0 0
use_rust/nrf52832_ble 385.2 KiB 386.0 KiB +0.22% ⬆️ +840 0 +48
use_rust/nrf52840_ble 435.2 KiB 435.3 KiB +0.01% ⬆️ +36 0 +40
use_rust/nrf52840_ble_split (central) 504.3 KiB 504.8 KiB +0.10% ⬆️ +488 0 +32
use_rust/nrf52840_ble_split (peripheral) 316.4 KiB 316.4 KiB +0.00% ⬆️ +4 0 0
use_rust/pi_pico_w_ble 672.1 KiB 672.8 KiB +0.10% ⬆️ +704 0 +40
use_rust/rp2040 145.6 KiB 145.6 KiB +0.00% ⬇️ -4 0 0
use_rust/rp2040_split (central) 158.4 KiB 158.4 KiB +0.00% 0 0 0
use_rust/rp2040_split (peripheral) 28.2 KiB 28.2 KiB +0.00% 0 0 0
use_rust/stm32f1 61.9 KiB 61.9 KiB +0.00% ⬇️ -4 0 0
use_rust/stm32h7 119.7 KiB 119.7 KiB +0.00% 0 0 0
use_config/nrf52832_ble — 397.6 KiB → 398.1 KiB (+0.13% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 365384	   8620	  33664	 407668	  63874	rmk-nrf52832

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 364872	   8620	  33624	 407116	  6364c	rmk-nrf52832

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.3% +11.2Ki  [ = ]       0    .debug_str
  +0.3% +6.58Ki  [ = ]       0    .debug_info
  +0.7% +4.78Ki  [ = ]       0    .debug_loc
  +0.5% +1.07Ki  [ = ]       0    .debug_ranges
  +0.2%    +720  [ = ]       0    .debug_line
  +0.1%    +464  +0.1%    +464    .text
  +0.1%    +389  [ = ]       0    .strtab
  +0.1%    +112  [ = ]       0    .symtab
  +0.9%     +70  [ = ]       0    .debug_abbrev
  +0.1%     +56  [ = ]       0    .debug_frame
  +0.1%     +48  +0.1%     +48    .rodata
  [ = ]       0  +0.1%     +40    .bss
  +0.3% +25.4Ki  +0.1%    +552    TOTAL
use_config/nrf52840_ble — 439.6 KiB → 439.9 KiB (+0.05% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 398096	   8628	  43712	 450436	  6df84	rmk-nrf52840

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 397904	   8628	  43664	 450196	  6de94	rmk-nrf52840

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +4.95Ki  [ = ]       0    .debug_str
  +0.2% +3.71Ki  [ = ]       0    .debug_info
  +0.3% +2.40Ki  [ = ]       0    .debug_loc
  +0.5% +1.22Ki  [ = ]       0    .debug_ranges
  +0.1%    +540  [ = ]       0    .strtab
  +0.1%    +417  [ = ]       0    .debug_line
  +0.1%    +144  [ = ]       0    .symtab
  +0.0%    +144  +0.0%    +144    .text
  +0.1%     +64  [ = ]       0    .debug_frame
  [ = ]       0  +0.1%     +48    .bss
  +0.1%     +48  +0.1%     +48    .rodata
  -2.2%      -1  [ = ]       0    [Unmapped]
  +0.2% +13.6Ki  +0.1%    +240    TOTAL
use_config/nrf52840_ble_split (central) — 500.8 KiB → 501.8 KiB (+0.20% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 456292	   8684	  48888	 513864	  7d748	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 455260	   8684	  48856	 512800	  7d320	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +5.46Ki  [ = ]       0    .debug_str
  +0.2% +3.78Ki  [ = ]       0    .debug_info
  +0.4% +1.02Ki  [ = ]       0    .debug_ranges
  +0.2%    +984  +0.2%    +984    .text
  +0.1%    +923  [ = ]       0    .debug_loc
  +0.1%    +515  [ = ]       0    .debug_line
  +0.1%    +337  [ = ]       0    .strtab
  +0.1%    +208  [ = ]       0    .symtab
  +0.2%    +128  [ = ]       0    .debug_frame
  +0.1%     +48  [ = ]       0    .debug_aranges
  +0.1%     +48  +0.1%     +48    .rodata
  [ = ]       0  +0.1%     +32    .bss
  -5.9%      -4  [ = ]       0    [Unmapped]
  +0.1% +13.4Ki  +0.2% +1.04Ki    TOTAL
use_config/nrf52840_ble_split (peripheral) — 318.8 KiB → 318.8 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 292804	   8500	  25184	 326488	  4fb58	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 292804	   8500	  25184	 326488	  4fb58	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +2  [ = ]       0    .debug_info
  -0.0%      -1  [ = ]       0    .strtab
  -5.3%      -3  [ = ]       0    [Unmapped]
  -0.0%     -14  [ = ]       0    .debug_str
  -0.0%     -16  [ = ]       0    TOTAL
use_config/pi_pico_w_ble — 672.7 KiB → 673.7 KiB (+0.15% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 636148	      0	  53744	 689892	  a86e4	rmk-pi-pico-w

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 635100	      0	  53704	 688804	  a82a4	rmk-pi-pico-w

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +1.2% +13.4Ki  [ = ]       0    .debug_loc
  +0.1% +5.82Ki  [ = ]       0    .debug_str
  +0.2% +4.60Ki  [ = ]       0    .debug_info
  +0.3%   +1000  +0.3%   +1000    .text
  +0.2%    +933  [ = ]       0    .debug_line
  +0.6%    +480  [ = ]       0    .symtab
  +0.1%    +266  [ = ]       0    .strtab
  +0.2%     +92  [ = ]       0    .debug_frame
  +0.0%     +48  +0.0%     +48    .rodata
  [ = ]       0  +0.1%     +40    .bss
  +0.1%     +24  [ = ]       0    .debug_aranges
   +20%     +10  [ = ]       0    [Unmapped]
  -0.1%    -224  [ = ]       0    .debug_ranges
  +0.3% +26.4Ki  +0.2% +1.06Ki    TOTAL
use_config/rp2040 — 146.3 KiB → 146.3 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 135880	      0	  13908	 149788	  2491c	rmk-rp2040

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 135880	      0	  13908	 149788	  2491c	rmk-rp2040

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +72  [ = ]       0    .debug_str
  +0.0%     +10  [ = ]       0    .debug_loc
  +0.0%      +8  [ = ]       0    .strtab
  -0.0%      -9  [ = ]       0    .debug_info
  -0.0%     -57  [ = ]       0    .debug_line
  +0.0%     +24  [ = ]       0    TOTAL
use_config/rp2040_split (central) — 159.9 KiB → 159.9 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 148908	      0	  14860	 163768	  27fb8	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 148912	      0	  14860	 163772	  27fbc	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +19  [ = ]       0    .debug_line
  +0.0%     +12  [ = ]       0    .debug_info
  +0.0%     +10  [ = ]       0    .debug_loc
  -0.0%      -4  [ = ]       0    .strtab
  -0.0%      -4  -0.0%      -4    .text
 -43.3%     -29  [ = ]       0    [Unmapped]
  -0.0%     -36  [ = ]       0    .debug_str
  -0.0%     -32  -0.0%      -4    TOTAL
use_config/rp2040_split (peripheral) — 27.9 KiB → 27.9 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  25696	     60	   2804	  28560	   6f90	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  25696	     60	   2804	  28560	   6f90	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +1  [ = ]       0    .debug_str
  +0.0%      +1  [ = ]       0    .strtab
  -3.9%      -2  [ = ]       0    [Unmapped]
  [ = ]       0  [ = ]       0    TOTAL
use_config/stm32f1 — 62.6 KiB → 62.6 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  57748	     28	   6336	  64112	   fa70	rmk-stm32f1

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  57744	     28	   6336	  64108	   fa6c	rmk-stm32f1

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +4  +0.0%      +4    .text
  -1.5%      -1  [ = ]       0    [Unmapped]
  -0.0%      -6  [ = ]       0    .debug_line
  -0.0%      -9  [ = ]       0    .strtab
  -0.0%     -64  [ = ]       0    .debug_str
  -0.0%     -76  +0.0%      +4    TOTAL
use_config/stm32h7 — 100.4 KiB → 100.4 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  94440	    264	   8128	 102832	  191b0	rmk-stm32h7

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  94440	    264	   8128	 102832	  191b0	rmk-stm32h7

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +124  [ = ]       0    .debug_line
  +0.0%    +100  [ = ]       0    .debug_str
  +0.0%     +36  [ = ]       0    .debug_info
  +0.0%    +260  [ = ]       0    TOTAL
use_rust/nrf52832_ble — 385.2 KiB → 386.0 KiB (+0.22% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 353072	   8620	  33608	 395300	  60824	rmk-nrf52832

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 352232	   8620	  33560	 394412	  604ac	rmk-nrf52832

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.3% +11.8Ki  [ = ]       0    .debug_str
  +0.4% +6.50Ki  [ = ]       0    .debug_info
  +0.4% +2.76Ki  [ = ]       0    .debug_loc
  +0.3%    +867  [ = ]       0    .debug_line
  +0.4%    +824  [ = ]       0    .debug_ranges
  +0.3%    +792  +0.3%    +792    .text
  +0.2%    +503  [ = ]       0    .strtab
  +0.2%    +240  [ = ]       0    .symtab
  +0.3%    +136  [ = ]       0    .debug_frame
  [ = ]       0  +0.1%     +48    .bss
  +0.1%     +48  +0.1%     +48    .rodata
  +0.1%     +40  [ = ]       0    .debug_aranges
  +0.1%     +12  [ = ]       0    .debug_abbrev
  -6.7%      -4  [ = ]       0    [Unmapped]
  +0.3% +24.4Ki  +0.2%    +888    TOTAL
use_rust/nrf52840_ble — 435.2 KiB → 435.3 KiB (+0.01% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 396176	   8628	  40944	 445748	  6cd34	rmk-nrf52840

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 396140	   8628	  40904	 445672	  6cce8	rmk-nrf52840

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +4.74Ki  [ = ]       0    .debug_str
  +0.2% +4.15Ki  [ = ]       0    .debug_info
  +0.3% +1.88Ki  [ = ]       0    .debug_loc
  +0.5% +1.16Ki  [ = ]       0    .debug_ranges
  +0.2%    +569  [ = ]       0    .debug_line
  +0.1%    +509  [ = ]       0    .strtab
  +0.1%     +48  [ = ]       0    .debug_frame
  +0.1%     +48  +0.1%     +48    .rodata
  [ = ]       0  +0.1%     +40    .bss
  -6.5%      -3  [ = ]       0    [Unmapped]
  -0.0%      -8  [ = ]       0    .debug_aranges
  -0.0%     -12  -0.0%     -12    .text
  -0.0%     -16  [ = ]       0    .symtab
  +0.2% +13.0Ki  +0.0%     +76    TOTAL
use_rust/nrf52840_ble_split (central) — 504.3 KiB → 504.8 KiB (+0.10% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 457372	   8684	  50856	 516912	  7e330	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 456884	   8684	  50824	 516392	  7e128	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +5.52Ki  [ = ]       0    .debug_str
  +0.2% +3.64Ki  [ = ]       0    .debug_info
  +0.3%    +680  [ = ]       0    .debug_ranges
  +0.1%    +558  [ = ]       0    .debug_line
  +0.1%    +440  +0.1%    +440    .text
  +0.0%    +197  [ = ]       0    .strtab
  +0.1%     +48  [ = ]       0    .debug_frame
  +0.1%     +48  +0.1%     +48    .rodata
  [ = ]       0  +0.1%     +32    .bss
  +0.0%      +8  [ = ]       0    .debug_aranges
 -21.2%     -11  [ = ]       0    [Unmapped]
  -0.0%     -16  [ = ]       0    .symtab
  -0.0%    -130  [ = ]       0    .debug_loc
  +0.1% +10.9Ki  +0.1%    +520    TOTAL
use_rust/nrf52840_ble_split (peripheral) — 316.4 KiB → 316.4 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 290540	   8500	  24952	 323992	  4f198	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 290536	   8500	  24952	 323988	  4f194	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +4  +0.0%      +4    .text
  +0.0%      +2  [ = ]       0    .debug_info
  -0.0%      -1  [ = ]       0    .strtab
  -2.0%      -1  [ = ]       0    [Unmapped]
  -0.0%     -10  [ = ]       0    .debug_loc
  -0.0%     -14  [ = ]       0    .debug_str
  -0.0%     -20  +0.0%      +4    TOTAL
use_rust/pi_pico_w_ble — 672.1 KiB → 672.8 KiB (+0.10% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 635544	      0	  53424	 688968	  a8348	rmk-pi-pico-w

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 634840	      0	  53384	 688224	  a8060	rmk-pi-pico-w

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +5.79Ki  [ = ]       0    .debug_str
  +0.4% +4.49Ki  [ = ]       0    .debug_loc
  +0.2% +4.32Ki  [ = ]       0    .debug_info
  +0.2%    +656  +0.2%    +656    .text
  +0.2%    +632  [ = ]       0    .debug_ranges
  +0.1%    +572  [ = ]       0    .debug_line
  +0.4%    +320  [ = ]       0    .symtab
  +0.1%    +218  [ = ]       0    .strtab
  +0.2%     +92  [ = ]       0    .debug_frame
  +0.0%     +48  +0.0%     +48    .rodata
  [ = ]       0  +0.1%     +40    .bss
  +0.1%     +24  [ = ]       0    .debug_aranges
  -1.8%      -1  [ = ]       0    [Unmapped]
  +0.2% +17.1Ki  +0.1%    +744    TOTAL
use_rust/rp2040 — 145.6 KiB → 145.6 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 135312	      0	  13748	 149060	  24644	rmk-rp2040

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 135316	      0	  13748	 149064	  24648	rmk-rp2040

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%     +91  [ = ]       0    .debug_line
  +0.0%     +46  [ = ]       0    .debug_info
  +0.0%     +30  [ = ]       0    .debug_str
  +8.3%      +5  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  -0.0%      -6  [ = ]       0    .strtab
  -0.0%     -10  [ = ]       0    .debug_loc
  +0.0%    +152  -0.0%      -4    TOTAL
use_rust/rp2040_split (central) — 158.4 KiB → 158.4 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 147612	      0	  14604	 162216	  279a8	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 147612	      0	  14604	 162216	  279a8	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +1.9%      +1  [ = ]       0    [Unmapped]
  -0.0%      -9  [ = ]       0    .strtab
  -0.0%     -25  [ = ]       0    .debug_info
  -0.1%    -106  [ = ]       0    .debug_line
  -0.0%    -141  [ = ]       0    .debug_str
  -0.0%    -280  [ = ]       0    TOTAL
use_rust/rp2040_split (peripheral) — 28.2 KiB → 28.2 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  25796	     60	   3068	  28924	   70fc	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  25796	     60	   3068	  28924	   70fc	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_rust/stm32f1 — 61.9 KiB → 61.9 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  57080	     28	   6272	  63380	   f794	rmk-stm32f1

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  57084	     28	   6272	  63384	   f798	rmk-stm32f1

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +62  [ = ]       0    .debug_str
  +0.0%      +9  [ = ]       0    .strtab
  +0.0%      +6  [ = ]       0    .debug_line
  +5.3%      +3  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  +0.0%     +76  -0.0%      -4    TOTAL
use_rust/stm32h7 — 119.7 KiB → 119.7 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 108184	    320	  14028	 122532	  1dea4	rmk-stm32h7

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 108184	    320	  14028	 122532	  1dea4	rmk-stm32h7

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  -0.0%      -1  [ = ]       0    .debug_str
  -0.0%      -1  [ = ]       0    .strtab
  -3.4%      -2  [ = ]       0    [Unmapped]
  -0.0%     -12  [ = ]       0    .debug_loc
  -0.0%     -16  [ = ]       0    TOTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant