matth-x / MicroOcpp

OCPP 1.6 client for microcontrollers
MIT License
332 stars 143 forks source link

Platform.h #177

Open pamukcu09 opened 1 year ago

pamukcu09 commented 1 year ago

Hi @matth-x ,

I am trying to compile this project in STM32CubeIDE environment. However, I get a compilation error because it does not contain the arduino.h in the platform.h file. What should I define MOCPP_PLATFORM as?

matth-x commented 1 year ago

Hi @pamukcu09, the best start is MOCPP_PLATFORM=MOCPP_PLATFORM_UNIX. Probably you also need to add MOCPP_CUSTOM_TIMER which removes the dependency on the <chrono> library. Feedback about further compilation issues is highly appreciated.

pamukcu09 commented 1 year ago

Thank you for your reply @matth-x

-I started with the definition MOCPP_PLATFORM=MOCPP_PLATFORM_UNIX and also defined MOCPP_CUSTOM_TIMER.

-Then I started getting the error that the dirent.h file is not supported.

https://github.com/armink/FreeModbus_Slave-Master-RTT-STM32/blob/master/RT-Thread-1.2.2/components/libc/newlib/sys/dirent.h -I replaced the dirent.h file in the link with the file in the project, and I also included other dependencies in the library ( rtthread.h etc.)

-This way I got an error-free build in the STM32CUBEIDE environment. I have already integrated mongoose library and arduinoJson libraries before. I will try to connect to the OCPP server by integrating an ethernet connection as well.

matth-x commented 1 year ago

Thanks for sharing your results and congrats on the successful build! Would be curious about what's finally necessary for the full port. Can you imagine to add an MOCPP_PLATFORM_STM32 section to the Platform.h and create a PR?

Before running into trouble with the filesystem, you could deactivate it for the moment by adding MOCPP_USE_FILEAPI=DISABLE_FS. It's not super important for a proof of concept.

At runtime, the OCPP lib will also need the clock. It reads the clock using a callback function which is set using this function:

https://github.com/matth-x/MicroOcpp/blob/99a0925a2202476e7539d1a3c8f07e3c267975ba/src/MicroOcpp/Platform.h#L68

get_ms needs to be a function which returns the milliseconds since start.

pamukcu09 commented 1 year ago

After making sure that I did everything right, it would be great to add the MOCPP_PLATFORM_STM32 section.
I will continue to try to establish the OCPP connection based on your suggestions . I will share the results with you. Thank you again.