1010#include <stdio.h>
1111#include <stdlib.h>
1212#include <unistd.h>
13- #include <arpa/inet.h>
1413
1514#include "bluetooth.h"
1615#include <pbdrv/bluetooth.h>
@@ -51,10 +50,6 @@ bool pbdrv_bluetooth_is_connected(pbdrv_bluetooth_connection_t connection) {
5150 return false;
5251}
5352
54- // Socket used to send data to Python animation.
55- static int data_socket = -1 ;
56- static struct sockaddr_in serv_addr ;
57-
5853pbio_error_t pbdrv_bluetooth_send_pybricks_value_notification (pbio_os_state_t * state , const uint8_t * data , uint16_t size ) {
5954 PBIO_OS_ASYNC_BEGIN (state );
6055
@@ -64,18 +59,8 @@ pbio_error_t pbdrv_bluetooth_send_pybricks_value_notification(pbio_os_state_t *s
6459 (void )ret ;
6560 }
6661
67- // No output configured, so done.
68- if (data_socket < 0 ) {
69- return PBIO_SUCCESS ;
70- }
71-
72- // Send the value notification via socket.
73- ssize_t sent = sendto (data_socket , data , size , 0 , (struct sockaddr * )& serv_addr , sizeof (serv_addr ));
74- if (sent < 0 ) {
75- printf ("send() failed" );
76- close (data_socket );
77- data_socket = -1 ;
78- }
62+ extern void virtual_hub_socket_send (const uint8_t * data , uint32_t size );
63+ virtual_hub_socket_send (data , size );
7964
8065 PBIO_OS_ASYNC_END (PBIO_SUCCESS );
8166}
@@ -195,24 +180,6 @@ void pbdrv_bluetooth_init_hci(void) {
195180 bluetooth_thread_err = PBIO_ERROR_AGAIN ;
196181 bluetooth_thread_state = 0 ;
197182 pbio_os_process_start (& pbdrv_bluetooth_simulation_process , pbdrv_bluetooth_simulation_process_thread , NULL );
198-
199- // Configure socket if specified.
200- if (getenv ("PBIO_TEST_CONNECT_SOCKET" )) {
201- data_socket = socket (AF_INET , SOCK_DGRAM , 0 );
202- if (data_socket < 0 ) {
203- printf ("socket() failed" );
204- return ;
205- }
206- serv_addr .sin_family = AF_INET ;
207- serv_addr .sin_port = htons (5002 );
208- if (inet_pton (AF_INET , "127.0.0.1" , & serv_addr .sin_addr ) <= 0 ) {
209- printf ("inet_pton() failed" );
210- close (data_socket );
211- data_socket = -1 ;
212- return ;
213- }
214- }
215-
216183}
217184
218185#endif // PBDRV_CONFIG_BLUETOOTH_SIMULATION
0 commit comments