ESP32_to_SMA icon indicating copy to clipboard operation
ESP32_to_SMA copied to clipboard

Not working with ESP32 2.05 bluetooth

Open darrylb123 opened this issue 3 years ago • 5 comments

Problem 1: Fail to connect Bluetooth connect seems to need the name or the MAC with additional arguments esp_spp_sec_t sec_mask=ESP_SPP_SEC_NONE; // or ESP_SPP_SEC_ENCRYPT|ESP_SPP_SEC_AUTHENTICATE to request pincode confirmation esp_spp_role_t role=ESP_SPP_ROLE_SLAVE; // or ESP_SPP_ROLE_MASTER
connected = SerialBT.connect(address,0,sec_mask,role);

Problem 2: Returned MAC address is reversed I have to reverse the order of the check bool ValidateSenderAddress() { // Compares the SMA inverter address to the "from" address contained in the message. // Debug prints "P wrng dest" if there is no match. return (Level1SrcAdd[5]==smaBTInverterAddressArray[0] && Level1SrcAdd[4]==smaBTInverterAddressArray[1] && Level1SrcAdd[3]==smaBTInverterAddressArray[2] && Level1SrcAdd[2]==smaBTInverterAddressArray[3] && Level1SrcAdd[1]==smaBTInverterAddressArray[4] && Level1SrcAdd[0]==smaBTInverterAddressArray[5]); }

Nothing happens from there on.

darrylb123 avatar Oct 17 '22 05:10 darrylb123

Recompiled with fresh repo using ESP32 1.0.6 Bluetooth connection works, my SMA (5000TL) bluetooth MAC addressed still reversed. Nothing more happens when I reverse the array.

darrylb123 avatar Oct 17 '22 06:10 darrylb123

Problem 2: I solved the problem with the reversed Mac in the bluetooth.h file by filling the smaBTInverterAddressArray[6] and myBTAddress[6] in the reverse order e.g.={ 5,4,3,2,1,0}

Problem 3: There is a failure in the SMAInverterPasscode[] encryption in file ESP32_to_SMA.ino. The modulo operator (% 0xff) is wrong. All characers above 'w' are wrong encrypted. //writeSMANET2SingleByte(level1packet,(v + 0x88) % 0xff); <= wrong writeSMANET2SingleByte(level1packet,(v + 0x88)); <= correct

Status: Since today, after some more corrections, I can logon to my SMC6000TL and read the current power and date (getInstantACPower). There are still a lot of problems on e.g. receive multi packet. Currently I'm porting some routines from SBFspot to this code.

Lupo135 avatar Oct 25 '22 17:10 Lupo135

That is very good. I currently use SBFSpot on a RPi. I looked at the sbfspot code and was wondering how difficult it is to port pure C++ to arduino. I would be happy to assist your efforts. Have you forked the repository? In the end, I want to upload to PVOutput so a lot of the code that was removed would have to go back.I also want to publish via mqtt.

darrylb123 avatar Oct 26 '22 03:10 darrylb123

Problem 1 : always fail to connect and i don't know why i chnaged mac adrees but no result : fail to connect please help

MahmoudiNawel avatar Nov 03 '22 09:11 MahmoudiNawel

There is a first draft of my port from SBFspot to ESP32 on the project "ESP32_SMA-Inverter" on github. This works on my SMA SMC6000TL with a plugin SMA bluetooth module.

Lupo135 avatar Nov 14 '22 16:11 Lupo135