Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 51 additions & 11 deletions .github/workflows/freertos_plus_demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,23 +449,63 @@ jobs:
- name: Query CI host IP address
id: get-ip
run: |
# Query the device's IP address
# Query the device's IP address (same approach as the original working workflow)
$SERVER_IP = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.IPAddress -notmatch '127.0.0.1' } | Select-Object -First 1 -ExpandProperty IPAddress)
Write-Host "Device IP address: $SERVER_IP"
echo "server_ip=$SERVER_IP" >> $env:GITHUB_ENV
shell: pwsh

- name: Start localhost MQTT broker
- name: Install Mosquitto MQTT v5 broker
id: install-mosquitto
shell: pwsh
run: |
$installerPath = "$env:RUNNER_TEMP\mosquitto-install.exe"
Invoke-WebRequest -Uri "https://mosquitto.org/files/binary/win64/mosquitto-2.1.2-install-windows-x64.exe" -OutFile $installerPath
$proc = Start-Process -FilePath $installerPath -ArgumentList '/S','/D=C:\mosquitto' -PassThru
$proc | Wait-Process -Timeout 120 -ErrorAction SilentlyContinue
if (!$proc.HasExited) { $proc | Stop-Process -Force }
Stop-Service -Name mosquitto -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
if (!(Test-Path "C:\mosquitto\mosquitto.exe")) {
Write-Host "ERROR: mosquitto.exe not found"
exit 1
}
Write-Host "Mosquitto installed successfully"

- name: Start Mosquitto MQTT v5 broker
id: mqtt-broker
uses: FreeRTOS/CI-CD-GitHub-Actions/localhost-mqtt-broker@main
with:
host_address: ${{ env.server_ip }}
root-ca-cert-path:
${{ steps.generate-credentials.outputs.root-ca-cert-path }}
server-priv-key-path:
${{ steps.generate-credentials.outputs.server-priv-key-path }}
server-cert-path:
${{ steps.generate-credentials.outputs.server-cert-path }}
shell: bash
run: |
# Convert MSYS cert paths to Windows paths
CAFILE=$(cygpath -w "${{ steps.generate-credentials.outputs.root-ca-cert-path }}")
CERTFILE=$(cygpath -w "${{ steps.generate-credentials.outputs.server-cert-path }}")
KEYFILE=$(cygpath -w "${{ steps.generate-credentials.outputs.server-priv-key-path }}")

# Write config
cat > "$(cygpath -w "${RUNNER_TEMP}")/mosquitto.conf" <<EOF
allow_anonymous true
listener 1883 ${{ env.server_ip }}
protocol mqtt
listener 8883 ${{ env.server_ip }}
protocol mqtt
cafile ${CAFILE}
certfile ${CERTFILE}
keyfile ${KEYFILE}
tls_version tlsv1.2
EOF

cat "$(cygpath -w "${RUNNER_TEMP}")/mosquitto.conf"

# Start broker in background with & (same pattern as old Python broker)
/c/mosquitto/mosquitto.exe -c "$(cygpath -w "${RUNNER_TEMP}")/mosquitto.conf" -v &
sleep 3

if tasklist | grep -qi mosquitto; then
echo "Mosquitto broker started successfully"
else
echo "ERROR: Mosquitto broker failed to start"
exit 1
fi

- env:
stepName: Update main.c to force stdout to write immediately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,12 @@ extern BaseType_t xPlatformIsNetworkUp( void );
* @param[in] pxPacketInfo Pointer to publish info of the incoming publish.
* @param[in] pxDeserializedInfo Deserialized information from the incoming publish.
*/
static void prvPublishCallback( MQTTContext_t * pxMqttContext,
static bool prvPublishCallback( MQTTContext_t * pxMqttContext,
MQTTPacketInfo_t * pxPacketInfo,
MQTTDeserializedInfo_t * pxDeserializedInfo );
MQTTDeserializedInfo_t * pxDeserializedInfo,
MQTTSuccessFailReasonCode_t * pxReasonCode,
MQTTPropBuilder_t * pxSendPropsBuffer,
MQTTPropBuilder_t * pxGetPropsBuffer );

/**
* @brief Collect all the metrics to be sent in the Device Defender report.
Expand Down Expand Up @@ -367,9 +370,12 @@ static bool prvValidateDefenderResponse( const char * pcDefenderResponse,
}
/*-----------------------------------------------------------*/

static void prvPublishCallback( MQTTContext_t * pxMqttContext,
static bool prvPublishCallback( MQTTContext_t * pxMqttContext,
MQTTPacketInfo_t * pxPacketInfo,
MQTTDeserializedInfo_t * pxDeserializedInfo )
MQTTDeserializedInfo_t * pxDeserializedInfo,
MQTTSuccessFailReasonCode_t * pxReasonCode,
MQTTPropBuilder_t * pxSendPropsBuffer,
MQTTPropBuilder_t * pxGetPropsBuffer )
{
DefenderStatus_t xStatus;
DefenderTopic_t xApi;
Expand All @@ -383,6 +389,9 @@ static void prvPublishCallback( MQTTContext_t * pxMqttContext,
/* Suppress the unused parameter warning when asserts are disabled in
* build. */
( void ) pxMqttContext;
( void ) pxReasonCode;
( void ) pxSendPropsBuffer;
( void ) pxGetPropsBuffer;

/* Handle an incoming publish. The lower 4 bits of the publish packet
* type is used for the dup, QoS, and retain flags. Hence masking
Expand Down Expand Up @@ -451,6 +460,8 @@ static void prvPublishCallback( MQTTContext_t * pxMqttContext,
{
vHandleOtherIncomingPacket( pxPacketInfo, pxDeserializedInfo->packetIdentifier );
}

return true;
}
/*-----------------------------------------------------------*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_serializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_deserializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer_private.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_tcp_sockets_wrapper.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\ports\freertos_plus_tcp\tcp_sockets_wrapper.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls.c" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_serializer.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_deserializer.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer_private.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\coreJSON\source\core_json.c">
<Filter>Additional Libraries\coreJSON</Filter>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,12 @@ static BaseType_t xShadowDeleted = pdFALSE;
* @param[in] pxPacketInfo Packet Info pointer for the incoming packet.
* @param[in] pxDeserializedInfo Deserialized information from the incoming packet.
*/
static void prvEventCallback( MQTTContext_t * pxMqttContext,
static bool prvEventCallback( MQTTContext_t * pxMqttContext,
MQTTPacketInfo_t * pxPacketInfo,
MQTTDeserializedInfo_t * pxDeserializedInfo );
MQTTDeserializedInfo_t * pxDeserializedInfo,
MQTTSuccessFailReasonCode_t * pxReasonCode,
MQTTPropBuilder_t * pxSendPropsBuffer,
MQTTPropBuilder_t * pxGetPropsBuffer );

/**
* @brief Process payload from /update/delta topic.
Expand Down Expand Up @@ -688,9 +691,12 @@ static void prvUpdateAcceptedHandler( MQTTPublishInfo_t * pxPublishInfo )
* function to determine whether the incoming message is a device shadow message
* or not. If it is, it handles the message depending on the message type.
*/
static void prvEventCallback( MQTTContext_t * pxMqttContext,
static bool prvEventCallback( MQTTContext_t * pxMqttContext,
MQTTPacketInfo_t * pxPacketInfo,
MQTTDeserializedInfo_t * pxDeserializedInfo )
MQTTDeserializedInfo_t * pxDeserializedInfo,
MQTTSuccessFailReasonCode_t * pxReasonCode,
MQTTPropBuilder_t * pxSendPropsBuffer,
MQTTPropBuilder_t * pxGetPropsBuffer )
{
ShadowMessageType_t messageType = ShadowMessageTypeMaxNum;
const char * pcThingName = NULL;
Expand All @@ -700,6 +706,9 @@ static void prvEventCallback( MQTTContext_t * pxMqttContext,
uint16_t usPacketIdentifier;

( void ) pxMqttContext;
( void ) pxReasonCode;
( void ) pxSendPropsBuffer;
( void ) pxGetPropsBuffer;

configASSERT( pxDeserializedInfo != NULL );
configASSERT( pxMqttContext != NULL );
Expand Down Expand Up @@ -769,6 +778,8 @@ static void prvEventCallback( MQTTContext_t * pxMqttContext,
{
vHandleOtherIncomingPacket( pxPacketInfo, usPacketIdentifier );
}

return true;
}
/*-----------------------------------------------------------*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_serializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_deserializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer_private.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_tcp_sockets_wrapper.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\ports\freertos_plus_tcp\tcp_sockets_wrapper.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls.c" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_serializer.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_deserializer.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer_private.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\coreJSON\source\core_json.c">
<Filter>Additional Libraries\coreJSON</Filter>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,12 @@ static MQTTFixedBuffer_t xBuffer =
* @param[in] pPublishInfo Pointer to publish info of the incoming publish.
* @param[in] usPacketIdentifier Packet identifier of the incoming publish.
*/
static void prvProvisioningPublishCallback( MQTTContext_t * pxMqttContext,
static bool prvProvisioningPublishCallback( MQTTContext_t * pxMqttContext,
MQTTPacketInfo_t * pxPacketInfo,
MQTTDeserializedInfo_t * pxDeserializedInfo );
MQTTDeserializedInfo_t * pxDeserializedInfo,
MQTTSuccessFailReasonCode_t * pxReasonCode,
MQTTPropBuilder_t * pxSendPropsBuffer,
MQTTPropBuilder_t * pxGetPropsBuffer );

/**
* @brief Subscribe to the CreateCertificateFromCsr accepted and rejected topics.
Expand Down Expand Up @@ -297,9 +300,12 @@ BaseType_t xPlatformIsNetworkUp( void );

/*-----------------------------------------------------------*/

static void prvProvisioningPublishCallback( MQTTContext_t * pxMqttContext,
static bool prvProvisioningPublishCallback( MQTTContext_t * pxMqttContext,
MQTTPacketInfo_t * pxPacketInfo,
MQTTDeserializedInfo_t * pxDeserializedInfo )
MQTTDeserializedInfo_t * pxDeserializedInfo,
MQTTSuccessFailReasonCode_t * pxReasonCode,
MQTTPropBuilder_t * pxSendPropsBuffer,
MQTTPropBuilder_t * pxGetPropsBuffer )
{
FleetProvisioningStatus_t xStatus;
FleetProvisioningTopic_t xApi;
Expand All @@ -312,6 +318,9 @@ static void prvProvisioningPublishCallback( MQTTContext_t * pxMqttContext,
/* Suppress the unused parameter warning when asserts are disabled in
* build. */
( void ) pxMqttContext;
( void ) pxReasonCode;
( void ) pxSendPropsBuffer;
( void ) pxGetPropsBuffer;

/* Handle an incoming publish. The lower 4 bits of the publish packet
* type is used for the dup, QoS, and retain flags. Hence masking
Expand Down Expand Up @@ -384,6 +393,8 @@ static void prvProvisioningPublishCallback( MQTTContext_t * pxMqttContext,
vHandleOtherIncomingPacket( pxPacketInfo, pxDeserializedInfo->packetIdentifier );
xResponseStatus = ResponseAccepted;
}

return true;
}
/*-----------------------------------------------------------*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_serializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_deserializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer_private.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_tcp_sockets_wrapper.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_pk_pkcs11.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_rng_pkcs11.c" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_serializer.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_deserializer.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer_private.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt.c">
<Filter>Additional Libraries\coreMQTT</Filter>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,12 @@ static JobActionType prvGetAction( const char * pcAction,
* @param[in] pxPacketInfo Packet Info pointer for the incoming packet.
* @param[in] pxDeserializedInfo Deserialized information from the incoming packet.
*/
static void prvEventCallback( MQTTContext_t * pxMqttContext,
static bool prvEventCallback( MQTTContext_t * pxMqttContext,
MQTTPacketInfo_t * pxPacketInfo,
MQTTDeserializedInfo_t * pxDeserializedInfo );
MQTTDeserializedInfo_t * pxDeserializedInfo,
MQTTSuccessFailReasonCode_t * pxReasonCode,
MQTTPropBuilder_t * pxSendPropsBuffer,
MQTTPropBuilder_t * pxGetPropsBuffer );

/**
* @brief Process payload from NextJobExecutionChanged and DescribeJobExecution
Expand Down Expand Up @@ -688,13 +691,19 @@ static void prvNextJobHandler( MQTTPublishInfo_t * pxPublishInfo )
* function to determine whether the incoming message is a Jobs message
* or not. If it is, it handles the message depending on the message type.
*/
static void prvEventCallback( MQTTContext_t * pxMqttContext,
static bool prvEventCallback( MQTTContext_t * pxMqttContext,
MQTTPacketInfo_t * pxPacketInfo,
MQTTDeserializedInfo_t * pxDeserializedInfo )
MQTTDeserializedInfo_t * pxDeserializedInfo,
MQTTSuccessFailReasonCode_t * pxReasonCode,
MQTTPropBuilder_t * pxSendPropsBuffer,
MQTTPropBuilder_t * pxGetPropsBuffer )
{
uint16_t usPacketIdentifier;

( void ) pxMqttContext;
( void ) pxReasonCode;
( void ) pxSendPropsBuffer;
( void ) pxGetPropsBuffer;

configASSERT( pxDeserializedInfo != NULL );
configASSERT( pxMqttContext != NULL );
Expand Down Expand Up @@ -822,6 +831,8 @@ static void prvEventCallback( MQTTContext_t * pxMqttContext,
{
vHandleOtherIncomingPacket( pxPacketInfo, usPacketIdentifier );
}

return true;
}

/*-----------------------------------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_serializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_prop_deserializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer_private.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_tcp_sockets_wrapper.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\ports\freertos_plus_tcp\tcp_sockets_wrapper.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls.c" />
Expand Down
Loading
Loading