Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sd auto detect for insert and remove #1270

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

asi345
Copy link
Collaborator

@asi345 asi345 commented Aug 14, 2024

Check commit messages for detailed explanation.

Let me know if you have a better suggestion for polling interval. You can test and let me know if it takes too long.

@asi345 asi345 requested a review from benma August 14, 2024 13:50
@asi345 asi345 self-assigned this Aug 14, 2024
#include <touch/gestures.h>
#include <ui/screen_stack.h>

// TODO: use a TIMER interrupt to get a more accurate timer.
// 250 is ~0.5 sec. Unit: rendering rate.
#define ACTIVE_AFTER 250
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACTIVE_AFTER is a bit misnamed., it's more like CHECK_INTERVAL?

// 250 is ~0.5 sec. Unit: rendering rate.
#define ACTIVE_AFTER 250

static int _count = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to the data_t struct to avoid globals and so it is initialized to 0 when the component is created.

static void _continue_callback(component_t* component)
{
data_t* data = (data_t*)component->parent->data;
if (!data->insert || sd_card_inserted()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For removing the card, the continue button served to exit the workflow without an error. You changed it to show a cancel button only, which errors with UserAbort when pressed, which is a breaking change.

Please leave the semantics as it was - leave the continue button/callback and hide the cancel button/callback for removal. Otherwise we have to worry about how it will behave in the app 😅

@asi345 asi345 force-pushed the sd-auto-detect branch 2 times, most recently from 0621b40 to 0e7f3b8 Compare August 21, 2024 15:14
Copy link
Collaborator

@benma benma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the main change, works very nicely!

Some small nits left.

@@ -648,16 +648,6 @@ def insert_sdcard(self) -> None:
)
self._msg_query(request, expected_response="success")

def remove_sdcard(self) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies a major version bump of the bitbox02 Python library (7.0.0 => 8.0.0) and a CHANGELOG entry to py/bitbox02/CHANGELOG.md

Comment on lines 37 to 38
if (sd_card_inserted()) {
if (data->callback) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(data->callback && sd_card_inserted()) ? not sure if sd_card_inserted() is cheap or expensive, but if expensive, it's better to call it only when needed.

CHANGELOG.md Outdated
@@ -16,6 +16,8 @@ customers cannot upgrade their bootloader, its changes are recorded separately.
- Ethereum: allow signing EIP-712 messages containing multi-line strings
- Allow exiting the screen asking to insert the microSD card
- HWW: add initialized status byte to _api_info response
- SD card: delete remove sd card api
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confusing wording, maybe better like "Remove API to prompt removal of the microSD card"

It seems that big share of the sd card support tickets are customers not clicking the upper right corner after inserting their sd card.
That's why auto-detection of sd card in the device is critical.

With this commit, when 'insert sd card' option is called from api,
BitBox02 device will start listening its sd card port and automatically
recognize if an sd card is inserted.

Furthermore, we noticed that 'remove sd card' feature is not used in any
of our libraries. That's why we removed it from api and Python library.

Signed-off-by: asi345 <inanata15@gmail.com>
@@ -2,6 +2,9 @@

## [Unreleased]

# 8.0.0
Copy link
Collaborator

@benma benma Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also bump the actual package version please:

So far we usually bump versions as needed in each PR that makes a change, but keep the changelog in "UNRELEASED" until shortly before an actual release. This is not ideal I guess as it needs another commit to fix the changelog before a release. Maybe we can revisit how we do this for all our repos consistently at some point (cc @NickeZ).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can take a look at best practices. I think there also are some changelog tooling, maybe that helps.

@benma benma merged commit e8285f8 into BitBoxSwiss:master Sep 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants