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

Add support for chipsea / OKOK 2.0 scales #706

Merged
merged 2 commits into from Mar 9, 2021
Merged

Conversation

inzanity
Copy link
Contributor

@inzanity inzanity commented Mar 3, 2021

For now only handles weight, impedance is read, but not used for
anything, algorithms not known.

The scale does not indicate whether it is sending the weight in kg or in
lbs, always assuming kg.

Based on findings from #496

For now only handles weight, impedance is read, but not used for
anything, algorithms not known.

The scale does not indicate whether it is sending the weight in kg or in
lbs, always assuming kg.
@oliexdev
Copy link
Owner

oliexdev commented Mar 4, 2021

thanks for your work but could rewrite your code that you don't overwrite connect/disconnect and onDiscoveredPeripheral. You can put the logic in onNextStep and onBluetoothNotify

@inzanity
Copy link
Contributor Author

inzanity commented Mar 4, 2021

I didn't figure out a way to get the advertisement data any other way, am I missing something?

@oliexdev
Copy link
Owner

oliexdev commented Mar 4, 2021

You need to turn on the notification in onNextStep with:

        switch (stepNr) {
            case 0:
                //Tell device to send us weight measurements
                setNotificationOn(WEIGHT_MEASUREMENT_SERVICE, WEIGHT_MEASUREMENT_SERVICE);
                break;
         }

Then you will receive any weight advertisement in onBluetoothNotify.

The WEIGHT_MEASUREMENT_SERVICE and WEIGHT_MEASUREMENT_SERVICE could be different but the default values are:

    private final UUID WEIGHT_MEASUREMENT_SERVICE = BluetoothGattUuid.fromShortCode(0xfff0);
    private final UUID WEIGHT_MEASUREMENT_CHARACTERISTIC = BluetoothGattUuid.fromShortCode(0xfff1);

@inzanity
Copy link
Contributor Author

inzanity commented Mar 4, 2021

The device is a pure broadcaster and does not advertise any GATT services (nor characteristics). All the data is simply in a manufacturer specific data field in the advertisement.

The fields present in the advertisement are:

  • 02 01 04: flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED
  • 04 09 04 09 41 44 56: name = ADV
  • 16 ff ... = 23 bytes of manufacturer specific data

As far as I understand, this data would only be received in the onDiscoveredPeripheral() callback in BluetoothCommunication.java which throws the ScanResult object away and stops receiving updates after the first received package (which contains only the very first measurement, likely quite close to zero).

Still, this is the only way I've perceived this kind of broadcaster-listener can be implemented without altering BluetoothCommunication.

@oliexdev
Copy link
Owner

oliexdev commented Mar 4, 2021

that would be really strange, could you do step 2 from https://github.com/oliexdev/openScale/wiki/How-to-reverse-engineer-a-Bluetooth-4.x-scale and post the results here?

@inzanity
Copy link
Contributor Author

inzanity commented Mar 4, 2021

openScale_2021-03-04_09-57.txt

When I click on the scale, it pops up a never ending spinner.

@oliexdev
Copy link
Owner

oliexdev commented Mar 4, 2021

you are using an old version of openScale?

But if its not work please use the BLE scanner app.

@inzanity
Copy link
Contributor Author

inzanity commented Mar 4, 2021

blescanner

This is all that I got with BLE Scanner, which says the same, not connectable and 3 fields in the advertisement.

@oliexdev
Copy link
Owner

oliexdev commented Mar 9, 2021

ok that would be the first scale without an Bluetooth service but if its works I will merge it. Do you have maybe a photo of the scale for out gallery (same camera angle like the other ones)? I can't use the official one due copyright reasons.

And thanks for your work. 🥇

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.

None yet

2 participants