840922704 / BLE_DMM_Client

Bluetooth Multimeter Client
GNU General Public License v3.0
10 stars 3 forks source link

Please ad Aneng V05B (10Byte) #1

Closed ludwich66 closed 2 years ago

ludwich66 commented 2 years ago

Hello 840922704, I only have the small Aneng V05B available. Would be nice if you can implement the 10 byte protocol. Note --> Bit 16 -device type- (the clamp multimeter is still open - for lack of device) I have Python 10.5 on the computer and have problems with the QT5 import - I'm not the most talented ;-) I have to solve that first...

Greatings ludwich

840922704 commented 2 years ago

Hi ludwich: You can install anaconda to separate different python environments and install libs such as bleak with pip. I don't have a lot of time recently, and it will probably take a while to revise. If you are familiar with python, you can do it first. Most of the code can be reused. We should first add a judgment code in the right place.

840922704 commented 2 years ago

@ludwich66 the code is not hard to modify so I did it just now. You can try the v0.2 release and tell me whether it works properly.

webspiderteam commented 2 years ago

Can you inform me too? Im designing WPF app. Uwp was not enough for my plans so i integrated to WPF app. if this code works for all device i will integrate your decoder to my app if you dont mind

840922704 commented 2 years ago

@webspiderteam Glad my code can inspires you. I just added support for 10byte devices in v0.2. However, at present, the algorithm implemented in python is a bit slow, with a delay of about 300ms. Maybe it will be better to introduce mathematical libraries such as numpy to speed up the operation.

webspiderteam commented 2 years ago

Original android app has delay too. I think its depend on data changing and connection. There is nothing to do with it.

This time I will add chart too and data logging as much as I can do.

Thanks for implementing this app and helping to making decoder much better.

ludwich66 commented 2 years ago

@webspiderteam Glad my code can inspires you. I just added support for 10byte devices in v0.2. However, at present, the algorithm implemented in python is a bit slow, with a delay of about 300ms. Maybe it will be better to introduce mathematical libraries such as numpy to speed up the operation.

Now i am work with anaconda :-)

First Test with V0.2:

BT search dialog works well But there is no connection to Aneng V05b established?

Errorcode

守护线程启动
Start lisnening to Bluetooth
58514D8F-2337-CDB
Failed to asyn58514D8F-2337-CDB

thank you for investing your rare time

ludwich

840922704 commented 2 years ago

@ludwich66 That's weird. The normal log should be:

守护线程启动
Start lisnening to Bluetooth
FC:58:FA:53:60:86
now
0101101010100101110000000010010110110101101101111110111111100000000100000000100010000000

It should be MAC address, but your code is "58514D8F-2337-CDB"😂. It seems bleak does not work properly. In order to rule out the influence of the development environment, does the released exe version run normally?

ludwich66 commented 2 years ago

@ludwich66 That's weird. The normal log should be:

守护线程启动
Start lisnening to Bluetooth
FC:58:FA:53:60:86
now
0101101010100101110000000010010110110101101101111110111111100000000100000000100010000000

It should be MAC address, but your code is "58514D8F-2337-CDB"😂. It seems bleak does not work properly. In order to rule out the influence of the development environment, does the released exe version run normally?

Its a representation Problem? Devicename are readable and looks real.

Main Window: 58514D8F-2337-CDBC-9CC3-DDC783386E3F: Bluetooth DMM 2D365B55-79B9-B130-ABA5-61BDEF337879: Unknown 85B9F29C-5BBF-2E9E-E568-9E29ADEBD58E: Unknown BE8E3BE4-58D3-F8FB-5E57-EA9914D13643: Unknown 070CDB94-EFB2-07DC-7B19-D72F1194CFAD: Xiaomi Band 3

I try to find anything in the bleak (used bleak version 0.4.13) Dokumentation today.

  1. Its a MAC Theme (used 12.x)
  2. Response = CHARACTERISTIC_UUID: 58514D8F-2337-CDBC-9CC3-DDC783386E3F
840922704 commented 2 years ago

@ludwich66 Are you using MAC OS so just get UUID? Try the latest code. I just changed the method to fetch integral UUID address.

ludwich66 commented 2 years ago

@ludwich66 Are you using MAC OS so just get UUID? Try the latest code. I just changed the method to fetch integral UUID address.

Great !

There are 80 Bits ;-) I try to check Bit-Order - 0 and ?4 isn't real

What did the first 3 Debug "None" mean?

First Example: "21" "°C" "B" (There are no filling zeros in Display of mini BT-DMM, only these signs)

None
None
None
?4
0
Fri Jun 10 16:19:41 2022

01011010101001010100000000000111011101001100011010100100111000010000000000000000
840922704 commented 2 years ago

@ludwich66 Never mind. I just close the extra debug and optimize the decoder's speed. Try the latest code. The decoder reference: https://github.com/ludwich66/Bluetooth-DMM/wiki/Bluetooth-DMM-10-Byte-Data-Protocol '?4' is because some code still unknown to decode.

webspiderteam commented 2 years ago

I have a litte speed up too for your decoder.

a = int(origin_value, 16)
b = 0x41217355a2c1327166aa3b
#print(format((a ^ b), '000000088b'))
result = format((a ^ b), '000000088b')
prepared = ''
for i in range(0, 87, 8):
    tmp = result[i:(i + 8)]
    prepared = prepared + tmp[::-1]
print(prepared)

Loops slows down a bit so you can do the same with this code :)

ludwich66 commented 2 years ago

@ludwich66 Never mind. I just close the extra debug and optimize the decoder's speed. Try the latest code. The decoder reference: https://github.com/ludwich66/Bluetooth-DMM/wiki/Bluetooth-DMM-10-Byte-Data-Protocol '?4' is because some code still unknown to decode.

How can I help you? Is that ping pong ok?

image

On Multimeter : "22" "°C" "B"

None
None
2None
20
?4 °C
Fri Jun 10 19:46:56 2022
01011010101001010100000000000000000000000000010110110101101100010000000000000001

The digits 0 0 2 2 are contained in Stream. (in the twisted order)

ludwich

webspiderteam commented 2 years ago

I'm working on 10 byte protocol too probably I will solve the data tomorrow(but with my way) based on ANENG V05B sample data of ludwich shared on page.

xor method is so complicated i think and not neccessery its only changing bits to default value. and its digits are same with mine only changes is symbol values.

ludwich66 commented 2 years ago

Ich arbeite auch am 10-Byte-Protokoll, wahrscheinlich werde ich die Daten morgen (aber auf meine Weise) basierend auf ANENG V05B-Beispieldaten von Ludwich lösen, die auf der Seite geteilt werden.

Die xor-Methode ist so kompliziert, denke ich, und es ist nicht notwendig, dass es nur Bits auf den Standardwert ändert. und seine Ziffern sind gleich mit meinen, nur Änderungen sind Symbolwerte.

Did you see this decodervariants? We made this last year but we strugglet with BTLE.

https://github.com/Shiro-Nek0/Bluetooth-DMM.py/issues/1#issue-1265121490

I have a ANENG V05B to test.

ludwich

webspiderteam commented 2 years ago

Is it working without problem? Because all I need for decoding 10byte protocol is symbols position on data

ludwich66 commented 2 years ago

Is it working without problem? Because all I need for decoding 10byte protocol is symbols position on data I don't understand your Problem not exact ;.-) The Positions are in the list (Scroll left-right) https://github.com/ludwich66/Bluetooth-DMM/wiki/Bluetooth-DMM-10-Byte-Data-Protocol Did you search this?

webspiderteam commented 2 years ago

yes i looked them but some of them not known also when trying to decode my dmm i saw that symbol positions on 11byte protocol was different places. Thats why I m asking for :)

ludwich66 commented 2 years ago

yes i looked them but some of them not known also when trying to decode my dmm i saw that symbol positions on 11byte protocol was different places. Thats why I m asking for :)

Yes, to put it simply, the digits are in the same place on two of the devices, the assignment of the other LCD segments is different. The known values are in the table. The implementation of alphanumeric display values is also difficult. "Auto" "EF" etc. The small device shows at 22 degrees C°: " 22" "C°", the big one "0022" "C°"

webspiderteam commented 2 years ago

In my app I have decoded all but battery and blutooth symbols not. I think its enough for using but 10bye protocol gives error because i didnt check if it is 11byte or 10 byte. so if its 10 byte it gives error because there is no 11th byte. Now I'm adding these checks and symbols.

ludwich66 commented 2 years ago

In my app I have decoded all but battery and blutooth symbols not. I think its enough for using but 10bye protocol gives error because i didnt check if it is 11byte or 10 byte. so if its 10 byte it gives error because there is no 11th byte. Now I'm adding these checks and symbols. There is as second indicator a changing Bit in Bitstream, i don't use/see a Clampmeter, but there are more Symbols PEAK INRUSH REL I had a ANENG9002 and now i have an V05B Byte2_0_16 = Typ: DMM(1) ANAENG 9002=1 TYP: smallDMM(2) ANENG V05B=0

webspiderteam commented 2 years ago

decoded all but 2. % and Hold signs has no data for them so i couldnt know them.

webspiderteam commented 2 years ago

10byte

840922704 commented 2 years ago

I have a litte speed up too for your decoder.

a = int(origin_value, 16)
b = 0x41217355a2c1327166aa3b
#print(format((a ^ b), '000000088b'))
result = format((a ^ b), '000000088b')
prepared = ''
for i in range(0, 87, 8):
    tmp = result[i:(i + 8)]
    prepared = prepared + tmp[::-1]
print(prepared)

Loops slows down a bit so you can do the same with this code :)

You can make a PR to merge your code😁.

840922704 commented 2 years ago

@ludwich66 @webspiderteam hello guys I just decompiled the Android app to see the official decode method and upload the files to reference fold in this repository :) There are four devices:

public enum DeviceType {
  AB_300, P_66, QB_5G, S_5G;

  static {
    AB_300 = new DeviceType("AB_300", 2);
    P_66 = new DeviceType("P_66", 3);
    $VALUES = new DeviceType[] { QB_5G, S_5G, AB_300, P_66 };
  }
}

The preprocess seems more complicated and harder to understand:

public class EncryptionUtil {
  public static byte[] encByted = new byte[] { 
      65, 33, 115, 85, -94, -63, 50, 113, 102, -86, 
      59, -48, -30, -88, 51, 20, 32, 26, -86, -69 };

  public static byte[] enc_code(byte[] paramArrayOfbyte) {
    byte[] arrayOfByte = new byte[paramArrayOfbyte.length];
    for (byte b = 0; b < paramArrayOfbyte.length; b++)
      arrayOfByte[b] = (byte)(byte)(paramArrayOfbyte[b] ^ encByted[b % 20]); 
    return arrayOfByte;
  }

Also, in the core decoder they also didn't consider the light or HOLD. So, I think it's okay to only decode the important information. I hope those files will be helpful.

ludwich66 commented 2 years ago

@840922704

It looks like an representation of the XOR Key in decimal. But the minus signs? Bitshifting?

EncryptionUtil        | dez | 65 | 33 | 115| 85 | -94? | -63? | 50 | 113 | 102 | -86? | 59 | -48? | -30? | -88? | 51 | 20 | 32 | 26 | -86? | -69?
key for xor Operation | hex | 41 | 21 |  73| 55 |  a2  |   c1 | 32 |  71 |  66 |   aa | 3b |   d0 |   e2 |   a8 | 33 | 14 | 20 | 21 |   aa | bb

Next open Question? Did you find anything about the bidireiktionality of Mini-Multimeter? Mini Multimeter works as remote-device.

ludwich66 commented 2 years ago

10byte

I dont understand your Table ;-( Line 2 dont represent "°C" in case of Line 6 "__28 "?

Please help me ;-) I used nearly the same Table, bur in flipped Order its clearer to read - Digits are in same Order

"do it step by step" ludwich

webspiderteam commented 2 years ago

10byte

I dont understand your Table ;-( Line 2 dont represent "°C" in case of Line 6 "__28 "?

Please help me ;-) I used nearly the same Table, bur in flipped Order its clearer to read - Digits are in same Order

"do it step by step" ludwich

its converted raw data :) not bitwised or flipped. your table is mostly true only some of them has wrong like hold i think because mine was at 59.th bit and i guessed the % sign at 75 i dont know if its true or not 10bytenew .

webspiderteam commented 2 years ago

My new decoder about to finish. I can share decoder code if you wish. But its in C#. If you can wait I will upload new WPF app a couple hours later i think. Its not finished compeletely but it can display datas for now.

webspiderteam commented 2 years ago

done for now. It's ready to test. Can you test this? It supports 10byte and 11byte protocol. https://github.com/webspiderteam/Bluetooth-DMM-For-Windows/releases/tag/WPFAlpha

ludwich66 commented 2 years ago

@webspiderteam It would be nice if we could reverse engineer the third model (new ore an "old" protocol?). kris0725pl has a Clamp-Meter

Have you found any clear errors in my mapping of the protocols - Please tell me - I would like to correct them.

I won't be able to check your code until next week, my last Windows computer has no BTLE device now.

greatings ludwich

webspiderteam commented 2 years ago

I tried to solve the original app but it maked too complicated. They dont want us to know I think. But if you can add enough data like 10byte protocol I can decode I think. My only device is an9002.

Your mapping is mostly true but Hold must be in 60th bit. Not sure about '%' but I guess its 76th. bit. thats all but may be Im wrong because there is no data for them I guessed them from my datas. also there is no led indicator in data. bit 24 is emty and 3rd byte is for device type. there is 4 type decoding and they are checking it from 3rd byte. thats all I know about it for now.

May be I could make fixes on this code and inform you if I can. But there is a problem with xor segment I think. because my decode bits different from this decoded bits.

840922704 commented 2 years ago

@webspiderteam I just add real time plot and file save function. The compiled file is too large to tolerate😂. GUI is not suitable for python: I would rather use the core decoder in Jupyter notebook for interact. There are some fantasy apps such as https://www.microsoft.com/store/productId/9N8S8M8226SH in Microsoft store. Maybe you can get some inspiration😁.

webspiderteam commented 2 years ago

If you did realtime logging your log should be very large. I did logging in my app too. While my test for logging I saw that its about 50KB for 10 - 15 second. Its too large if you use more than 5 minutes. So I filtered logging for only changed values now its 1 or 2KB depending on changes but its for 5 minutes :)

Which OS do you use? Did you try my app? its 200Kb for now. I wish I can make it good looking but I'm not a good designer :) so I will do it as simple :) Maybe someone can help me to improve the desing :)

840922704 commented 2 years ago

If you did realtime logging your log should be very large. I did logging in my app too. While my test for logging I saw that its about 50KB for 10 - 15 second. Its too large if you use more than 5 minutes. So I filtered logging for only changed values now its 1 or 2KB depending on changes but its for 5 minutes :)

Which OS do you use? Did you try my app? Its 200Kb for now. I wish I can make it good looking but I'm not a good designer :) so I will do it as simple :) Maybe someone can help me to improve the desing :)

I'm using windows, closed logger and used print instead. What I complain is just python's environment is bloated: V1.0 🤣🤣It's 300MB for exe. I tried your app and opened an issue, remember? Any idea about the real-time drawing component?😎

webspiderteam commented 2 years ago

yes I remember but I yesterday uploaded new one with WPF as I said there I'm porting my app to wpf for chart. I'm working on chart right now. If I can I will finish it in a few days I think.

webspiderteam commented 2 years ago

I have aneng st207 data and decoded it I think. not sure all of them but u can add @ludwich66 @840922704 10bytetyp2 device type depend on byte 3 bitvised adn flipped 00000001 or 10000000. the old 10byte device type was 00000011 or 11000000

ludwich66 commented 2 years ago

I have aneng st207 data and decoded it I think. not sure all of them but u can add @ludwich66 @840922704 10bytetyp2 device type depend on byte 3 bitvised adn flipped 00000001 or 10000000. the old 10byte device type was 00000011 or 11000000

Please provide clear and comprehensible data. One spins the other starts counting from 0 or 1. It is best to use the hex values and source with the display value. This is the best way to avoid mistakes - thank you! Great, then we'll slowly get the device under control ;-) Ludwich

Please Check it: Typ 11=(1)Multimeter/11Byte Typ 10=(2)Small-Multimeter/10Byte Typ 01=(3)Clamp-Multimeter/10Byte

webspiderteam commented 2 years ago

the top line is bit number and below what it is displaying. I Have a log but without values and not hex type decmical type because C# gives me like that. log.txt this is log of it. I learned values from https://www.youtube.com/watch?v=rJkatoVu8FE this video and https://www.youtube.com/watch?v=CBDvwMhPZcQ this one is my decoded result

Please Check it: Typ 11=(1)Multimeter/11Byte Typ 10=(2)Small-Multimeter/10Byte Typ 01=(3)Clamp-Multimeter/10Byte

thats right Ludwich but while we flip bit order 00000001 changes to 10000000 thats why I wrote like that ;)

ludwich66 commented 2 years ago

Anlayışınız için teşekkürler - kötü bir şey demek istemedim ;-) Log.txt is in the same order as plain Hex from gatttol. Nice that the cooperation works around the globe. The YouTube videos are a good option, although I don't know how to display the OSD - you never stop learning. ludwich

webspiderteam commented 2 years ago

Anlayışınız için teşekkürler - kötü bir şey demek istemedim ;-) Teşekkürler:) thanks :))

Nice that the cooperation works around the globe.

I agree This was so cool :)

I don't know how to display the OSD

OBS Studio has window capture abilitiy but I cant remember how can we use :(

webspiderteam commented 2 years ago
My decoded table Bit ID _____ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
11byte (Type ID 10)                                                 Rel∆ Buzz - d1e d1b d1a d1g d1f d1d d1c . d2 d2 d2 d2 d2 d2 d2 . d3 d3 d3 d3 d3 d3 d3 . d4 d4 d4 d4 d4 d4 d4 H °F °C 0 max min % AC F m(F) u(F) n(F) Hz Ω k M V m(V) DC A auto   u(A) m(A)        
10 byte (Type ID 01)                                                 Hold High volt   Buzz  - d1e d1b d1a d1g d1f d1d d1c . d2 d2 d2 d2 d2 d2 d2 . d3 d3 d3 d3 d3 d3 d3 . d4 d4 d4 d4 d4 d4 d4 n V DC AC F Diode  A u Ω k m M   Hz °F °C INRUSH   Peek ??
10byte (Type ID 11)                                                 Hold? High volt   Buzz  - d1e d1b d1a d1g d1f d1d d1c . d2 d2 d2 d2 d2 d2 d2 . d3 d3 d3 d3 d3 d3 d3 . d4 d4 d4 d4 d4 d4 d4 Hold?   n V DC AC F Diode A u Ω k m M %? Hz °F °C

11byte is complete for use if there is battery indicator or Bluetooth indicator these are missing in all protocols 10byte protocols there is ?? Which I'm not sure.

ludwich66 commented 2 years ago

Bit ID _____ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 11byte (Type ID 10)                                                 Rel∆ Buzz - d1e d1b d1a d1g d1f d1d d1c . d2 d2 d2 d2 d2 d2 d2 . d3 d3 d3 d3 d3 d3 d3 . d4 d4 d4 d4 d4 d4 d4 H °F °C 0 max min % AC F m(F) u(F) n(F) Hz Ω k M V m(V) DC A auto   u(A) m(A)         10 byte (Type ID 01)                                                 Hold High volt   Buzz  - d1e d1b d1a d1g d1f d1d d1c . d2 d2 d2 d2 d2 d2 d2 . d3 d3 d3 d3 d3 d3 d3 . d4 d4 d4 d4 d4 d4 d4 n V DC AC F Diode  A u Ω k m M   Hz °F °C INRUSH   Peek ??
10byte (Type ID 11)                                                 Hold? High volt   Buzz  - d1e d1b d1a d1g d1f d1d d1c . d2 d2 d2 d2 d2 d2 d2 . d3 d3 d3 d3 d3 d3 d3 . d4 d4 d4 d4 d4 d4 d4 Hold?   n V DC AC F Diode A u Ω k m M %? Hz °F °C

Great !!

I beginning with same representation 1/2 hour before ;-) Tomorrow i receive my new WLAN/BT5.0b Card - hope without problems. Then i test it ;-)

Thanks

webspiderteam commented 2 years ago

Never mind. I like the way that we work together 😊 my thank to you all 🙏 helped me a lot

840922704 commented 2 years ago

@ludwich66 the code in your wiki may have some mistakes. In the Bluetooth DMM 10 Byte Data Protocol --->4. Build the 80 Bit Datastream section, Bitsnr#16 is 1 as the hex 03 is 0000 0011:

image

This influences the judgment of device type.

840922704 commented 2 years ago

I just test out that my decoder script work badly to 10 bytes🤣. So I just change the method to Bluetooth-DMM.py And later I will release a version complied by Nuitka. Only below 45 MB after packaging for Windows.

ludwich66 commented 2 years ago

@ludwich66Der Code in Ihrem Wiki kann einige Fehler enthalten. Im Bluetooth DMM 10 Byte Data Protocol --->4. Erstellen Sie den 80-Bit-Datastream-Abschnitt, Bitsnr#16 ist 1, da der Hex 03 0000 0011 ist:

Abbild

Dies beeinflusst das Urteil über den Gerätetyp.

Thanks - Problem Fixed i work on a new combined overviewpage in 1:1 view without flipped bytes. It will be ;-)

ludwich

ludwich66 commented 2 years ago

@840922704

None None 2None 20 ?4 °C Fri Jun 10 19:46:56 2022 01011010101001010100000000000000000000000000010110110101101100010000000000000001

I generated this Output with V05B an checked the Digits - Stream looks good Theresa only a little decoding problem

Thumbs up ludwich

840922704 commented 2 years ago

New version 2.0 released. That may solve most of the decoder's problems and also an installer version be released.

webspiderteam commented 2 years ago

Congratulations :) Looks like working great 👍 also another congratulations to decreased size of app. Good work :)