50ButtonsEach / fliclib-android

Creative Commons Zero v1.0 Universal
33 stars 22 forks source link

Grabbing button fails: proofs are not equal #21

Open xylo opened 7 years ago

xylo commented 7 years ago

I've written a small app using flic and it always worked fine with 2 buttons (white and green). After some months I bought a third button (black) and wanted to integrate it in my app, too. After some trouble activating the third button it finally worked, but for some reason flic seems to have a problem with my white button now, but only when I want to grab it from my app. In the flic app itself all buttons work perfectly.

My app code is based on the flic android tutorial project. I'm calling

FlicManager.getInstance(this, new FlicManagerInitializedCallback() {
    @OverrideButton grabbed
    public void onInitialized(FlicManager manager) {
        manager.initiateGrabButton(MainActivity.this);
    }
});

to grab the buttons and get the result via

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    FlicManager.getInstance(this, new FlicManagerInitializedCallback() {
        @Override
        public void onInitialized(FlicManager manager) {
            FlicButton button = manager.completeGrabButton(requestCode, resultCode, data);
            if (button != null) {
                button.registerListenForBroadcast(FlicBroadcastReceiverFlags.UP_OR_DOWN | FlicBroadcastReceiverFlags.REMOVED);
                Toast.makeText(MainActivity.this, "Button grabbed", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MainActivity.this, "Could not grab the button " + resultCode, Toast.LENGTH_SHORT).show();
            }
        }
    });
}

In the flic app I don't see any differences between the 3 buttons. Only the colors and names are different. But they are all connected and all working in the flic app. Also when I call manager.initiateGrabButton(...) from my app I get to a view that shows me that all 3 buttons are conencted to the device. But now comes the strange thing. When I tap on the green or the black button they get successfully grabbed in my app, but when I tap on the white onActivityResult is called with a resultCode of -1 and manager.completeGrabButton returns null instead of a FlicButton.

I already removed the white button from my flic account and added it again but the behaviour is still the same.

Emill commented 7 years ago

What does the lib print in logcat, while the completeGrabButton runs? Or could you debug-step through that function and see where it returns null?

xylo commented 7 years ago

OK, indeed the FlicManager logs the message "completeGrabButton: proofs are not equal" and it returns null as FlicButton. What does that mean?

Emill commented 7 years ago

Hmm. Could you please post the full Intent extra datas for the request and the response and I can take a look at it on Monday?

xylo commented 7 years ago

The intent extra data created by FlicMmanager.createIntentForInitiateGrabButton:

Bundle[{intfId=6925418392491339772, appId=f4a52191-b830-4416-99ab-c3d324ee7436, token=[B@d1be484, appSecret= 4768e481-c3ef-4fd0-b3df-aaaf1d149e0d}]

token:

[85, 104, 6, 90, -68, -52, -82, -118, -39, 109, 55, -90, 3, 86, 40, 107, -16, 56, 53, 21, 57, -104, 53, -105, 108, 43, -102, 59, -72, 107, -31, 27]

The Intent extra data passed to onActivityResult:

Bundle[{button_uuid=45e6f54167f2363a1b3d94d35ac866b0, connection_parameters=, press_ounter=920, pubkey=[B@60ca623, press_counter_diff=0, h1=2744A65396BAAF96, mac=80:E4:DA:71:FE:2E, name=F022cf4u, color=white, proof=[B@139720, serial_number=AF25-B07219, saved_connection_state=0, pubkey_signature=[B@32348d9, boot_counter=2, last_values=5}]

The Intent extra data passed to FlicManager.completeGrabButton:

Bundle[{button_uuid=45e6f54167f2363a1b3d94d35ac866b0, connection_parameters=, press_ounter=920, pubkey=[B@da51db2, press_counter_diff=0, h1=2744A65396BAAF96, mac=80:E4:DA:71:FE:2E, name=F022cf4u, color=white, proof=[B@8061103, serial_number=AF25-B07219, saved_connection_state=0, pubkey_signature=[B@f165880, boot_counter=2, last_values=5}]

pubkey:

[76, -61, -102, 72, 37, 36, -70, -27, -112, 81, 9, -64, 7, -35, -71, -62, -89, -9, 2, -89, -59, 28, 43, -117, 69, 104, -30, -16, 55, 9, -97, 35]

proof:

[104, 122, -83, -8, 98, -67, 119, 108, -113, -63, -117, -114, -97]

pubkey_signature:

[-120, 14, -66, 49, -15, -69, 126, -40, 39, 19, -74, -55, 32, 48, -36, 50, -51, -23, -106, 123, 66, -98, 111, -98, -85, 16, 6, -13, -91, -90, -16, -62, 63, 64, 114, 93, 76, 86, -22, 113, -39, -43, 24, 122, 126, -10, 3, -82, -59, 85, -108, -9, 45, -92, 74, 111, 76, -77, 71, -53, -114, 71, 84, 51, 70, 122, -28, 28, -114, -50, 69, -75, 31, -120, -80, 32, -88, 96, -53, -52, 70, 89, -117, 83, 112, 88, -82, 114, -75, 117, 112, -103, -1, -120, 93, 115, -124, -52, -54, -23, 114, 78, -120, 56, -128, 35, 74, 51, -14, 22, 124, -23, 74, -62, -90, -12, 38, 65, 3, -14, 32, 5, 69, 58, -26, -56, -40, -92, 103, 105, 87, 77, 85, 77, -36, -12, -108, -29, -120, 95, 39, 111, 120, 39, 37, 75, 32, 87, 122, 41, 55, -32, -102, -28, -90, 112, 86, -37, -50, 95, -21, -114, -121, 102, -124, -86, 75, -11, 97, 17, -111, -52, 74, -48, -76, 44, 108, -114, -119, -111, -49, -92, -80, 108, 105, 65, -44, -61, -105, 13, 99, -8, -104, 82, -59, -114, -86, 73, 46, 28, 109, -31, 34, 20, -58, 82, 65, -84, -8, -50, 107, 35, -18, 36, 88, -41, 26, 112, 0, -88, -80, -30, 75, -91, -28, 61, 40, 73, -125, -94, 53, 54, -74, 32, 51, 66, 12, -83, 127, -47, 52, 28, -62, -2, 22, -124, 0, -17, -95, -16, -48, -111, 107, -108, -115, -25]

Emill commented 7 years ago

Yes please

xylo commented 7 years ago

OK, I added the arrays in my previous post. Thanks for looking into this.

andrblum commented 3 years ago

Hello, does someone found the cause/an explanation for this error?

andrblum commented 3 years ago

I could resolve this problem by simply replacing the battery