kolinger / skyrc-mc3000

Simple application for monitoring SkyRC MC3000 charger over BLE/Bluetooth and for import/export of profiles over USB
GNU General Public License v3.0
22 stars 1 forks source link

Can't connect to MC3000, FW1.15 #1

Closed ilgrank closed 7 months ago

ilgrank commented 8 months ago

Hi Just read some of your posts on BLF (https://budgetlightforum.com/t/skyrc-mc3000-help-thread/51269/93?page=5) and wanted to try your software :) Alas, even tho I can see a "Simple BLE Peripheral" with other softwares, yours remains in "Scanning... This can take a while..." Running Windows 10 22H2 btw I know it is not much help in trying to understand what's going on.. is there a way to enable debugging maybe? Thanks for your effort!

kolinger commented 8 months ago

Hi, if you are stuck in scanning for more than few minutes than something is wrong with this application, at this stage it has nothing to do with the charger yet, the app should say nothing found or something found, if it's just stuck then it's bug.

Do you see something suspicious in the log? You can find log files at this location C:\Users\YOUR_USERNAME\AppData\Local\mc3000ble\log\, in this directory you should see info.log file(s).

BTW: I don't post on BLF - those aren't my posts.

ilgrank commented 7 months ago

Hi Thanks for your reply alas, my info.log is 0 bytes Is there anything I can try? (I've tried so far disabling the antivirus and firewall, and running as admin,but to no avail)

and sorry, you're right about BLF: the poster actually wrote "my custom mc3000ble.py"

kolinger commented 7 months ago

I updated underlying Bluetooth library - this could lead to improved error reporting. I also added more logging so info.log should say at least something now.

Please try latest release and look at info.log again.

ilgrank commented 7 months ago

Hi Thanks for the updated build! I now have data in the log:

2024-02-09 11:14:02,842 - INFO - starting
2024-02-09 11:14:05,504 - INFO - scanning started
2024-02-09 11:14:10,561 - INFO - scanning done
2024-02-09 11:15:01,034 - INFO - starting
2024-02-09 11:15:02,415 - INFO - scanning started
2024-02-09 11:15:07,478 - INFO - scanning done

but it seems it is finding nothing. Other softwares, like Windows Bluetooth cpl, do find a SimpleBLE Peripheral tho:

image

kolinger commented 7 months ago

SimpleBLE Peripheral is not MC3000 as far as I know. My MC3000 presents itself as "Charger", I suppose it can be different for different years of production but SimpleBLE Peripheral doesn't look like it for sure.

Seems like you don't see MC3000 at all, make sure Bluetooth is enabled in SETUP of MC3000 and try to close the distance to charger, Bluetooth can have surprising short range in less ideal environments with interference.

There is a bug - app should say nothing found I will look into that but that will not solve your issue with connection, that will only fix the message so it says nothing found. If something is found then you will see Bluetooth addresses with name in brackets.

kolinger commented 7 months ago

I fixed the message now it should show nothing found when nothing is found. There was also error in scanning where devices without name didn't show. I also found some shortcomings in error handling where some errors could escape log - please try latest release - now everything should be logged and scanning shall return some result.

ilgrank commented 7 months ago

Maybe showing as "SimpleBLEPeripheral" is related to my HW version of MC3000, but I can assure you I can connect to it using both DataExplorer and with the native Android App. (Which, btw, is running on an android emulator on the same windows machine that discovers the "SimpleBLEPeripheral")

ilgrank commented 7 months ago

Wow! detection is working with the Alpha5! image and it is connecting too!: image

kolinger commented 7 months ago

Funny they did release MC3000 with some default Bluetooth name, very professional!

I guess it was failing due to the one unknown device bellow it. Thanks for reporting!

ilgrank commented 7 months ago

thanks to you! :) Do you plan to implement altering values in the future too?

kolinger commented 7 months ago

I would like to since I hate to manage all the profiles on charger itself, it's lot of leg work to setup with the simple button interface. It's real pain to do everything again when firmware upgrade wipes everything. If I could do all the profiles on PC, export and import, that would be the last missing feature of this amazing charger.

The problem is that all the SkyRC apps released don't alter profiles they just replace current selected profile and that's useless for me since it doesn't alter the profiles in charger itself thus then I can't switch to these profiles on charger. This is deal breaker for me. I would like to modify profiles on PC so I can use them on charger when I load batteries without PC and not to always select everything on PC.

I'm not sure if even Bluetooth interface of MC3000 allows to modify the internal profiles, if it's even possible. In any case I would need working example so I can sniff and reverse engineer the communication as I did with monitoring but the official apps don't do it so I have no way of knowing what are the commands/addresses/API. I would be even better if someone already did reverse engineering of the protocol so I can just implement it but I don't know of anything like that.

I'm not sure if this is correct but was at least years ago. Please correct me if I'm wrong but there is no app that can do this including the apps from SkyRC. If there is a way I would make it for sure. If there is only what the SkyRC apps do then I don't see the point since then charger would required PC to function and that's downgrade for me.

ilgrank commented 7 months ago

I totally agree on your point, abut perhaps I have good news: the SkyRC protocol has already been reverse engineered some time ago, and the full source is available: https://github.com/gitGNU/gnu_dataexplorer/blob/master/SkyRC/src/gde/device/skyrc/MC3000.java Now while the implementation is java, the protocol seems to be simple enough Data Explorer already allows controlling the MC3000 btw, but it is really not a good implementation as DEX is more meant to visualize data rather than controlling the charger

kolinger commented 7 months ago

I have no idea how to use this Data Explorer....

image

This doesn't allow to read existing profile? If I press read then it reads only currently selected profile not the one stored in charger under specified number. Do you know how do I read specific stored profile from charger?

This is something I would need to make it much more useful - show and modify specific profile number under specific slot stored inside of charger. Not what the SkyRC apps are doing - they have their own local profiles they upload to charger on demand - that's useless. I have no idea how to do it with Data Explorer, Toolbox doesn't seem to do it at first.

If only current profile of slot can be read and changed then it's much less useful, I guess it's still better than nothing. Not sure if all the amount of work is justified for such limited functionality. My original idea was that I would click button and application would create backup file of all profiles and then it would be possible to upload all profiles back or modify them. Current profile only would allow you to still export/modify/import but only one profile at a time.

What was your idea anyway? What would you want to see implemented specifically?

ilgrank commented 7 months ago

Hi I've not used Data Explorer in .. 5 years maybe, so I don't recall exactly, but if memory serves me well, you're right: it can only upload one config, per slot, at a time, much in the same way as the SkyRC Android app can do. The PC App is even more limited than the Android app, so having a modern app that can save (locally) several profiles and apply them to the charger would be a godsend. the MC3000 is still, today, one of the best multipurpose chargers on the marked, and It's held back only by the lack of proper software and a very difficult local user interface. Having the possibility to send different configurations to each slot, choosing from a local library, would be great. Having the chance to have these profiles exportable (XML or JSON) and having them e.g. on Github, where people could collaborate on making them even better, would be .. well, great :) I'm just dreaming, I know, but you've proven it is at least a possibility, thanks :)

kolinger commented 7 months ago

I did look into it briefly and Bluetooth interface is pretty much different thing than the USB interface. I tried command from Data Explorer and charger doesn't respond, the format is different, I adapted the format so it was in Bluetooth form and charger didn't respond either. If I look at Android app then there is no mention of such command that Data Explorer uses for the slot settings. Some commands are the same, like the command for obtaining status of slot but others aren't and the specific one for obtaining current slot settings doesn't work.

Android app never reads out the slot settings. It has local settings that it pushes to charger on command. So I guess there is no way to read settings over Bluetooth? It was never implemented in Android app and thus no command for it exists either? That would make sense. I remember this know from the past and that's why I never bothered to do more. I assumed PC app was the same but it looks it isn't?

Thus as far as I see proper export/import of all profiles is impossible over any interface. Export/import over Bluetooth is also impossible - only import of current slot is possible. That's a shame - it would be easy for SkyRC to implement proper export/import support but they just don't care.

Current profile export/import could be done only via USB. Official Windows app can load and save current profile and Data Explorer implements this somehow but I don't know how to use it. I guess Data Explorer it's just not mean for this so it's implemented in obscure way that fit into Data Explorer abilities.

This very much limits what I can make. Export/import of current profile via USB is still better than nothing but it could be so much better only if SkyRC did little bit more work on their part.

BTW: I tried to sends all possible commands over Bluetooth and didn't find anything that Android app doesn't use but I found factory reset so now my MC3000 is blank again! Now the import would be very useful indeed :D

BTW2: those are valid MC3000 Bluetooth names from official Android app:

public static final String BLUETOOTHNAME1 = "SimpleBLEPeripheral";
public static final String BLUETOOTHNAME2 = "Charger";
public static final String BLUETOOTHNAME3 = "HitecCharger";

Look like you have first generation of MC3000 and I second? Maybe!

kolinger commented 7 months ago

I can confirm export/import of current settings of each slots works over USB. I did make it work in Data Explorer also, documentation was required, the UI is very much not intuitive but after reading the documentation I got it working eventually.

I will try to port the current profile code from Data Explorer and make some kind of export/import from it soon.

EDIT: Result from today is MC3000 Profiles application included in version 2.0.0-alfa, see readme for details.

ilgrank commented 7 months ago

Well Kolinger.. you did a huge amount of work in such a short time.. thanks! Alas, what you have found is not good news, but as you say, if the implementation by SKYRC is just half-backed there's only so much that can be done. I know a group of BLE experts: I suspect that given the low power of the internal MCU, the communication is done in cleartext.. maybe there is hope (by dumping the BLE traffic) still to reverse engineer the communication between the MC3000 and the android app.. who knows? I'll keep you updated on my discoveries tooo.. meanwhile, thansk again for your great work!

kolinger commented 7 months ago

There is easier way with Android - just read the source code. Jadx decompiler does very good job at decompiling regular .apk files/java bytecode, then you can literally see anything what Android app can ever do and thus there is no need to see communication itself. I wouldn't hope that new discoveries are made here, even if we see the BLE communication perfectly, it will not change the fact that the Android app doesn't use the interesting functions - thus there is nothing to see in the first place.

USB seems like the superior interface of MC3000 and I don't think we can do anything about that unless there is new firmware.

Although I'm fairly happy with current state. I never wished to control MC3000 wirelessly, I don't see the value in that since I need to put the batteries into charger anyway and then I can press few buttons as well. I was always interested in seeing the status and notifications wirelessly and that's what MC3000 BLE can do already. The fact that I need USB for export/import it's totally fine since that's not something I will do often compared to monitoring of the status so wired solution is acceptable. Perhaps other people use MC3000 differently - I use it for charging most of the time so my scope could be different to others. I don't use logging and there are others projects for that anyway. So as it is it's quite alright.