timo-schluessler / custom-hm-cc-rt-dn

Custom firmware for ELV Homematic HM-CC-RT-DN radiator thermostat. Includes fully working and compatible OTA bootloader.
BSD 2-Clause "Simplified" License
3 stars 1 forks source link

[question] Port to Medion/MAX! door/window contact #2

Open andyboeh opened 3 years ago

andyboeh commented 3 years ago

Hey,

I have a bunch of Medion-branded MAX! door/window contacts which - in contrast to the original MAX! door/window contacts - are based on STM8 and Si4431 ICs. I was looking into porting it myself when I found your work here, so I will happily base my work on yours.

When skipping through the code, I found a few things that aren't exactly obvious:

  1. What's the for-loop in main.c for / what are these magic numbers? https://github.com/timo-schluessler/custom-hm-cc-rt-dn/blob/89e1adb9f6d0dc0952e7739a34d18e2a0f516ebb/main.c#L53
  2. I suppose a port to STM8L052C6 should be doable with minor modifications, do you happen to know if there might be some road blocks (I'll have to rework the timeout handling as the LSE crystal is not populated).

Regards, Andreas

EDIT: I just disassembled one of the Medion MAX! radiator thermostats: Also STM8L052/Si4431-based. Cool, so I might be able to convert those to Homematic as well - only downside: The wall thermostats are Samsung-based and I don't want to replace the thermostats.

timo-schluessler commented 3 years ago

Hi,

I am glad to hear that this might be of any help to your project. Regarding your questions:

  1. This for loop is a leftover from some stack debugging. It fills the end of the SRAM area (where the stack lives) with the value 0x55. This helps me to quickly find the maximum size of the stack by checking how many 0x55‘s are left intact. You can safely drop these lines.
  2. I don‘t know any of the other STM8‘s and am also not very familiar with this line. But as all the peripherals in use are pretty standard I don‘t suspect any pitfalls.

Regards Timo

andyboeh commented 3 years ago

Thanks - this will be my summer project, I'll report back when I have something. I'm not familiar with the STM MCUs at all, but I do have quite some experience with other MCU families - let's see.

One more question: Does your implementation support direct associations between devices?

timo-schluessler commented 3 years ago

No, it does not. So far only OTA updates are fully implemented (and the underlying radio protocol which is working fine). Implementing specific commands and features should be straight forward. See for example https://github.com/trilu2000/NewAskSin how to implement peering. Good luck with your project - I am looking forward to hear about your progress.

andyboeh commented 3 years ago

I did some porting work and got the basics up and running: https://github.com/andyboeh/medion-hm-sec-sc

andyboeh commented 3 years ago

In case you are still working on your implementation: I did a few power consumption measurements and found a few occasions where the radio module is not reset to idle. I added a call to radio_write_reg(SI4430_OMFC1, 0); in radio_received() and in radio_sent() (everywhere you set radio_state = radio_idle), now the battery consumption is down to a few uA instead of 1.5mA.

Apart from that, the door/window contact implementation seems to be fairly complete now (periodic battery reporting is missing), including AES authentication and configuration. Peering is not supported.