@@ -114,68 +114,6 @@ const pbdrv_ioport_platform_data_t pbdrv_ioport_platform_data[PBDRV_CONFIG_IOPOR
114114
115115char bluetooth_address_string [6 * 3 ]; // 6 hex bytes separated by ':' and ending in 0.
116116
117- static void legacy_bluetooth_init_blocking (void ) {
118- nx_bt_init ();
119-
120- nx_bt_set_friendly_name ("Pybricks NXT" );
121-
122- uint8_t local_addr [7 ];
123- if (nx_bt_get_local_addr (local_addr )) {
124- snprintf (bluetooth_address_string , sizeof (bluetooth_address_string ),
125- "%02X:%02X:%02X:%02X:%02X:%02X" ,
126- local_addr [0 ], local_addr [1 ], local_addr [2 ],
127- local_addr [3 ], local_addr [4 ], local_addr [5 ]);
128- }
129-
130- nx_display_string (bluetooth_address_string );
131- nx_display_string ("\n" );
132- }
133-
134- // REVISIT: This process waits for the user to connect to the NXT brick with
135- // Bluetooth classic (RFCOMM). This allows basic I/O until proper Pybricks USB
136- // or Bluetooth classic solutions are implemented. Then this process will be
137- // removed.
138- static pbio_os_process_t legacy_bluetooth_connect_process ;
139-
140- static pbio_error_t legacy_bluetooth_connect_process_thread (pbio_os_state_t * state , void * context ) {
141-
142- PBIO_OS_ASYNC_BEGIN (state );
143-
144- static pbio_os_timer_t timer ;
145-
146- static int connection_handle = -1 ;
147-
148- while (!nx_bt_stream_opened ()) {
149-
150- if (nx_bt_has_dev_waiting_for_pin ()) {
151- nx_bt_send_pin ("1234" );
152- nx_display_string ("Please enter pin.\n" );
153- } else if (nx_bt_connection_pending ()) {
154- nx_display_string ("Connecting ...\n" );
155- nx_bt_accept_connection (true);
156-
157- while ((connection_handle = nx_bt_connection_established ()) < 0 ) {
158- PBIO_OS_AWAIT_MS (state , & timer , 2 );
159- }
160-
161- nx_bt_stream_open (connection_handle );
162- }
163-
164- PBIO_OS_AWAIT_MS (state , & timer , 100 );
165- }
166-
167- nx_display_clear ();
168- nx_display_cursor_set_pos (0 , 0 );
169-
170- nx_display_string ("RFCOMM ready.\n" );
171-
172- PBIO_OS_ASYNC_END (PBIO_SUCCESS );
173- }
174-
175- bool nx_bt_is_ready (void ) {
176- return legacy_bluetooth_connect_process .err == PBIO_SUCCESS ;
177- }
178-
179117// Called from assembly code in startup.S
180118void SystemInit (void ) {
181119 nx__aic_init ();
@@ -202,9 +140,16 @@ void SystemInit(void) {
202140 /* Delay a little post-init, to let all the drivers settle down. */
203141 nx_systick_wait_ms (100 );
204142
205- // Blocking Bluetooth setup, then await user connection without blocking,
206- // allowing pbio processes to start even if nothing is connected.
207- legacy_bluetooth_init_blocking ();
208- pbio_os_process_start (& legacy_bluetooth_connect_process , legacy_bluetooth_connect_process_thread , NULL );
209-
143+ // Get Bluetooth address for use as unique USB serial number.
144+ nx_bt_init ();
145+ nx_bt_set_friendly_name ("Pybricks NXT" );
146+ uint8_t local_addr [7 ];
147+ if (nx_bt_get_local_addr (local_addr )) {
148+ snprintf (bluetooth_address_string , sizeof (bluetooth_address_string ),
149+ "%02X:%02X:%02X:%02X:%02X:%02X" ,
150+ local_addr [0 ], local_addr [1 ], local_addr [2 ],
151+ local_addr [3 ], local_addr [4 ], local_addr [5 ]);
152+ }
153+ nx_display_string (bluetooth_address_string );
154+ nx_display_string ("\n" );
210155}
0 commit comments