Closed davet2001 closed 4 years ago
It has been a long time since I have looked at this code - it has just be running quietly and getting on with its job for the last few years. And even then most of it was cobbled together from energenie examples.
I'll try and take a look at the weekend if I get a chance, but at the moment I think you are way ahead of me in your understanding.
In principal, this is what you would need to do
Add a case entry to the switch statement in dev_HRF.c line 516 to handle the new message parameter (it has an id of 0x73 from the debug you pasted) Add a case entry in the switch statement id dev_HRF.c line 560 to handle the data of the new message type Add an if statement in engMQTTClient.c (about line 984) to generate an MQTT message from the received message.
There is probably something I have missed, but that should serve as a starting point. Let me know how you get on.
I'm trying to add support for a MIHO005 switchable socket (the kind with the purple button on the front). It should be able to switch on and off remotely, and also report power/current measurements.
The question is what is the best strategy for adding support for this within the engMQTTClient project.
I see that the while(1) loop in engMQTTClient.c is looking for FSK messages coming from a specific device ID via the call:
HRF_receive_FSK_msg(encryptId, eTRVProductId, engManufacturerId, &msgData );
So if i want to listen to more than one type of device, what is the best way to do this? Should I expand the scope of HRF_receive_FSK_msg() to be able to look out for more than one type of message, or should I make multiple calls to HRF_receive_FSK_msg() with different product ID parameters each time?
For info, when I cheat the system by changing the value of the constant eTRVProductId from 0x3 to 0x2, the sort of output I get is like this:
stderr] 20190801 21:12:53.793 NOTICE MQTTClient- Received message [stderr] 20190801 21:12:53.793 NOTICE MQTTClient- SensorId=9398 Battery Voltage 246 [stderr] 20190801 21:13:03.766 DEBUG hrf- Receiving Message 60 [stderr] 20190801 21:13:03.766 DEBUG hrf- ManufacturerID=0x4 [stderr] 20190801 21:13:03.766 DEBUG hrf- ProductID=0x2 [stderr] 20190801 21:13:03.766 DEBUG hrf- SensorID=0x0024b6 [stderr] 20190801 21:13:03.766 DEBUG hrf- ParameterID=Power [stderr] 20190801 21:13:03.766 ERROR hrf- Don't understand OpenThings message 0x70 [stderr] 20190801 21:13:03.766 DEBUG hrf- ParameterID=Reactive_P [stderr] 20190801 21:13:03.766 ERROR hrf- Don't understand OpenThings message 0x71 [stderr] 20190801 21:13:03.766 DEBUG hrf- ParameterID=Voltage [stderr] 20190801 21:13:03.766 DEBUG hrf- value=246 [stderr] 20190801 21:13:03.766 DEBUG hrf- ParameterID=Frequency [stderr] 20190801 21:13:03.766 ERROR hrf- Don't understand OpenThings message 0x66 [stderr] 20190801 21:13:03.766 DEBUG hrf- ParameterID=Switch_state [stderr] 20190801 21:13:03.766 ERROR hrf- Don't understand OpenThings message 0x73 [stderr] 20190801 21:13:03.766 DEBUG hrf- ParameterID=CRC [stderr] 20190801 21:13:03.766 DEBUG hrf- CRC OK
Overall, I think it's understanding quite a lot of the data coming from the MIHO005. I'm just not sure how to turn the code into something that can handle more than just eTRVs. Advice welcome!