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 NEEY/Heltec 4A balancer support #109

Closed
syssi opened this issue May 11, 2022 · 127 comments
Closed

Add NEEY/Heltec 4A balancer support #109

syssi opened this issue May 11, 2022 · 127 comments
Labels
enhancement New feature or request

Comments

@syssi
Copy link
Owner

syssi commented May 11, 2022

See #106.

The android apps aren't obfuscated. It should be possible to extract details about the protocol / frame structure and content.

@syssi syssi added help wanted Extra attention is needed enhancement New feature or request labels May 11, 2022
@syssi
Copy link
Owner Author

syssi commented May 11, 2022

Do you own a NEEY or Heltec 4A balancer and a Android device with the app installed? Please provide a btsnoop capture which can be easily created if you follow these instructions:

https://medium.com/@charlie.d.anderson/how-to-get-the-bluetooth-host-controller-interface-logs-from-a-modern-android-phone-d23bde00b9fa

The capture is helpful to replicate the behavior / BLE frames of the Android app to talk to the BMS using this component.

@cristi2005

@syssi
Copy link
Owner Author

syssi commented May 11, 2022

# Frame:

2 Bytes: Start of frame (0x55 0xAA) 
1 Bytes: Address (0x11)
1 Bytes: Read or write
2 Bytes: Command
2 Bytes: Data length
n Bytes: Data
1 Bytes: End of frame (0xFF)


# Commands / Data structure

0x01: Request system data
  - 16 Bytes: Module No
  -  8 Bytes: Hardware version
  -  8 Bytes: Software version
  -  8 Bytes: Protocol version
  -  8 Bytes: Cycle
  -  Int: Reboots counter
  -  Int: Total uptime

0x02: Request battery data
  - 1 Byte: Serial number
  - Cell data
    - Float: Cell voltage 1
    - Float: Cell voltage 2
    - Float: Cell voltage 3
    ...
    - Float: Cell voltage 24
  - Resistance
    - Float: Cell resistance 1
    - Float: Cell resistance 2
    - Float: Cell resistance 3
    ....
    - Float: Cell resistance 24
  - Float: Total voltage
  - Float: SingleVoltage?!
  - Float: MaxMPa
  - 1 Byte: Max Voltage Cell Number
  - 1 Byte: Min Voltage Cell Number
  - 1 Byte: Single Num
  - 1 Byte: Balancing
  - Float: Balancing current
  - 1 Float: Tempature 1
  - 1 Float: Tempature 2
  - 1 Float: Tempature 3
  - 1 Byte: Error bitmask?
  - 1 Byte: NTC warnings?
  - Int: TempStamp?
  
  
0x03: Factory reset
  - 1 Float: Standard voltage 1
  - 1 Float: Standard voltage 2
  - 1 Float: Battery voltage 1
  - 1 Float: Battery voltage 2
  - 1 Float: Standard current 1
  - 1 Float: Standard current 2
  - 1 Float: Super Bat 1
  - 1 Float: Super Bat 2
  - 1 Float: Resistor 1
  - 1 Float: Bat Status
  - 1 Float: Max Voltage
  - 1 Float: Min Voltage
  - 1 Float: NTC Max Temperature
  - 1 Float: NTC Min Temperature
  - Int: Reboot counter
  - 8 Bytes String: Cycle

0x04: Request settings
  - 1 Byte: Num (Battery strings?)
  - 1 Float: MPA
  - 1 Float: Max Current
  - 1 Float: Turn off voltage
  - 1 Byte: Balancer
  - 1 Byte: Alarm mode
  - 1 Byte: Bat mode
  - 1 Int: Bat Volume
  - 1 Float: Balancing start voltage

@cristi2005
Copy link

Hi,
In this moment I don't have a balancer, I order one NEEY today, when he arrives I'll let you know here and we'll do tests.
Cristi

@syssi
Copy link
Owner Author

syssi commented May 13, 2022

I know. I just tried to inform you if you own the device some day we could give it a try to add device support.

@cristi2005
Copy link

Thank you for the great news and involvement.

@cristi2005
Copy link

Hi I have a Neey balancer, I prepare a phone settings for developer otions....... I downloaded adb files, I conected the phone on laptop, run powershell:

#!/bin/bash
OUTPUT_DIR=$(pwd)
pushd /tmp
echo "Getting Bug Report..."
adb bugreport bug
echo "Unzipping Bluetooth HCI Log..."
unzip bug.zip FS/data/log/bt/btsnoop_hci.log
echo "Copying btsnoop_hci.log to '$OUTPUT_DIR' ..."
cp FS/data/log/bt/btsnoop_hci.log $OUTPUT_DIR/$(date +"%Y%m%d_%H%M%S")_btsnoop_hci.log
echo "Cleaning up..."
rm FS/data/log/bt/btsnoop_hci.log
rm bug.zip
popd

And have a lot of errors and not create btsnoop capture.
If you have some time to help my with the capture please leave message here.

Thank you,
Cristi

@syssi
Copy link
Owner Author

syssi commented Jul 29, 2022

Are you sure the bug.zip did not contain a "btsnootlog"?

unzip bug.zip
find . -name btsnoop_hci.log

@cristi2005
Copy link

Only this 4 file:

bugreport-2022-07-29-21-20-00.txt
dumpstate_log.txt
main_entry.txt
version.txt

@cristi2005
Copy link

If you want can allow a remote desktop with AnyDesk ?

@syssi
Copy link
Owner Author

syssi commented Jul 29, 2022

I will provide some additional instructions tomorrow. I assume some important steps of the capturing process are missing. I've to verify some steps locally to provide better instructions. Probably just a "Bluetooth off + Bluetooth on" is missing to trigger the traffic capture. Please start the NEEY app as next step and connect to the BMS. The to retrieve the bug report again. This time the file should be part of the dump. If not we could try to retrieve the dump manually from your device using adb. Where are you from / at which timezone do you life? I've some free time for a anydesk session tomorrow.

@cristi2005
Copy link

I am from Romania, it's ok for me tomorrow, I'm at home all today and can tested all necesary.
Give me a sign tomorrow when you have time and we'll do the tests together.

@syssi
Copy link
Owner Author

syssi commented Jul 29, 2022

Alright. I will ping you tomorrow!

@cristi2005
Copy link

Ok, good nyght.

@syssi
Copy link
Owner Author

syssi commented Jul 30, 2022

Could you tell me the Android version of your device?

@cristi2005
Copy link

8.0.0

@syssi
Copy link
Owner Author

syssi commented Jul 30, 2022

I tried the following with my Android 9 phone:

  1. Enable ADB
  2. Enable Bluetooth HCI snoop log
  3. Turn off bluetooth + turn on bluetooth
  4. Start the BMS app and play around
  5. Generate a bug report containing the capture adb bugreport bug
  6. Unzip the bug.zip and copy the FS/data/misc/bluetooth/logs/btsnoop_hci.log:
$ unzip ../bug.zip
Archive:  ../bug.zip
  inflating: version.txt             
  inflating: proto/SurfaceFlinger_CRITICAL.proto  
  inflating: proto/activity_CRITICAL.proto  
  inflating: proto/window_CRITICAL.proto  
  inflating: FS/data/misc/recovery/ro.build.fingerprint  
  inflating: FS/data/misc/recovery/proc/version.1  
  inflating: FS/data/misc/recovery/proc/version  
  inflating: FS/data/misc/recovery/ro.build.fingerprint.1
[...]
  inflating: lshal-debug/[email protected]::IQtiOemHook_oemhook1.txt  
  inflating: lshal-debug/[email protected]::IQtiRadio_slot1.txt  
  inflating: lshal-debug/[email protected]::IQtiRadio_slot2.txt  
  inflating: lshal-debug/[email protected]::IQtiRadio_slot1.txt  
  inflating: lshal-debug/[email protected]::IQtiRadio_slot2.txt  
  inflating: lshal-debug/[email protected]::IUim_Uim0.txt  
  inflating: lshal-debug/[email protected]::IUim_Uim1.txt  
  inflating: lshal-debug/[email protected]::IUim_Uim0.txt  
  inflating: lshal-debug/[email protected]::IUim_Uim1.txt  
  inflating: lshal-debug/[email protected]::IUimRemoteServiceClient_uimRemoteClient0.txt  
  inflating: lshal-debug/[email protected]::IUimRemoteServiceClient_uimRemoteClient1.txt  
  inflating: lshal-debug/[email protected]::IUimRemoteServiceServer_uimRemoteServer0.txt  
  inflating: lshal-debug/[email protected]::IUimRemoteServiceServer_uimRemoteServer1.txt  
  inflating: lshal-debug/[email protected]::ITuiComm_default.txt  
  inflating: lshal-debug/[email protected]::IService_default.txt  
  inflating: lshal-debug/[email protected]::IRTPService_imsrtpservice.txt  
  inflating: FS/data/misc/bluetooth/logs/btsnoop_hci.log  
  inflating: FS/data/misc/bluetooth/logs/firmware_events.log  
  inflating: FS/data/misc/bluetooth/logs/firmware_events.log.last  
  inflating: FS/data/anr/anr_2022-07-29-10-04-23-453  
  inflating: FS/data/tombstones/tombstone_24  
  inflating: FS/data/tombstones/tombstone_23  
  inflating: FS/data/tombstones/tombstone_22  
  inflating: FS/data/tombstones/tombstone_21  
  inflating: FS/data/tombstones/tombstone_20  
  inflating: FS/data/tombstones/tombstone_19  
  inflating: FS/data/tombstones/tombstone_18  
  inflating: FS/data/tombstones/tombstone_17  
  inflating: FS/data/tombstones/tombstone_16  
  inflating: FS/data/tombstones/tombstone_15  
  inflating: proto/activity.proto    
  inflating: bugreport-jasmine-PQ3A.190801.002-2022-07-30-10-22-53.txt  
  inflating: main_entry.txt          
  inflating: dumpstate_log.txt   

My bug.zip contains hundreds of files.

@syssi
Copy link
Owner Author

syssi commented Jul 30, 2022

Is your phone rooted? If yes we could try this approach: https://stackoverflow.com/a/58384046

@cristi2005
Copy link

Can you asist me on AnyDesk ?
If is yes where send AnyDesk ID ?

@cristi2005
Copy link

Finaly I have BT snoop log, I send an email to see if ok ?

@cristi2005
Copy link

cristi2005 commented Jul 30, 2022

I send on email.

works with your steps:

Enable ADB
Enable Bluetooth HCI snoop log
Turn off bluetooth + turn on bluetooth
Start the BMS app and play around
Generate a bug report containing the capture adb bugreport bug
Unzip the bug.zip and copy the FS/data/misc/bluetooth/logs/btsnoop_hci.log:

THX

@syssi
Copy link
Owner Author

syssi commented Jul 30, 2022

Awesome! It looks like your capture contains everything I'm looking for. I will try to extract some requests & responses.

@syssi
Copy link
Owner Author

syssi commented Jul 30, 2022

1. Command

<- Write request (0x12)
   Service UUID: 0xffe0
   Char: 0xffe1
   Char Configuration: 0x2902
   (Handle 0x000b, Subscribe to notifications)

-> Write response (0x13)


2. Write command (0x52)
   Service UUID: 0xffe0
   Char: 0xffe1
   Value: aa5511010100140000000000000000000000faff



More commands:

aa5511010400140000000000000000000000ffff
aa5511010200001400000000000000000000f9ff

aa551100050d140000000000000000000000f2ff
aa551100050d140000000000000000000000f2ff

aa551100050d140001000000000000000000f3ff
aa551100050d140001000000000000000000f3ff



Notifications (32 bytes per chunk, 480 bytes per frame):

01: 55aa110102002c0138e7fa5040b6045140850e51
02: 40f0055140b6045140751e51407f4f5140430251
03: 401c3d5140786a5140fe825140167e5140bc7651
04: 40167e51408b805140ca66514000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00de405142de4051400017083c0a000f0519a182
12: c0c3f54842c3f548420000000000000000000000
13: 0000000000000000000000000000762e09000000
14: 0000000000000000000000000000000000000000
15: 000000000000000000000000000000000000b6ff

01: 55aa110102002c0139e7fa5040b6045140850e51
02: 40f0055140b6045140751e51407f4f5140430251
03: 401c3d5140786a5140fe825140167e5140bc7651
04: 40167e51408b805140ca66514000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00de405142de4051400017083c0a000f0519a182
12: c0c3f54842c3f548420000000000000000000000
13: 0000000000000000000000000000772e09000000
14: 0000000000000000000000000000000000000000
15: 000000000000000000000000000000000000b8ff

01: 55aa110102002c013ae7fa5040b6045140850e51
02: 40f0055140b6045140751e51407f4f5140430251
03: 401c3d5140786a5140fe825140167e5140bc7651
04: 40167e51408b805140ca66514000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00de405142de4051400017083c0a000f0519a182
12: c0c3f54842c3f548420000000000000000000000
13: 0000000000000000000000000000772e09000000
14: 0000000000000000000000000000000000000000
15: 000000000000000000000000000000000000b9ff

01: 55aa11010100640047572d323453344542000000
02: 0000000048572d322e382e305a482d312e322e33
03: 56312e302e300000323032323035333105000000
04: 9f41090000000000000000000000000000000000
05: 000000000000000000000000000000000000f8ff

-> Command: aa5511010400140000000000000000000000ffff

01: 55aa110104006400100ad7a33b00008040000020
02: 4001010218010000666626400000000000000000
03: 0000000000000000000000000000000000000000
04: 0000000000000000000000000000000000000000
05: 000000000000000000000000000000000000b7ff

-> Command: aa5511010200001400000000000000000000f9ff

01: 55aa110102002c013bddf04f40cab44f40cab44f
02: 4025bc4f405fbd4f4087a84f40449c4f4081c34f
03: 402e0553405ffb5240e2ed52400bd95240b1f752
04: 4004f45240caf252400dff524000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 001558514215585140803a5a3d08060f053b0b81
12: c066664942666649420000000000000000000000
13: 00000000000000000000000000002b120a000000
14: 0000000000000000000000000000000000000000
15: 00000000000000000000000000000000000088ff

01: 55aa110102002c013cddf04f40cab44f4002b64f
02: 4025bc4f4025bc4f4035ac4f40f29f4f402ec74f
03: 4067065340d3fd524056f05240b9dc524025fa52
04: 4004f4524004f45240ba02534000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00d7595142d7595140409d593d08060f053b0b81
12: c0c3f54842c3f548420000000000000000000000
13: 00000000000000000000000000002c120a000000
14: 0000000000000000000000000000000000000000
15: 00000000000000000000000000000000000057ff

01: 55aa110102002c013dddf04f40cab44f4002b64f
02: 4025bc4f4025bc4f4035ac4f40f29f4f402ec74f
03: 4067065340d3fd524056f05240b9dc524025fa52
04: 4004f4524004f45240ba02534000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00d7595142d7595140409d593d08060f053b0b81
12: c0c3f54842c3f548420000000000000000000000
13: 00000000000000000000000000002c120a000000
14: 0000000000000000000000000000000000000000
15: 00000000000000000000000000000000000058ff

01: 55aa110102002c013eddf04f40cab44f4002b64f
02: 4025bc4f4025bc4f4035ac4f40f29f4f402ec74f
03: 4067065340d3fd524056f05240b9dc524025fa52
04: 4004f4524004f45240ba02534000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00d7595142d7595140409d593d08060f059e3f83
12: c0c3f54842c3f548420000000000000000000000
13: 00000000000000000000000000002d120a000000
14: 0000000000000000000000000000000000000000
15: 000000000000000000000000000000000000f3ff

01: 55aa110102002c013fddf04f40cab44f4002b64f
02: 4025bc4f4025bc4f4035ac4f40f29f4f402ec74f
03: 4067065340d3fd524056f05240b9dc524025fa52
04: 4004f4524004f45240ba02534000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00d7595142d7595140409d593d08060f05b3e07f
12: c0c3f54842c3f548420000000000000000000000
13: 00000000000000000000000000002d120a000000
14: 0000000000000000000000000000000000000000
15: 000000000000000000000000000000000000a6ff

-> Command: aa551100050d140000000000000000000000f2ff
<- Command response: 55aa1100050d14000000000000000000000036ff

01: 55aa110102002c0140ddf04f40cab44f4002b64f
02: 4025bc4f4025bc4f4035ac4f40f29f4f402ec74f
03: 4067065340d3fd524056f05240b9dc524025fa52
04: 4004f4524004f45240ba02534000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00d7595142d7595140409d593d08060f05cff081
12: c0c3f54842c3f548420000000000000000000000
13: 00000000000000000000000000002e120a000000
14: 0000000000000000000000000000000000000000
15: 000000000000000000000000000000000000d6ff

-> Command: aa551100050d140001000000000000000000f3ff
<- Command response: 55aa1100050d14000000000000000000000036ff

01: 55aa110102002c0146a3ef4f4056b24f4056b24f
02: 40b1b94f40ebba4f404da74f40d0994f40bac44f
03: 407f01534098fc5240e2ed52400bd95240ebf852
04: 403ef5524004f45240f403534000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 009f5751429f57514000895a3d0f060f04000000
12: 007b1448427b1448420000000000000000000000
13: 000000000000000000000000000031120a000000
14: 0000000000000000000000000000000000000000
15: 00000000000000000000000000000000000015ff

-> Command: aa551100050d140000000000000000000000f2ff
<- Command response: 55aa1100050d14000000000000000000000036ff

01: 55aa110102002c018f72f94f405fbd4f405fbd4f
02: 4046c24f40bac44f4056b24f409fa34f4089ce4f
03: 40e4135340dc08534098fc5240fbe85240670653
04: 402e0553400dff52407011534000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00e1635142e163514040115c3d08060f050a8880
12: c052b84a4252b84a420000000000000000000000
13: 000000000000000000000000000056120a000000
14: 0000000000000000000000000000000000000000
15: 000000000000000000000000000000000000a3ff

01: 55aa110102002c019072f94f405fbd4f405fbd4f
02: 4046c24f40bac44f4056b24f409fa34f4089ce4f
03: 40e4135340dc08534098fc5240fbe85240670653
04: 402e0553400dff52407011534000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00e1635142e163514040115c3d08060f04000000
12: 0052b84a4252b84a420000000000000000000000
13: 000000000000000000000000000057120a000000
14: 0000000000000000000000000000000000000000
15: 000000000000000000000000000000000000d2ff

-> Command: aa551100050d140001000000000000000000f3ff
<- Command response: 55aa1100050d14000000000000000000000036ff

01: 55aa110102002c019672f94f40ebba4f405fbd4f
02: 40bac44f4046c24f40cab44f4013a64f40c3cf4f
03: 401d155340c20d53400dff524035ea5240dc0853
04: 402e055340470053403610534000000000000000
05: 0000000000000000000000000000000000000000
06: 00000000003593243e6894263e3d251b3e908e1b
07: 3eb3f3233e2e91253ec61b1a3e4a7c1c3e6f1b1a
08: 3ec2431b3e851e183e4b27193e5edf183ed0eb1a
09: 3ee6d4183e0cfe183e0000000000000000000000
10: 0000000000000000000000000000000000000000
11: 00e0645142e064514080c25b3d08060f04000000
12: 000bd749420bd749420000000000000000000000
13: 00000000000000000000000000005a120a000000
14: 0000000000000000000000000000000000000000
15: 0000000000000000000000000000000000007cff

@syssi
Copy link
Owner Author

syssi commented Jul 30, 2022

Could you provide some screenshots of the android app? This will help me a bit to understand what's available/exposed and whats internal + what can be controlled and what's read-only.

@cristi2005
Copy link

cristi2005 commented Jul 30, 2022 via email

@syssi
Copy link
Owner Author

syssi commented Jul 30, 2022

I attached a pic, If you need somthing ... please tell me.

Thanks! Could you explain the purpose of the Run: switch which is turned on at the moment?

@cristi2005
Copy link

cristi2005 commented Jul 30, 2022 via email

@syssi
Copy link
Owner Author

syssi commented Jul 30, 2022

I would be happy if you could create another traffic capture while turning balancing on and off multiple times. I would like to capture the balancing on/off commands.

@cristi2005
Copy link

cristi2005 commented Jul 30, 2022 via email

@cristi2005
Copy link

Yes is correct.

@cristi2005
Copy link

log.txt

WhatsApp Image 2022-08-08 at 21 03 56

ballance curent

When I set the current in Homeassistant, it is also set in Balancer, I checked with the Android application, I have attached pictures.

@syssi
Copy link
Owner Author

syssi commented Aug 8, 2022

Looks good to me. No issues found. Correct? In this case only the error bitmask is missing + some documentation and we are feature complete. Do you miss something?

@cristi2005
Copy link

Only the missing problem above, the one with the missing entities after restarting Homeassistant. Can't you set those entities to load automatically after the HA restart?

@syssi
Copy link
Owner Author

syssi commented Aug 8, 2022

You could add an automation to your HA setup to press the retrieve settings button automatically on startup (once).

@syssi
Copy link
Owner Author

syssi commented Aug 8, 2022

If the periodic beep isn't a problem we could add the retrieve settings call to the yaml configuration.

@cristi2005
Copy link

If the periodic beep isn't a problem we could add the retrieve settings call to the yaml configuration.

Ok

@cristi2005
Copy link

You could add an automation to your HA setup to press the retrieve settings button automatically on startup (once).

this is also an option

@syssi
Copy link
Owner Author

syssi commented Aug 8, 2022

If the periodic beep isn't a problem we could add the retrieve settings call to the yaml configuration.

You could add this approach to your configuration: 54f5b19

@syssi
Copy link
Owner Author

syssi commented Aug 8, 2022

Take a look at the full file: https://github.com/syssi/esphome-jk-bms/blob/79d6016c98388e0cda4f7d981de7153adfaf4372/esp32-heltec-balancer-ble-example.yaml

It's important to assign an id to the retrieve settings button to be able to use the button at a action.

The last two text sensors are also new but unrelated:

text_sensor:
  - platform: heltec_balancer_ble
    errors:
      name: "${name} errors"
    operation_status:
      name: "${name} operation status"
    total_runtime_formatted:
      name: "${name} total runtime formatted"
    buzzer_mode:
      name: "${name} buzzer mode"
    battery_type:
      name: "${name} battery type"

@syssi syssi closed this as completed in 854196d Aug 14, 2022
@syssi
Copy link
Owner Author

syssi commented Aug 14, 2022

I've merged the NEEY balancer support into main. Please update configuration yaml to:

  external_components_source: github://syssi/esphome-jk-bms@main

@cristi2005
Copy link

I've merged the NEEY balancer support into main. Please update configuration yaml to:

  external_components_source: github://syssi/esphome-jk-bms@main

Ok, Thank you for this wonderful integration and thank you for support.

@cristi2005
Copy link

Hi,

When I try to compile the code I have this error's:

Microsoft Windows [Version 10.0.19044.2006]
(c) Microsoft Corporation. All rights reserved.

C:\tools\neey-ball2>esphome clean neey-bal1.yaml
←[32mINFO Reading configuration neey-bal1.yaml...←[0m
←[31mERROR Error while reading config: Invalid YAML syntax:

Error reading file neey-bal1.yaml: [Errno 2] No such file or directory: 'neey-bal1.yaml'←[0m

C:\tools\neey-ball2>esphome clean neey-bal2.yaml
←[32mINFO Reading configuration neey-bal2.yaml...←[0m
←[32mINFO Updating https://github.com/syssi/esphome-jk-bms.git@main←[0m
←[33mWARNING GPIO2 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins←[0m
←[32mINFO Deleting .esphome/build/neey-bal2.pioenvs←[0m
←[32mINFO Done!←[0m

C:\tools\neey-ball2>esphome run neey-bal2.yaml
←[32mINFO Reading configuration neey-bal2.yaml...←[0m
←[32mINFO Updating https://github.com/syssi/esphome-jk-bms.git@main←[0m
←[33mWARNING GPIO2 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins←[0m
←[32mINFO Generating C++ source...←[0m
←[32mINFO Compiling app...←[0m
Processing neey-bal2 (board: wemos_d1_mini32; framework: espidf; platform: platformio/espressif32 @ 3.5.0)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/wemos_d1_mini32.html
PLATFORM: Espressif 32 (3.5.0) > WeMos D1 MINI ESP32
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:

  • framework-espidf 3.40302.0 (4.3.2)
  • tool-cmake 3.16.4
  • tool-esptoolpy 1.30100.210531 (3.1.0)
  • tool-idf 1.0.1
  • tool-mconf 1.4060000.20190628 (406.0.0)
  • tool-ninja 1.9.0
  • toolchain-esp32ulp 1.22851.191205 (2.28.51)
  • toolchain-riscv32-esp 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32s2 8.4.0+2021r2-patch2
    Reading CMake configuration...
    Generating assembly for certificate bundle...
    LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ off, Compatibility ~ soft
    Found 0 compatible libraries
    Scanning dependencies...
    No dependencies
    Building in release mode
    Compiling .pioenvs\neey-bal2\src\esphome\components\api\api_connection.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\api\api_frame_helper.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\api\api_pb2.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\api\api_pb2_service.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\api\api_server.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\api\list_entities.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\api\proto.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\api\subscribe_state.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\api\user_services.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\binary_sensor\automation.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\binary_sensor\binary_sensor.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\binary_sensor\filter.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\ble_client\ble_client.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\button\button.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\esp32\core.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\esp32\gpio_arduino.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\esp32\gpio_idf.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\esp32\preferences.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\esp32_ble_tracker\esp32_ble_tracker.o
    src/esphome/components/ble_client/ble_client.cpp: In member function 'float esphome::ble_client::BLEClient::parse_char_value(uint8_t*, uint16_t)':
    src/esphome/components/ble_client/ble_client.cpp:257:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (length > 2) {
    ^~
    src/esphome/components/ble_client/ble_client.cpp:260:5: note: here
    case 0x7: // uint24.
    ^~~~
    src/esphome/components/ble_client/ble_client.cpp:261:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (length > 3) {
    ^~
    src/esphome/components/ble_client/ble_client.cpp:264:5: note: here
    case 0x8: // uint32.
    ^~~~
    src/esphome/components/ble_client/ble_client.cpp:265:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (length > 4) {
    ^~
    src/esphome/components/ble_client/ble_client.cpp:269:5: note: here
    case 0xC: // int8.
    ^~~~
    src/esphome/components/ble_client/ble_client.cpp:273:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (length > 2) {
    ^~
    src/esphome/components/ble_client/ble_client.cpp:276:5: note: here
    case 0xF: // int24.
    ^~~~
    src/esphome/components/ble_client/ble_client.cpp:277:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (length > 3) {
    ^~
    src/esphome/components/ble_client/ble_client.cpp:280:5: note: here
    case 0x10: // int32.
    ^~~~
    Compiling .pioenvs\neey-bal2\src\esphome\components\heltec_balancer_ble\button\heltec_button.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\heltec_balancer_ble\heltec_balancer_ble.o
    Compiling .pioenvs\neey-bal2\src\esphome\components\heltec_balancer_ble\number\heltec_number.o
    src/esphome/components/heltec_balancer_ble/heltec_balancer_ble.cpp: In member function 'virtual void esphome::heltec_balancer_ble::HeltecBalancerBle::gattc_event_handler(esp_gattc_cb_event_t, esp_gatt_if_t, esp_ble_gattc_cb_param_t*)':
    src/esphome/components/heltec_balancer_ble/heltec_balancer_ble.cpp:179:71: error: 'class esphome::ble_client::BLEClient' has no member named 'get_gattc_if'; did you mean 'gattc_if'?
    auto status = esp_ble_gattc_register_for_notify(this->parent()->get_gattc_if(), this->parent()->get_remote_bda(),
    ^~~~~~~~~~~~
    gattc_if
    src/esphome/components/heltec_balancer_ble/heltec_balancer_ble.cpp:179:103: error: 'class esphome::ble_client::BLEClient' has no member named 'get_remote_bda'; did you mean 'remote_bda'?
    auto status = esp_ble_gattc_register_for_notify(this->parent()->get_gattc_if(), this->parent()->get_remote_bda(),
    ^~~~~~~~~~~~~~
    remote_bda
    src/esphome/components/heltec_balancer_ble/heltec_balancer_ble.cpp: In member function 'bool esphome::heltec_balancer_ble::HeltecBalancerBle::send_command(uint8_t, uint8_t, uint8_t, uint32_t)':
    src/esphome/components/heltec_balancer_ble/heltec_balancer_ble.cpp:816:47: error: 'class esphome::ble_client::BLEClient' has no member named 'get_gattc_if'; did you mean 'gattc_if'?
    esp_ble_gattc_write_char(this->parent_->get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
    ^~~~~~~~~~~~
    gattc_if
    src/esphome/components/heltec_balancer_ble/heltec_balancer_ble.cpp:816:78: error: 'class esphome::ble_client::BLEClient' has no member named 'get_conn_id'; did you mean 'conn_id'?
    esp_ble_gattc_write_char(this->parent_->get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
    ^~~~~~~~~~~
    conn_id
    *** [.pioenvs\neey-bal2\src\esphome\components\heltec_balancer_ble\heltec_balancer_ble.o] Error 1
    ============================================= [FAILED] Took 36.63 seconds =============================================

C:\tools\neey-ball2>

Have any ideea about this error's ?

Thank you,
Cristi

@syssi
Copy link
Owner Author

syssi commented Oct 12, 2022

Please update ESPHome. Version 2022.9.3 is required as minimum.

@cristi2005
Copy link

Thank you, working now.

@chfink0
Copy link

chfink0 commented Jan 15, 2023

Hey guys, first of all, thank you very much for this integration. Does this work with multiple Balancers? I do have 5 of them :-)

Thank you in advance!

@syssi
Copy link
Owner Author

syssi commented Jan 15, 2023

A single ESP32 is limited to 3 simultaneous BLE connections. See https://esphome.io/components/ble_client.html

@chfink0
Copy link

chfink0 commented Jan 15, 2023

Ok cool. Thank you. So I could just take two of the ESP32 boards I guess. But where can I set the 2nd and 3rd mac adress? Thank you!!

@syssi
Copy link
Owner Author

syssi commented Jan 15, 2023

Take a look at this JK-BMS example: https://github.com/syssi/esphome-jk-bms/blob/main/esp32-ble-example-multiple-devices.yaml#L54-L87

You have to add multiple BLE Clients blocks to the YAML and load the custom component multiple times. Please keep in mind the example above is for the JK-BMS. You have to replicate the pattern/schema for the balancer example.

@chfink0
Copy link

chfink0 commented Jan 15, 2023

Excellent, seems doable, thank you very much!

Repository owner deleted a comment from dossidr Feb 11, 2023
@oguzatagan
Copy link

hi everyone. im using home assistant OS on rasp. pi 3. can i connect with bluetooth direct rasppi to neey balancer without esp32. sorry bad English.

@syssi
Copy link
Owner Author

syssi commented Apr 7, 2023

This implementation/project requires a ESP32. I'm not aware of other (Linux based) projects supporting the device.

@oguzatagan
Copy link

This implementation/project requires a ESP32. I'm not aware of other (Linux based) projects supporting the device.

you are perfect. but raspberry pi have a bluetooth. I asked because I was wondering if it could be done without the need for other hardware.

@syssi
Copy link
Owner Author

syssi commented Apr 7, 2023

This implementation requires ESPHome / a ESP32 device as foundation. It cannot be ported to Linux / a Raspberry Pi easily.

@syssi
Copy link
Owner Author

syssi commented Oct 29, 2023

[16:11:46][I][heltec_balancer_ble:425]:   Model: GW-24S4EB
[16:11:46][I][heltec_balancer_ble:427]:   Hardware version: HW-2.8.0
[16:11:46][I][heltec_balancer_ble:429]:   Hardware version: ZH-1.2.3
[16:11:46][I][heltec_balancer_ble:431]:   Protocol version: V1.0.0
[16:11:46][I][heltec_balancer_ble:433]:   Protocol version: 20220531

@oguzatagan
Copy link

Same problem. Sometimes after the reboot or electricity disconnect, device connection ok but data is unavailable

@syssi syssi removed the help wanted Extra attention is needed label Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants