mpp-solar: JK-B1A20S15P not working, JK-B2A24S20P works well. Seems like some init commands should be reverse engineered

Hi

Trying

mpp-solar -p 20:21:11:28:15:EF -P JK02 -c getCellData --tag solar/lutsk/jkbms100 -q 127.0.0.0 -o mqtt

And getting

Traceback (most recent call last):
  File "/usr/local/bin/mpp-solar", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/mppsolar/__init__.py", line 417, in main
    results = _device.run_command(command=_command)
  File "/usr/local/lib/python3.10/dist-packages/mppsolar/devices/device.py", line 316, in run_command
    raw_response = self._port.send_and_receive(
  File "/usr/local/lib/python3.10/dist-packages/mppsolar/inout/jkbleio.py", line 37, in send_and_receive
    response = self.ble_get_data(full_command)
  File "/usr/local/lib/python3.10/dist-packages/mppsolar/inout/jkbleio.py", line 88, in ble_get_data
    serviceId = self._device.getServiceByUUID(btle.AssignedNumbers.genericAccess)
  File "/usr/local/lib/python3.10/dist-packages/bluepy/btle.py", line 490, in getServiceByUUID
    raise BTLEGattError("Service %s not found" % (uuid.getCommonName()), rsp)
bluepy.btle.BTLEGattError: Service Generic Access not found

Next to it JK-B2A24S20P works well

Sysinfo

root@metrics:/var/lib/bluetooth# mpp-solar --version
Solar Device Command Utility, version: 0.14.1
root@metrics:/var/lib/bluetooth# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy

Any suggestion how to fix it?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Playing around with the above (using the construct library to try to determine what bytes equal what result), i get a pretty good match up

Container: 
    header = b'U\xaa\xeb\x90' (total 4)
    Record_Type = 2
    Record_Counter = 193
    cell_voltage_array = ListContainer: 
        3244
        3245
        3246
        3249
        3249
        3250
        3246
        3246
        [snip empty cell data]
    discard1 = b'\xff\x00\x00\x00' (total 4)
    Average_Cell_Voltage = 3248
    Delta_Cell_Voltage = 7
    Current_Balancer = 3
    cell_resistance_array = ListContainer: 
        56
        57
        56
        56
        56
        56
        55
        56
       [snip empty cell data]
    mos_temp = 226
    discard3 = b'\x00\x00\x00\x00' (total 4)
    battery_voltage = 25985
    battery_power = 424079
    battery_current = 16320
    T2 = 192
    T3 = 190
    balance_current = 0
    discard9 = b'\x00\x00\x00' (total 3)
    Percent_Remain = 9
    Capacity_Remain = 25279
    Nominal_Capacity = 280000
    Cycle_Count = 11
    Cycle_Capacity = 3280276
    discard7 = b'd\x00\x00\x00' (total 4)
    uptime = 3194094
    discard8 = b'\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'... (truncated, total 24)
    rest = b'\x03P\x00\x00\x00\xca\xfa@@\x00\x00\x00\x00&\n\x85'... (truncated, total 79)

(ignore the need to /1000 or /10 for some of these numbers)

this is using:

jk02_32_definition = cs.Struct(
    "header" / cs.Bytes(4),
    "Record_Type" / cs.Byte,
    "Record_Counter" / cs.Byte,
    "cell_voltage_array" / cs.Array(32, cs.Int16ul),
    "discard1" / cs.Bytes(4),
    "Average_Cell_Voltage" / cs.Int16ul,
    "Delta_Cell_Voltage" / cs.Int16ul,
    "Current_Balancer" / cs.Int16ul,
    "cell_resistance_array" / cs.Array(32, cs.Int16ul),
    "mos_temp" / cs.Int16ul,
    "discard3" / cs.Bytes(4),
    "battery_voltage" / cs.Int32ul,
    "battery_power" / cs.Int32ul,
    "battery_current" / cs.Int32sl,
    "T2" / cs.Int16ul,
    "T3" / cs.Int16ul,
    "balance_current" / cs.Int32sl,
    "discard9" /  cs.Bytes(3),  # discard of 3 bytes seems wrong
    "Percent_Remain" / cs.Int8ul,
    "Capacity_Remain" / cs.Int32ul,
    "Nominal_Capacity" / cs.Int32ul,
    "Cycle_Count" / cs.Int32ul,
    "Cycle_Capacity" / cs.Int32ul,
    "discard7" / cs.Bytes(4),
    "uptime" / cs.Int24ul,
    "discard8" / cs.Bytes(24),
    "rest" / cs.GreedyBytes
)

there are some obvious gaps / possible mistakes Do you have another seet of data - perhaps with balancing turned on?