Skip to content

Commit f24e846

Browse files
committed
pbio/sys/host: Schedule status update.
This is not yet implemented for the driver side. At the moment, the usb drivers poll the status for partial changes, and the bluetooth status is managed by pbsys/bluetooth, which is to be removed.
1 parent 01ec3b6 commit f24e846

File tree

11 files changed

+60
-4
lines changed

11 files changed

+60
-4
lines changed

lib/pbio/drv/bluetooth/bluetooth_btstack.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,4 +1109,8 @@ void pbdrv_bluetooth_stop_observing(pbio_task_t *task) {
11091109
start_task(task, stop_observing_task, NULL);
11101110
}
11111111

1112+
void pbdrv_bluetooth_schedule_status_update(const uint8_t *status_msg) {
1113+
// todo
1114+
}
1115+
11121116
#endif // PBDRV_CONFIG_BLUETOOTH_BTSTACK

lib/pbio/drv/bluetooth/bluetooth_stm32_bluenrg.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,4 +1556,8 @@ PROCESS_THREAD(pbdrv_bluetooth_spi_process, ev, data) {
15561556
PROCESS_END();
15571557
}
15581558

1559+
void pbdrv_bluetooth_schedule_status_update(const uint8_t *status_msg) {
1560+
// todo
1561+
}
1562+
15591563
#endif // PBDRV_CONFIG_BLUETOOTH_STM32_BLUENRG

lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,4 +2470,8 @@ HCI_StatusCodes_t HCI_sendHCICommand(uint16_t opcode, uint8_t *pData, uint8_t da
24702470
return bleSUCCESS;
24712471
}
24722472

2473+
void pbdrv_bluetooth_schedule_status_update(const uint8_t *status_msg) {
2474+
// todo
2475+
}
2476+
24732477
#endif // PBDRV_CONFIG_BLUETOOTH_STM32_CC2640

lib/pbio/drv/usb/usb_ev3.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,10 @@ static void usb_device_intr(void) {
879879
HWREG(USB_0_OTGBASE + USB_0_END_OF_INTR) = 0;
880880
}
881881

882+
void pbdrv_usb_schedule_status_update(const uint8_t *status_msg) {
883+
// todo
884+
}
885+
882886
static pbio_os_process_t pbdrv_usb_ev3_process;
883887

884888
static pbio_error_t pbdrv_usb_ev3_process_thread(pbio_os_state_t *state, void *context) {

lib/pbio/drv/usb/usb_nxt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,10 @@ bool pbdrv_usb_connection_is_active(void) {
883883
return nx_usb_is_connected();
884884
}
885885

886+
void pbdrv_usb_schedule_status_update(const uint8_t *status_msg) {
887+
// todo
888+
}
889+
886890
void nx_usb_read(uint8_t *data, uint32_t length) {
887891
pbdrv_usb_nxt_state.rx_data = data;
888892
pbdrv_usb_nxt_state.rx_size = length;

lib/pbio/drv/usb/usb_stm32.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ pbdrv_usb_bcd_t pbdrv_usb_get_bcd(void) {
389389
return pbdrv_usb_bcd;
390390
}
391391

392+
void pbdrv_usb_schedule_status_update(const uint8_t *status_msg) {
393+
// todo
394+
}
395+
392396
// Event loop
393397

394398
PROCESS_THREAD(pbdrv_usb_process, ev, data) {

lib/pbio/include/pbdrv/bluetooth.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ bool pbdrv_bluetooth_is_connected(pbdrv_bluetooth_connection_t connection);
276276
*/
277277
void pbdrv_bluetooth_set_on_event(pbdrv_bluetooth_on_event_t on_event);
278278

279+
/**
280+
* Schedules Pybricks status to be sent via a characteristic notification.
281+
*
282+
* The data length is always ::PBIO_PYBRICKS_EVENT_STATUS_REPORT_SIZE.
283+
*/
284+
void pbdrv_bluetooth_schedule_status_update(const uint8_t *status_msg);
285+
279286
/**
280287
* Requests for @p data to be sent via a characteristic notification.
281288
*
@@ -424,6 +431,9 @@ static inline bool pbdrv_bluetooth_is_connected(pbdrv_bluetooth_connection_t con
424431
return false;
425432
}
426433

434+
static inline void pbdrv_bluetooth_schedule_status_update(const uint8_t *status_msg) {
435+
}
436+
427437
static inline void pbdrv_bluetooth_send(pbdrv_bluetooth_send_context_t *context) {
428438
if (context->done) {
429439
context->done();

lib/pbio/include/pbdrv/usb.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ typedef enum {
4040
*/
4141
pbdrv_usb_bcd_t pbdrv_usb_get_bcd(void);
4242

43+
/**
44+
* Schedules Pybricks status to be sent soon.
45+
*
46+
* The data length is always ::PBIO_PYBRICKS_EVENT_STATUS_REPORT_SIZE.
47+
*/
48+
void pbdrv_usb_schedule_status_update(const uint8_t *status_msg);
49+
4350
/**
4451
* Transmits the given buffer over the USB stdout stream.
4552
* @return The result of the operation.
@@ -75,6 +82,9 @@ static inline pbdrv_usb_bcd_t pbdrv_usb_get_bcd(void) {
7582
return PBDRV_USB_BCD_NONE;
7683
}
7784

85+
static inline void pbdrv_usb_schedule_status_update(const uint8_t *status_msg) {
86+
}
87+
7888
static inline pbio_error_t pbdrv_usb_stdout_tx(const uint8_t *data, uint32_t *size) {
7989
return PBIO_SUCCESS;
8090
}

lib/pbio/include/pbsys/host.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef bool (*pbsys_host_stdin_event_callback_t)(uint8_t c);
2727

2828
void pbsys_host_init(void);
2929
bool pbsys_host_is_connected(void);
30+
void pbsys_host_schedule_status_update(const uint8_t *buf);
3031
uint32_t pbsys_host_stdin_get_free(void);
3132
void pbsys_host_stdin_write(const uint8_t *data, uint32_t size);
3233
void pbsys_host_stdin_set_callback(pbsys_host_stdin_event_callback_t callback);
@@ -40,6 +41,7 @@ bool pbsys_host_tx_is_idle(void);
4041

4142
#define pbsys_host_init()
4243
#define pbsys_host_is_connected() false
44+
#define pbsys_host_schedule_status_update(buf)
4345
#define pbsys_host_stdin_get_free() 0
4446
#define pbsys_host_stdin_write(data, size) { (void)(data); (void)(size); }
4547
#define pbsys_host_stdin_set_callback(callback) { (void)(callback); }

lib/pbio/sys/host.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ void pbsys_host_init(void) {
2222
pbsys_bluetooth_init();
2323
}
2424

25+
/**
26+
* Schedules sending a status update to connected hosts.
27+
*
28+
* The data length is always ::PBIO_PYBRICKS_EVENT_STATUS_REPORT_SIZE.
29+
*/
30+
void pbsys_host_schedule_status_update(const uint8_t *buf) {
31+
pbdrv_bluetooth_schedule_status_update(buf);
32+
pbdrv_usb_schedule_status_update(buf);
33+
}
34+
2535
/**
2636
* Tests if the hub is connected to the host with BLE or USB.
2737
*

0 commit comments

Comments
 (0)