19
19
#include <hal_timer.h>
20
20
#include <platform/driver_init.h>
21
21
#endif
22
+ #include <da14531/da14531.h>
23
+ #include <da14531/da14531_handler.h>
22
24
#include <hww.h>
25
+ #include <memory/memory_shared.h>
23
26
#include <screen.h>
24
27
#include <ui/components/lockscreen.h>
25
28
#include <ui/components/orientation_arrows.h>
26
29
#include <ui/screen_stack.h>
27
30
#include <usb/usb.h>
31
+ #include <utils_ringbuffer.h>
32
+ #include <version.h>
33
+
34
+ #if APP_U2F
35
+ #include <u2f.h>
36
+ #endif
28
37
29
38
#ifndef TESTING
30
39
#define IDLE_PERIOD_MS 1300
31
40
41
+ // Currently we have one firmware for both BB02 and BB02_PLUS, and only the
42
+ // PRODUCT_BITBOX_MULTI/BTCONLY definitions apply. The PRODUCT_BITBOX_PLUS_MULTI/BTCONLY defs
43
+ // currently only apply in the bootloader, which we don't need here.
44
+ #if PRODUCT_BITBOX_MULTI == 1
45
+ #define PRODUCT_STRING_SUFFIX "multi"
46
+ #elif PRODUCT_BITBOX_BTCONLY == 1
47
+ #define PRODUCT_STRING_SUFFIX "btconly"
48
+ #elif PRODUCT_BITBOX02_FACTORYSETUP == 1
49
+ // Dummy, not actually needed, but this file is currently needlessly compiled for factorysetup.
50
+ #define PRODUCT_STRING_SUFFIX "factory"
51
+ #else
52
+ #error "unknown edition"
53
+ #endif
54
+
55
+ #define DEVICE_MODE \
56
+ "{\"p\":\"bb02p-" PRODUCT_STRING_SUFFIX "\",\"v\":\"" DIGITAL_BITBOX_VERSION "\"}"
57
+
32
58
static struct timer_task _idle_timer_task = {0 };
33
59
60
+ struct select_orientation_data {
61
+ struct ringbuffer * uart_out_queue ;
62
+ };
63
+
64
+ static struct select_orientation_data _data = {0 };
65
+
34
66
static void _idle_timer_cb (const struct timer_task * const timer_task )
35
67
{
36
68
(void )timer_task ;
37
- usb_start (hww_setup );
69
+
70
+ // Setup usb_processing handlers
71
+ hww_setup ();
72
+ #if APP_U2F
73
+ u2f_device_setup ();
74
+ #endif
75
+
76
+ // hww handler in usb_process must be setup before we can allow ble connections
77
+ if (memory_get_platform () == MEMORY_PLATFORM_BITBOX02_PLUS ) {
78
+ da14531_handler_current_product = (const uint8_t * )DEVICE_MODE ;
79
+ da14531_handler_current_product_len = sizeof (DEVICE_MODE ) - 1 ;
80
+ da14531_set_product (
81
+ da14531_handler_current_product ,
82
+ da14531_handler_current_product_len ,
83
+ _data .uart_out_queue );
84
+ }
85
+
86
+ usb_start ();
38
87
ui_screen_stack_push (lockscreen_create ());
39
88
}
40
89
#endif
@@ -57,7 +106,10 @@ static void _select_orientation_done(bool upside_down, void* cb_param)
57
106
#endif
58
107
}
59
108
60
- void orientation_screen (void )
109
+ void orientation_screen (struct ringbuffer * uart_out_queue )
61
110
{
111
+ #ifndef TESTING
112
+ _data .uart_out_queue = uart_out_queue ;
113
+ #endif
62
114
ui_screen_stack_push (orientation_arrows_create (_select_orientation_done , NULL ));
63
115
}
0 commit comments