bvenneker / Chat64

C64 Chat Cartridge, 2023
GNU General Public License v3.0
13 stars 2 forks source link

Splitted the ino file into multiple files to isolate wifi on single core #11

Closed heneault closed 2 months ago

heneault commented 2 months ago

I splitted the ino file into multiple files to highlight what is running on each core. Only the wifi_core.ino is now using the wifi library. The main program is running on the app code and communicates by sending messages to the wifi core. The app core also handles the remaining operations (c64 communication, read/write settings,...)

The goal of this is to eventually support the pi core which allows only wifi code on the core 0. However, this PR will help to avoid possible race conditions in the esp32 wifi library like trying to read messages from one core while the other is trying to reconnect to the wifi/server with a new setting at the same time.

I didn’t change the logic at all for the moment. Only the first few lines of the wifi core have been updated to take into account the split. Also, the last_up_refresh and refreshUserPages variables have been scoped only where they are used. Everything else is like before.

Eventually to reduce complexity we could lower the number of shared variables and replace them with arguments specific to each message.

bvenneker commented 2 months ago

I am closing this pull request. I want to implement your changes to the beta branch but I've already made a lot of changes there. So I have reviewed and replicated the changes manually in my local files from the beta branch and will commit those changes to the beta branch next.