Skip to content

Commit

Permalink
Merge pull request #403 from LedgerHQ/ble_local_buf
Browse files Browse the repository at this point in the history
[BLE] enable use of local APDU buffer
  • Loading branch information
yhql authored Sep 20, 2023
2 parents 96be290 + 2a8c8c6 commit c8363b3
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 80 deletions.
2 changes: 2 additions & 0 deletions Makefile.defines
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ DEFINES += HAVE_BAGL_FONT_INTER_REGULAR_24PX
DEFINES += HAVE_BAGL_FONT_INTER_SEMIBOLD_24PX
DEFINES += HAVE_BAGL_FONT_INTER_MEDIUM_32PX
DEFINES += HAVE_BAGL_FONT_HMALPHAMONO_MEDIUM_32PX
DEFINES += HAVE_INAPP_BLE_PAIRING
DEFINES += HAVE_NBGL
DEFINES += HAVE_PIEZO_SOUND
DEFINES += HAVE_SE_TOUCH
Expand Down Expand Up @@ -212,6 +213,7 @@ DEFINES += HAVE_MCU_SERIAL_STORAGE
DEFINES += HAVE_FONTS
# already defined within apps
# DEFINES += HAVE_BLE
DEFINES += HAVE_INAPP_BLE_PAIRING
DEFINES += HAVE_BATTERY
endif

Expand Down
9 changes: 6 additions & 3 deletions include/ledger_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ enum {

/* Exported types, structures, unions ----------------------------------------*/
typedef struct ledger_protocol_s {
uint8_t *tx_apdu_buffer;
const uint8_t *tx_apdu_buffer;

uint16_t tx_apdu_length;
uint16_t tx_apdu_sequence_number;
uint16_t tx_apdu_offset;
Expand All @@ -45,6 +46,8 @@ typedef struct ledger_protocol_s {
uint16_t rx_apdu_length;
uint16_t rx_apdu_offset;

uint8_t *rx_dst_buffer;

uint16_t mtu;
uint8_t mtu_negotiated;
} ledger_protocol_t;
Expand All @@ -57,5 +60,5 @@ typedef struct ledger_protocol_s {

/* Exported functions prototypes--------------------------------------------- */
void LEDGER_PROTOCOL_init(ledger_protocol_t *data);
void LEDGER_PROTOCOL_rx(uint8_t *buffer, uint16_t length);
void LEDGER_PROTOCOL_tx(uint8_t *buffer, uint16_t length);
void LEDGER_PROTOCOL_rx(const uint8_t *buffer, uint16_t length);
void LEDGER_PROTOCOL_tx(const uint8_t *buffer, uint16_t length);
5 changes: 3 additions & 2 deletions lib_blewbxx_impl/include/ledger_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@

/* Exported functions prototypes--------------------------------------------- */
void LEDGER_BLE_init(void);
void LEDGER_BLE_send(uint8_t *packet, uint16_t packet_length);
void LEDGER_BLE_receive(void);
void LEDGER_BLE_send(const uint8_t *packet, uint16_t packet_length);
void LEDGER_BLE_receive(const uint8_t *spi_buffer);
void LEDGER_BLE_set_recv_buffer(uint8_t *buffer, uint16_t buffer_length);
void LEDGER_BLE_enable_advertising(uint8_t enable);
void LEDGER_BLE_reset_pairings(void);
void LEDGER_BLE_accept_pairing(uint8_t status);
Expand Down
Loading

0 comments on commit c8363b3

Please sign in to comment.