-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
ReOpen PR Support for nameless OKOK scales (Myria MY4836) #1088
Conversation
So I've been investigating the Bluetooth payload... We could possibly use the manufacturer details or even look for a weight value and only display devices which respond with that data. Would need to change the code which scans for new devices and might make pairing a little janky |
thanks @TRex22 best think would be to have some manufactur id for filtering |
So Im not 100% that all scales have that ID set. I believe the one I have is empty 🤦🏻 |
That will only help more experience users as normally you don't know the Bluetooth address of the scale. |
The filtering logic is known, it just needs to be integrated with BluetoothSettingsFragment: openScale/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothOKOK2.java Lines 165 to 169 in 29dd632
openScale/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothOKOK2.java Lines 74 to 99 in 29dd632
|
I created a new branch https://github.com/oliexdev/openScale/tree/MY4836 (sorry don't know how to pushed it into this PR) with a potential solution. I would be happy if somebody could test it as I don't own this kind of nameless scale. The basic idea is to give a nameless scale a fake name which can be used later for identification, see the commit c17fff3. |
int vendorIndex = -1; | ||
for (int i = 0; i < manufacturerSpecificData.size(); i++) { | ||
int vendorId = manufacturerSpecificData.keyAt(i); | ||
if ((vendorId & 0xff) == 0xc0) { // 0x00c0-->0xffc0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the 0xc0 the identifier for the scale?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ID is 0x??c0 (0x00c0, 0x01c0, 0x02c0.... ) where the MSB is used to notify the progress, it starts from 0 and increases until the measurement is stable
I had to do some changes to work:
diff --git a/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java
index 7bea7c1c..214ba506 100644
--- a/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java
+++ b/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java
@@ -322,14 +322,19 @@ public class BluetoothSettingsFragment extends Fragment {
return;
}
- BluetoothDeviceView deviceView = new BluetoothDeviceView(context);
- deviceView.setDeviceName(formatDeviceName(bleScanResult.getDevice()));
-
String deviceName = device.getName();
if (deviceName == null) {
deviceName = BluetoothFactory.convertNoNameToDeviceName(bleScanResult.getScanRecord().getManufacturerSpecificData());
+ }
+ if (deviceName == null) {
+ return;
}
+ BluetoothDeviceView deviceView = new BluetoothDeviceView(context);
+ deviceView.setDeviceName(formatDeviceName(deviceName, device.getAddress()));
+ deviceView.setAlias(deviceName);
+
BluetoothCommunication btDevice = BluetoothFactory.createDeviceDriver(context, deviceName);
if (btDevice != null) {
Timber.d("Found supported device %s (driver: %s)",
@@ -398,6 +403,7 @@ public class BluetoothSettingsFragment extends Fragment {
private TextView deviceName;
private ImageView deviceIcon;
private String deviceAddress;
+ private String deviceAlias;
public BluetoothDeviceView(Context context) {
super(context);
@@ -439,6 +445,14 @@ public class BluetoothSettingsFragment extends Fragment {
deviceName.setText(name);
}
+ public void setAlias(String alias) {
+ deviceAlias = alias;
+ }
+
+ public String getAlias() {
+ return deviceAlias;
+ }
+
public void setSummaryText(String text) {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(new String());
@@ -485,10 +499,10 @@ public class BluetoothSettingsFragment extends Fragment {
prefs.edit()
.putString(PREFERENCE_KEY_BLUETOOTH_HW_ADDRESS, device.getAddress())
- .putString(PREFERENCE_KEY_BLUETOOTH_DEVICE_NAME, device.getName())
+ .putString(PREFERENCE_KEY_BLUETOOTH_DEVICE_NAME, getAlias())
.apply();
- Timber.d("Saved Bluetooth device " + device.getName() + " with address " + device.getAddress());
+ Timber.d("Saved Bluetooth device " + getAlias() + " with address " + device.getAddress());
stopBluetoothDiscovery(); |
Thanks @Florin9doi I applied the patch with b232995 Does this version work now with the nameless OkOk scale? |
If you'd like I can generate an APK on my side and test? ... probably only over the weekend when I find some free time. |
@TRex22 That would be great as I don't own a nameless OkOK scale. You could also use the apk build at https://github.com/oliexdev/openScale/releases/tag/dev-build if you want |
|
These 2 comments can be removed: openScale/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothOKOK2.java Lines 175 to 176 in b232995
I tested on a S24U with Android 14 and doesn't work. |
thanks for testing, I will merge it |
Are you sure you merged the correct branch? I can't find in master the latest fixes from https://github.com/oliexdev/openScale/tree/MY4836 |
you are absolutely right, I hope I pushed the right one now, could you test it maybe again? |
I'll test later this week |
I tested the latest dev build (https://github.com/oliexdev/openScale/releases/tag/dev-build) and it is ok. |
Thanks for testing and your great PR |
Reopen PR #1081