Open tvan0076 opened 4 months ago
Looks like Shunt works differently, characteristic_enable_notifications_failed is not a good sign. Is this the same response you get everytime?
Only way you can figure out the register values is by doing bluetooth snooping. You have to enable Bluetooth HCI snoop in android phone while using dc home app and open the file using wireshark (read).
I have created the snoop file with iOS and XCode. Would you be open to looking at it to see what might need to be done to add the shunt to your program? If so, how should I send it. It has too much private info to add to the thread.
Here is the ATT Attributes:
I briefly looked into it. Unfortunately the data sent back from Shunt looks very different from rest of the devices. There are some patterns but it will be really difficult to figure out the whole story without an actual device.
Can you let me know what do you see when using this branch shunt?
Use device type RNG_SHUNT
The first output was this: INFO:root:Init SmartShuntClient: RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx] INFO:root:Adapter status - Powered: True INFO:root:Starting discovery... INFO:root:Devices found: 21 INFO:root:Found matching device RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx] INFO:root:[xx:xx:xx:xx:xx:xx] Connected INFO:root:[xx:xx:xx:xx:xx:xx] Resolved services ERROR:dbus.connection:Exception in handler for D-Bus signal: Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/dbus/connection.py", line 218, in maybe_handle_message self._handler(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/gatt/gatt_linux.py", line 398, in properties_changed self.services_resolved() File "/home/pi/renogy-bt-main/renogybt/BLE.py", line 73, in services_resolved self.resolved_callback() File "/home/pi/renogy-bt-main/renogybt/BaseClient.py", line 58, in __on_resolved self.poll_data() if self.config['data'].getboolean('enable_polling') == True else self.read_section() File "/home/pi/renogy-bt-main/renogybt/BaseClient.py", line 105, in read_section request = self.create_generic_read_request(self.device_id, 3, self.sections[index]['register'], self.sections[index]['words']) TypeError: create_generic_read_request() takes 1 positional argument but 5 were given INFO:root:characteristic_enable_notifications_failed
After the first output I kept getting this: INFO:root:Init SmartShuntClient: RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx] INFO:root:Adapter status - Powered: True INFO:root:Starting discovery... INFO:root:Devices found: 21 INFO:root:Found matching device RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx] INFO:root:[xx:xx:xx:xx:xx:xx] Connected INFO:root:[xx:xx:xx:xx:xx:xx] Resolved services ERROR:root:Exception occured: create_generic_read_request() takes 1 positional argument but 5 were given
I hope this helps.
Updated, please check again.
Doo you always get this error characteristic_enable_notifications_failed
?
The test above I didn't get the characteristic_enable_notifications_failed. I don't think it made it that far.
Updated test I get this: INFO:root:Init SmartShuntClient: RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx] INFO:root:Adapter status - Powered: True INFO:root:Starting discovery... INFO:root:Devices found: 15 INFO:root:Found matching device RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx] INFO:root:[xx:xx:xx:xx:xx:xx] Connected INFO:root:[xx:xx:xx:xx:xx:xx] Resolved services INFO:root:subscribed to notification 0000fff1-0000-1000-8000-00805f9b34fb INFO:root:found write characteristic 0000ffd1-0000-1000-8000-00805f9b34fb INFO:root:resolved services INFO:root:characteristic_enable_notifications_failed INFO:root:characteristic_write_value_succeeded ERROR:root:on_read_timeout => please check your device_id! INFO:root:Exit: Disconnecting device: RTMShunt30053001400 [xx:xx:xx:xx:xx:xx]
That means the shunt has totally different ble characteristics. You might have to use a ble scanner app to figure out which one is write characteristic and which one is notification and update in BaseClient
Here is the output for both the controller and the shunt. The shunt doesn't use the subscribed to notification like the controller. Device (new): xx.xx.xx.xx.xx.xx (public), -36 dBm Flags: <06> Incomplete 16b Services: <0000ffd0-0000-1000-8000-00805f9b34fb> Manufacturer: <6cb2fd859e6a> Tx Power: <00> Complete Local Name: 'BT-TH-FD859E6A ' Device (new): xx.xx.xx.xx.xx.xx (public), -30 dBm Flags: <06> Manufacturer: <4ce1744c9298001e0001> Appearance: <0000> Tx Power: <00> Complete Local Name: 'RTMShunt30053001400'
I tried running sensortag --all xx.xx.xx.xx.xx.xx and I got this back: raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp) bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral xx.xx.xx.xx.xx.xx, addr type: public
sudo gatttool -b xx:xx:xx:xx:xx:xx -I [xx:xx:xx:xx:xx:xx][LE]> connect Attempting to connect to xx.xx.xx.xx.xx.xx Error: connect: Connection refused (111)
I sent pic of the BLE scanner to the email address above. Lots of good data :-)
My Renogy Rover 60A works like a champ! I thought I would try to use the same code for the Renogy Shunt 300 with Bluetooth, but that didn't work so well :-( It doesn't like the request payload.
DEBUG:root:create_request_payload 5000 => [33, 3, 19, 136, 0, 17, 6, 8]
I used the RNG_BATT in hopes they were close, but I guess not. I tried many device_IDs but couldn't get it to read.
Output Data: INFO:root:Init BatteryClient: RTMShunt300xxxxxxxx => xx:xx:xx:xx:xx:xx INFO:root:Adapter status - Powered: True INFO:root:Starting discovery... INFO:root:Devices found: 55 INFO:root:Found matching device RTMShunt3005xxxxxxxx => [(xx:xx:xx:xx:xx:xx)] INFO:root:[xx:xx:xx:xx:xx:xx] Connected INFO:root:[xx:xx:xx:xx:xx:xx] Resolved services INFO:root:subscribed to notification 0000fff1-0000-1000-8000-00805f9b34fb INFO:root:found write characteristic 0000ffd1-0000-1000-8000-00805f9b34fb INFO:root:resolved services DEBUG:root:create_request_payload 5000 => [33, 3, 19, 136, 0, 17, 6, 8] INFO:root:characteristic_enable_notifications_failed INFO:root:characteristic_write_value_succeeded ERROR:root:on_read_timeout => please check your device_id! INFO:root:Exit: Disconnecting device: RTMShunt300xxxxxxxx [(xx:xx:xx:xx:xx:xx)]
Is there a way to get past this easily and pull/read the data from this device? Seems you already built the rest out. Maybe just the right data feeds and added parser. Happy to assist!
Is there a wireshark ish app for Bluetooth on RPie4? I am happy to assist if you are open to the idea.