racka98 / PicoW-MQTT-C

Raspberry Pi Pico W using FreeRTOS & coreMQTT in C
10 stars 2 forks source link

MQTT_COMMAND_CONTEXTS_POOL_SIZE is undefined? #3

Open Molgaard78 opened 6 months ago

Molgaard78 commented 6 months ago

I am trying to build your project using VS Code and ran into a few issues.

For reference when I write a path below the name of my workspace folder is PicoMQTT.

To start off VSCode complained that it could not find mqttFilePaths.cmake and mqttAgentFilePaths.cmake. It will also complain about json-maker and tiny-json missing.

I solved all those issues by creating a subfolder called lib and ran the following commands inside the folder:

git submodule add https://github.com/FreeRTOS/coreMQTT.git
git submodule add https://github.com/FreeRTOS/coreMQTT-Agent.git
git submodule add https://github.com/rafagafe/json-maker.git
git submodule add https://github.com/rafagafe/tiny-json.git

I also added the following to CMakeList.txt in the workplace root folder:

# Set external lib locations
set(CORE_MQTT_AGENT_PATH ${CMAKE_CURRENT_LIST_DIR}/lib/coreMQTT-Agent)
set(CORE_MQTT_PATH ${CMAKE_CURRENT_LIST_DIR}/lib/coreMQTT)
set(JSON_MAKER_PATH ${CMAKE_CURRENT_LIST_DIR}/lib/json-maker)
set(TINY_JSON_PATH ${CMAKE_CURRENT_LIST_DIR}/lib/tiny-json)

I added the statements just prior where you are defining your config files.

Like so:

mqtt_issue

However:

When I try to build the project I get the error:

PicoMQTT\configs\CoreMQTT-Agent\freertos_command_pool.c:

'MQTT_COMMAND_CONTEXTS_POOL_SIZE' undeclared here (not in a function) GCC [LN 54, COL 49]

I can see the value is defined in PicoMQTT\configs\CoreMQTT\core_mqtt_config.h, so how come that the compile cannot find the file when compiling the project?

I could copy-paste the definition for MQTT_COMMAND_CONTEXTS_POOL_SIZE over, but then I get a range of other compiling issues, so it looks to me that there are a general cross-referencing issue going on that is not being handled.

racka98 commented 6 months ago

This project relies on the CMake extension for VSCode to build. I didn't update the README to show that you also need to define paths for all the other libs you mentioned. I have set all the paths on my CMake extension configuration.

Like so;

Screenshot 2024-02-16 190842
Molgaard78 commented 6 months ago

Well it is possible to make your setup a little more generic when using VS Code.

I installed the VS Code with pico-sdk support using the official guide.

So whenever I launch the Pico version of VS Code, then the PICO_SDK_PATH environment variable is already defined as part of launch of VS Code.

I also found out that the FREERTOS_KERNEL_PATH I was using pointed to a not up-to-date version, so that gave a few compiling errors.

I have added the FreeRTOS Kernel to my lib folder, and now my .vscode\settings.json contains the following addition:

    "cmake.configureEnvironment": {
        "CORE_MQTT_PATH": "${workspaceFolder}/lib/coreMQTT",
        "CORE_MQTT_AGENT_PATH": "${workspaceFolder}/lib/coreMQTT-Agent",
        "FREERTOS_KERNEL_PATH": "${workspaceFolder}/lib/FreeRTOS-Kernel",
        "JSON_MAKER_PATH": "${workspaceFolder}/lib/json-maker",
        "TINY_JSON_PATH" : "${workspaceFolder}/lib/tiny-json",
        "TWIN_THING_PICO_PATH" : "${workspaceFolder}/lib/twinThingPicoW"
    }

However building you project now gives me a lot of complains about configUSE_CORE_AFFINITY is not supported in single core FreeRTOS.

I guess that relates to configs/FreeRTOSConfig.h? :-)

Found that error a bit odd, since Raspberry Pico W does have a dual core CPU, so why does it talk about running on only one core? :-)

I thought the point of using FreeRTOS was to fully utilize the CPU.

racka98 commented 6 months ago

Looks like FreeRTOS was updated and something changed. Replace the FreeRTOSConfig.h in the project with one from the FreeRTOS repo

mmolbech commented 3 months ago

Looks like FreeRTOS was updated and something changed. Replace the FreeRTOSConfig.h in the project with one from the FreeRTOS repo

This is a bug in FreeRTOS they are fixing it - so it follow the normal naming