advertising - testing options

tychovrahe/T3W1/devkit1_with_ble_sq3
tychovrahe 11 months ago
parent 3b6c30a23f
commit 6ef00f51be

@ -25,7 +25,7 @@ PRODUCTION ?= 0
PYOPT ?= 1
BITCOIN_ONLY ?= 0
BOOTLOADER_QA ?= 0
TREZOR_MODEL ?= T
TREZOR_MODEL ?= T3W1
TREZOR_MEMPERF ?= 0
ADDRESS_SANITIZER ?= 0
CMAKELISTS ?= 0

@ -176,7 +176,7 @@ void process_command(uint8_t *data, uint16_t len) {
send_status_event();
break;
case INTERNAL_CMD_ADVERTISING_ON:
advertising_start(true);
advertising_start(data[1] != 0);
send_status_event();
break;
case INTERNAL_CMD_ADVERTISING_OFF:

@ -154,7 +154,7 @@ int main(void) {
#ifdef USE_BLE
dfu_init();
ble_comm_init();
start_advertising();
start_advertising(true);
#endif
#if !defined TREZOR_MODEL_1

@ -341,6 +341,7 @@ fn generate_trezorhal_bindings() {
.no_copy("buffer_blurring_t")
// ble
.allowlist_function("ble_connected")
.allowlist_function("start_advertising")
//usb
.allowlist_function("usb_configured")
// touch

@ -3,3 +3,7 @@ use super::ffi;
pub fn ble_connected() -> bool {
unsafe { ffi::ble_connected() }
}
pub fn start_advertising(whitelist: bool) {
unsafe { ffi::start_advertising(whitelist) }
}

@ -2,7 +2,7 @@ mod render;
use crate::{
time::{Duration, Instant},
trezorhal::{ble::ble_connected, usb::usb_configured},
trezorhal::{ble::ble_connected, ble::start_advertising, usb::usb_configured},
ui::{
component::{Component, Event, EventCtx, Pad, TimerToken},
display::{self, tjpgd::jpeg_info, toif::Icon, Color, Font},
@ -195,7 +195,9 @@ where
}
if let Event::Button(ButtonEvent::ButtonPressed(PhysicalButton::Power)) = event {
Some(HomescreenMsg::Dismissed)
start_advertising(false);
None
//Some(HomescreenMsg::Dismissed)
} else {
None
}

@ -10,9 +10,11 @@ void send_state_request(void) {
ble_int_comm_send(&cmd, sizeof(cmd), INTERNAL_EVENT);
}
void send_advertising_on(void) {
uint8_t cmd = INTERNAL_CMD_ADVERTISING_ON;
ble_int_comm_send(&cmd, sizeof(cmd), INTERNAL_EVENT);
void send_advertising_on(bool whitelist) {
uint8_t data[2];
data[0] = INTERNAL_CMD_ADVERTISING_ON;
data[1] = whitelist ? 1 : 0;
ble_int_comm_send(data, sizeof(data), INTERNAL_EVENT);
}
void send_advertising_off(void) {

@ -1,9 +1,11 @@
#ifndef __BLE_MESSAGES__
#define __BLE_MESSAGES__
#include <stdbool.h>
void send_state_request(void);
void send_advertising_on(void);
void send_advertising_on(bool whitelist);
void send_advertising_off(void);

@ -7,6 +7,7 @@
static bool ble_state_connected = false;
static bool ble_state_initialized = false;
static bool ble_advertising_wanted = false;
static bool ble_advertising_wh_wanted = false;
static bool ble_advertising = false;
bool ble_connected(void) {
@ -18,7 +19,7 @@ void set_connected(bool connected) { ble_state_connected = connected; }
void set_advertising(bool advertising) {
if (ble_advertising_wanted != advertising) {
if (ble_advertising_wanted) {
send_advertising_on();
send_advertising_on(ble_advertising_wh_wanted);
} else {
send_advertising_off();
}
@ -32,11 +33,12 @@ bool ble_initialized(void) {
return ble_state_initialized && ble_firmware_running();
}
void start_advertising(void) {
void start_advertising(bool whitelist) {
ble_advertising_wh_wanted = whitelist;
ble_advertising_wanted = true;
if (!ble_advertising) {
send_advertising_on();
}
//if (!ble_advertising) {
send_advertising_on(whitelist);
//}
}
void stop_advertising(void) {

@ -15,7 +15,7 @@ void set_advertising(bool advertising);
void set_connected(bool connected);
void start_advertising(void);
void start_advertising(bool whitelist);
void stop_advertising(void);

@ -2,7 +2,6 @@
#define _ST7789V_H
#include STM32_HAL_H
#include TREZOR_BOARD
typedef struct {
uint16_t x;

Loading…
Cancel
Save