get mqtt_client building
This commit is contained in:
parent
4b09a8611b
commit
d70d551638
5 changed files with 544 additions and 1 deletions
|
|
@ -41,3 +41,65 @@ target_link_libraries(wifi_scan
|
|||
)
|
||||
|
||||
pico_add_extra_outputs(wifi_scan)
|
||||
|
||||
|
||||
# Define the host name of the MQTT server in an environment variable or pass it to cmake,
|
||||
# e.g. cmake -DMQTT_SERVER=myserver ..
|
||||
|
||||
if ((NOT MQTT_SERVER) OR (NOT MQTT_USERNAME) OR (NOT MQTT_PASSWORD))
|
||||
message("Missing MQTT_SERVER or MQTT_USERNAME or MQTT_PASSWORD")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(MQTT_SERVER "${MQTT_SERVER}" CACHE INTERNAL "MQTT server")
|
||||
set(MQTT_USERNAME "${MQTT_USERNAME}" CACHE INTERNAL "MQTT user name")
|
||||
set(MQTT_PASSWORD "${MQTT_PASSWORD}" CACHE INTERNAL "MQTT password")
|
||||
set(WIFI_SSID "${WIFI_SSID}" CACHE INTERNAL "wifi ssid")
|
||||
set(WIFI_PASSWORD "${WIFI_PASSWORD}" CACHE INTERNAL "wifi password")
|
||||
|
||||
# Set path to the certificate include file
|
||||
if (NOT MQTT_CERT_PATH)
|
||||
set(MQTT_CERT_PATH ${CMAKE_CURRENT_LIST_DIR}/certs/${MQTT_SERVER})
|
||||
endif()
|
||||
|
||||
# Set the name of the certificate include file
|
||||
if (NOT MQTT_CERT_INC)
|
||||
set(MQTT_CERT_INC mqtt_client.inc)
|
||||
endif()
|
||||
|
||||
set(TARGET_NAME mqtt_client)
|
||||
|
||||
add_executable(${TARGET_NAME}
|
||||
mqtt_client.c
|
||||
)
|
||||
|
||||
target_link_libraries(${TARGET_NAME}
|
||||
pico_stdlib
|
||||
hardware_adc
|
||||
pico_cyw43_arch_lwip_threadsafe_background
|
||||
pico_lwip_mqtt
|
||||
pico_mbedtls
|
||||
pico_lwip_mbedtls
|
||||
)
|
||||
|
||||
target_include_directories(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts or any other standard includes, if required
|
||||
)
|
||||
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE
|
||||
WIFI_SSID=\"${WIFI_SSID}\"
|
||||
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
|
||||
MQTT_SERVER=\"${MQTT_SERVER}\"
|
||||
MQTT_USERNAME=\"${MQTT_USERNAME}\"
|
||||
MQTT_PASSWORD=\"${MQTT_PASSWORD}\"
|
||||
)
|
||||
|
||||
pico_add_extra_outputs(${TARGET_NAME})
|
||||
|
||||
# Ignore warnings from lwip code
|
||||
set_source_files_properties(
|
||||
${PICO_LWIP_PATH}/src/apps/altcp_tls/altcp_tls_mbedtls.c
|
||||
PROPERTIES
|
||||
COMPILE_OPTIONS "-Wno-unused-result"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue