MicroOcpp icon indicating copy to clipboard operation
MicroOcpp copied to clipboard

Platform.h

Open pamukcu09 opened this issue 2 years ago • 4 comments

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?

pamukcu09 avatar Aug 22 '23 14:08 pamukcu09

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.

matth-x avatar Aug 23 '23 12:08 matth-x

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.

pamukcu09 avatar Aug 23 '23 12:08 pamukcu09

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.

matth-x avatar Aug 23 '23 13:08 matth-x

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.

pamukcu09 avatar Aug 23 '23 13:08 pamukcu09