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

Not working with ESP32 2.05 bluetooth #2

Open
darrylb123 opened this issue Oct 17, 2022 · 5 comments
Open

Not working with ESP32 2.05 bluetooth #2

darrylb123 opened this issue Oct 17, 2022 · 5 comments

Comments

@darrylb123
Copy link

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
Copy link
Author

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.

@Lupo135
Copy link

Lupo135 commented Oct 25, 2022

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.

@darrylb123
Copy link
Author

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.

@MahmoudiNawel
Copy link

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

@Lupo135
Copy link

Lupo135 commented Nov 14, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants