Skip to content

Commit 142966f

Browse files
fix for indent and working directory
1 parent d2501ae commit 142966f

1 file changed

Lines changed: 115 additions & 114 deletions

File tree

.github/workflows/threadx.yml

Lines changed: 115 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -117,127 +117,128 @@ jobs:
117117
working-directory: ./wolfmqtt
118118
run: |
119119
cat > examples/threadx_netx_test.c <<'EOF'
120-
/* threadx_netx_test.c
121-
* Minimal ThreadX/NetX test app using NetConnect logic from mqttnet.c
122-
*/
123-
124-
#include <stdio.h>
125-
#include "tx_api.h"
126-
#include "nx_api.h"
127-
#include "nxd_dns.h"
128-
#include "examples/mqttnet.h"
129-
#include "examples/mqttexample.h"
130-
131-
#define DEMO_STACK_SIZE 2048
132-
#define DEMO_IP_ADDRESS IP_ADDRESS(192,168,1,100)
133-
#define DEMO_NET_MASK 0xFFFFFF00
134-
#define DEMO_GATEWAY_ADDRESS IP_ADDRESS(192,168,1,1)
135-
#define DEMO_DNS_SERVER IP_ADDRESS(8,8,8,8)
136-
#define DEMO_HOSTNAME "test.mosquitto.org"
137-
#define DEMO_PORT 1883
138-
#define DEMO_TIMEOUT_MS 5000
139-
140-
/* ThreadX/NetX objects */
141-
TX_THREAD demo_thread;
142-
ULONG demo_thread_stack[DEMO_STACK_SIZE / sizeof(ULONG)];
143-
NX_PACKET_POOL pool_0;
144-
NX_IP ip_0;
145-
NX_DNS dns_0;
146-
147-
/* Forward declaration */
148-
void demo_thread_entry(ULONG thread_input);
149-
150-
void tx_application_define(void *first_unused_memory)
151-
{
152-
/* Create the main demo thread. */
153-
tx_thread_create(&demo_thread, "Demo Thread", demo_thread_entry, 0,
154-
demo_thread_stack, DEMO_STACK_SIZE,
155-
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
156-
}
157-
158-
void demo_thread_entry(ULONG thread_input)
159-
{
160-
UINT status;
161-
NXD_ADDRESS dns_server;
162-
MQTTCtx mqttCtx;
163-
MqttNet net;
164-
SocketContext *sockCtx;
165-
int rc;
166-
167-
/* Initialize NetX system */
168-
nx_system_initialize();
169-
170-
/* Create a packet pool. */
171-
status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool",
172-
1536, (UCHAR*)first_unused_memory, 16*1536);
173-
if (status != NX_SUCCESS) {
174-
printf("Packet pool create failed: %u\n", status);
175-
return;
176-
}
177-
178-
/* Create an IP instance. */
179-
status = nx_ip_create(&ip_0, "NetX IP Instance",
180-
DEMO_IP_ADDRESS, DEMO_NET_MASK,
181-
&pool_0, nx_driver_placeholder,
182-
(UCHAR*)first_unused_memory + 16*1536, 2048, 1);
183-
if (status != NX_SUCCESS) {
184-
printf("IP create failed: %u\n", status);
185-
return;
186-
}
187-
188-
/* Enable ARP, ICMP, TCP, UDP */
189-
nx_arp_enable(&ip_0, (UCHAR*)first_unused_memory + 16*1536 + 2048, 1024);
190-
nx_icmp_enable(&ip_0);
191-
nx_tcp_enable(&ip_0);
192-
nx_udp_enable(&ip_0);
193-
194-
/* Create DNS instance */
195-
status = nxd_dns_create(&dns_0, (UCHAR*)"DNS Client", &ip_0, (UCHAR*)first_unused_memory + 16*1536 + 2048 + 1024, 2048);
196-
if (status != NX_SUCCESS) {
197-
printf("DNS create failed: %u\n", status);
198-
return;
199-
}
200-
dns_server.nxd_ip_version = NX_IP_VERSION_V4;
201-
dns_server.nxd_ip_address.v4 = DEMO_DNS_SERVER;
202-
nxd_dns_server_add(&dns_0, &dns_server);
203-
204-
/* Initialize MQTT context and network */
205-
mqtt_init_ctx(&mqttCtx);
206-
MqttClientNet_Init(&net, &mqttCtx);
207-
sockCtx = (SocketContext*)net.context;
208-
sockCtx->ipPtr = &ip_0;
209-
sockCtx->dnsPtr = &dns_0;
210-
211-
/* Use NetConnect to connect to the MQTT broker */
212-
rc = net.connect(sockCtx, DEMO_HOSTNAME, DEMO_PORT, DEMO_TIMEOUT_MS);
213-
if (rc == 0) {
214-
printf("NetConnect succeeded!\n");
215-
net.disconnect(sockCtx);
216-
} else {
217-
printf("NetConnect failed: %d\n", rc);
218-
}
219-
220-
/* Cleanup (not strictly necessary in a demo) */
221-
nxd_dns_delete(&dns_0);
222-
nx_ip_delete(&ip_0);
223-
nx_packet_pool_delete(&pool_0);
224-
/* Thread exits */
225-
tx_thread_terminate(&demo_thread);
226-
}
227-
228-
/* Placeholder driver for demo purposes */
229-
void nx_driver_placeholder(NX_IP_DRIVER *driver_req)
230-
{
231-
NX_PARAMETER_NOT_USED(driver_req);
232-
}
233-
EOF
120+
/* threadx_netx_test.c
121+
* Minimal ThreadX/NetX test app using NetConnect logic from mqttnet.c
122+
*/
123+
124+
#include <stdio.h>
125+
#include "tx_api.h"
126+
#include "nx_api.h"
127+
#include "nxd_dns.h"
128+
#include "examples/mqttnet.h"
129+
#include "examples/mqttexample.h"
130+
131+
#define DEMO_STACK_SIZE 2048
132+
#define DEMO_IP_ADDRESS IP_ADDRESS(192,168,1,100)
133+
#define DEMO_NET_MASK 0xFFFFFF00
134+
#define DEMO_GATEWAY_ADDRESS IP_ADDRESS(192,168,1,1)
135+
#define DEMO_DNS_SERVER IP_ADDRESS(8,8,8,8)
136+
#define DEMO_HOSTNAME "test.mosquitto.org"
137+
#define DEMO_PORT 1883
138+
#define DEMO_TIMEOUT_MS 5000
139+
140+
/* ThreadX/NetX objects */
141+
TX_THREAD demo_thread;
142+
ULONG demo_thread_stack[DEMO_STACK_SIZE / sizeof(ULONG)];
143+
NX_PACKET_POOL pool_0;
144+
NX_IP ip_0;
145+
NX_DNS dns_0;
146+
147+
/* Forward declaration */
148+
void demo_thread_entry(ULONG thread_input);
149+
150+
void tx_application_define(void *first_unused_memory)
151+
{
152+
/* Create the main demo thread. */
153+
tx_thread_create(&demo_thread, "Demo Thread", demo_thread_entry, 0,
154+
demo_thread_stack, DEMO_STACK_SIZE,
155+
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
156+
}
157+
158+
void demo_thread_entry(ULONG thread_input)
159+
{
160+
UINT status;
161+
NXD_ADDRESS dns_server;
162+
MQTTCtx mqttCtx;
163+
MqttNet net;
164+
SocketContext *sockCtx;
165+
int rc;
166+
167+
/* Initialize NetX system */
168+
nx_system_initialize();
169+
170+
/* Create a packet pool. */
171+
status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool",
172+
1536, (UCHAR*)first_unused_memory, 16*1536);
173+
if (status != NX_SUCCESS) {
174+
printf("Packet pool create failed: %u\n", status);
175+
return;
176+
}
177+
178+
/* Create an IP instance. */
179+
status = nx_ip_create(&ip_0, "NetX IP Instance",
180+
DEMO_IP_ADDRESS, DEMO_NET_MASK,
181+
&pool_0, nx_driver_placeholder,
182+
(UCHAR*)first_unused_memory + 16*1536, 2048, 1);
183+
if (status != NX_SUCCESS) {
184+
printf("IP create failed: %u\n", status);
185+
return;
186+
}
187+
188+
/* Enable ARP, ICMP, TCP, UDP */
189+
nx_arp_enable(&ip_0, (UCHAR*)first_unused_memory + 16*1536 + 2048, 1024);
190+
nx_icmp_enable(&ip_0);
191+
nx_tcp_enable(&ip_0);
192+
nx_udp_enable(&ip_0);
193+
194+
/* Create DNS instance */
195+
status = nxd_dns_create(&dns_0, (UCHAR*)"DNS Client", &ip_0, (UCHAR*)first_unused_memory + 16*1536 + 2048 + 1024, 2048);
196+
if (status != NX_SUCCESS) {
197+
printf("DNS create failed: %u\n", status);
198+
return;
199+
}
200+
dns_server.nxd_ip_version = NX_IP_VERSION_V4;
201+
dns_server.nxd_ip_address.v4 = DEMO_DNS_SERVER;
202+
nxd_dns_server_add(&dns_0, &dns_server);
203+
204+
/* Initialize MQTT context and network */
205+
mqtt_init_ctx(&mqttCtx);
206+
MqttClientNet_Init(&net, &mqttCtx);
207+
sockCtx = (SocketContext*)net.context;
208+
sockCtx->ipPtr = &ip_0;
209+
sockCtx->dnsPtr = &dns_0;
210+
211+
/* Use NetConnect to connect to the MQTT broker */
212+
rc = net.connect(sockCtx, DEMO_HOSTNAME, DEMO_PORT, DEMO_TIMEOUT_MS);
213+
if (rc == 0) {
214+
printf("NetConnect succeeded!\n");
215+
net.disconnect(sockCtx);
216+
} else {
217+
printf("NetConnect failed: %d\n", rc);
218+
}
219+
220+
/* Cleanup (not strictly necessary in a demo) */
221+
nxd_dns_delete(&dns_0);
222+
nx_ip_delete(&ip_0);
223+
nx_packet_pool_delete(&pool_0);
224+
/* Thread exits */
225+
tx_thread_terminate(&demo_thread);
226+
}
227+
228+
/* Placeholder driver for demo purposes */
229+
void nx_driver_placeholder(NX_IP_DRIVER *driver_req)
230+
{
231+
NX_PARAMETER_NOT_USED(driver_req);
232+
}
233+
EOF
234234
235235
- name: Compile ThreadX NetX test app
236236
working-directory: ./wolfmqtt
237237
run: |
238238
gcc -o threadx_netx_test examples/threadx_netx_test.c -I${{ github.workspace }}/netxduo_src/common/inc -I${{ github.workspace }}/netxduo_src/ports/linux/gnu/inc -I${{ github.workspace }}/netxduo_src/test/cmake/netxduo64/build/libs/inc -I${{ github.workspace }}/netxduo_src/test/cmake/netxduo64/build/libs/threadx -L${{ github.workspace }}/netxduo_src/test/cmake/netxduo64/build/default_build_coverage/netxduo -L${{ github.workspace }}/netxduo_src/test/cmake/netxduo64/build/libs/threadx -lnetxduo -lthreadx -lwolfssl -lwolfmqtt
239239
240240
- name: Run ThreadX NetX test app
241+
working-directory: ./wolfmqtt
241242
run: |
242243
./threadx_netx_test
243244

0 commit comments

Comments
 (0)