Skip to content

Commit 7c4c4ac

Browse files
committed
Disable messaging on primehub.
Currently we have made rfcomm connections dependent on umm_malloc, which primehub currently does not have. As such, we need to disable messaging since it depends on rfcomm.
1 parent 40aa072 commit 7c4c4ac

2 files changed

Lines changed: 32 additions & 21 deletions

File tree

bricks/primehub/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#define PYBRICKS_PY_IODEVICES_UART_DEVICE (1)
4242
#define PYBRICKS_PY_IODEVICES_XBOX_CONTROLLER (1)
4343
#define PYBRICKS_PY_MEDIA_IMAGE (0)
44-
#define PYBRICKS_PY_MESSAGING (1)
44+
#define PYBRICKS_PY_MESSAGING (0)
4545
#define PYBRICKS_PY_MESSAGING_RFCOMM (0)
4646
#define PYBRICKS_PY_NXTDEVICES (0)
4747
#define PYBRICKS_PY_PARAMETERS (1)

lib/pbio/drv/bluetooth/bluetooth_btstack.c

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <pbsys/storage.h>
2929
#include <pbsys/storage_settings.h>
3030

31-
#if HAVE_UMM_MALLOC
31+
#if MAX_NR_RFCOMM_CHANNELS > 0
3232
#include <umm_malloc.h>
3333
#endif
3434

@@ -1197,7 +1197,8 @@ pbio_error_t pbdrv_bluetooth_stop_observing_func(pbio_os_state_t *state, void *c
11971197
PBIO_OS_ASYNC_END(PBIO_SUCCESS);
11981198
}
11991199

1200-
#ifdef PBSYS_CONFIG_BLUETOOTH_CLASSIC_LINK_KEY_DB_SIZE
1200+
#if MAX_NR_RFCOMM_CHANNELS > 0
1201+
12011202
static int link_db_entry_size() {
12021203
return sizeof(bd_addr_t) + sizeof(link_key_t) + sizeof(link_key_type_t);
12031204
}
@@ -1316,19 +1317,13 @@ static void link_db_settings_load_once(void) {
13161317
DEBUG_PRINT("Loaded %u link keys from settings\n", count);
13171318
}
13181319

1319-
#endif
1320-
13211320
// Returns true if the given address is already paired in our link database.
13221321
bool is_already_paired(bd_addr_t addr) {
13231322
link_key_t key;
13241323
link_key_type_t type;
13251324
return gap_get_link_key_for_bd_addr(addr, key, &type);
13261325
}
13271326

1328-
#ifndef MAX_NR_RFCOMM_CHANNELS
1329-
#define MAX_NR_RFCOMM_CHANNELS 0
1330-
#endif
1331-
13321327
#define RFCOMM_SOCKET_COUNT (MAX_NR_RFCOMM_CHANNELS > 0 ? MAX_NR_RFCOMM_CHANNELS - 1 : 0)
13331328
#if HAVE_UMM_MALLOC
13341329
#define RFCOMM_RX_BUFFER_SIZE (4 * 1024)
@@ -1769,18 +1764,6 @@ void pbdrv_bluetooth_classic_init() {
17691764
rfcomm_register_service_with_initial_credits(&user_rfcomm_packet_handler, 1, 1024, 0);
17701765
}
17711766

1772-
void pbdrv_bluetooth_local_address(bdaddr_t addr) {
1773-
gap_local_bd_addr(addr);
1774-
}
1775-
1776-
const char *pbdrv_bluetooth_bdaddr_to_str(const bdaddr_t addr) {
1777-
return bd_addr_to_str(addr);
1778-
}
1779-
1780-
bool pbdrv_bluetooth_str_to_bdaddr(const char *str, bdaddr_t addr) {
1781-
return sscanf_bd_addr(str, addr) == 1;
1782-
}
1783-
17841767
// Returns whether this socket is in a state where we should abandon
17851768
// our connection attempt, either listening or connecting.
17861769
static bool should_abandon_connection(pbdrv_bluetooth_rfcomm_socket_t *sock) {
@@ -2081,6 +2064,34 @@ void pbdrv_bluetooth_rfcomm_disconnect_all() {
20812064
pending_listen_socket = NULL;
20822065
}
20832066

2067+
#else
2068+
2069+
void pbdrv_bluetooth_classic_init() {
2070+
}
2071+
2072+
static inline void maybe_handle_classic_security_packet(uint8_t *packet, uint16_t size) {
2073+
}
2074+
2075+
static inline void link_db_settings_load_once(void) {
2076+
}
2077+
2078+
void pbdrv_bluetooth_rfcomm_disconnect_all() {
2079+
}
2080+
2081+
#endif // BLUETOOTH_CLASSIC
2082+
2083+
void pbdrv_bluetooth_local_address(bdaddr_t addr) {
2084+
gap_local_bd_addr(addr);
2085+
}
2086+
2087+
const char *pbdrv_bluetooth_bdaddr_to_str(const bdaddr_t addr) {
2088+
return bd_addr_to_str(addr);
2089+
}
2090+
2091+
bool pbdrv_bluetooth_str_to_bdaddr(const char *str, bdaddr_t addr) {
2092+
return sscanf_bd_addr(str, addr) == 1;
2093+
}
2094+
20842095
static void pbdrv_bluetooth_inquiry_unpack_scan_event(uint8_t *event_packet, pbdrv_bluetooth_inquiry_result_t *result) {
20852096

20862097
gap_event_inquiry_result_get_bd_addr(event_packet, result->bdaddr);

0 commit comments

Comments
 (0)