I believe the code uses ring buffer to get data using mbedtls_net_recv function. : Yes; you will have to implement ring buffer functions in rng1.c files.
You donot need CS1.h and other files while implementing and using rin1.c/.h files.
Create rng1.c/.h files and then Place these .c and .h files in mbedtls folder.
I’m facing couple of issue here. Can you please help me with it?
The CS1.c/.h files are not needed but RNG1.c.h use it if #define RNG1_CONFIG_REENTRANT is 1. So should I make it 0?
The function call for my_mqtt_publish in MqttDoStateMachine function has less arguments than needed. I think that function was modified later and called in beginning using this piece of code
res = xQueueReceive(APP_MsgQueue, &msg, 0);
if (res==errQUEUE_EMPTY) {
/* nothing in queue /
} else {
if (msg.msgKind==APP_MQTT_MSG_CONNECT) {
MQTT_state = MQTT_STATE_DO_CONNECT;
} else if (msg.msgKind==APP_MQTT_MSG_DISCONNECT) {
MQTT_state = MQTT_STATE_DO_DISCONNECT;
} else if (msg.msgKind==APP_MQTT_MSG_PUBLISH) {
LWIP_DEBUGF(MQTT_APP_DEBUG_TRACE,(“Publish to broker\r\n”));
my_mqtt_publish(mqtt_client, msg.publish.topic, msg.publish.payload, NULL);
if (msg.publish.topic!=NULL) {
vPortFree((void)msg.publish.topic);
}
if (msg.publish.payload!=NULL) {
vPortFree((void*)msg.publish.payload);
}
MQTT_state = MQTT_STATE_CONNECTED;
}
}
I think the xQueueReceiveis used for freeRTOS and not for our projects. So I called the function in one of the switch cases but that is this
case MQTT_STATE_DO_PUBLISH:
LWIP_DEBUGF(MQTT_APP_DEBUG_TRACE,("Publish to broker\r\n"));
my_mqtt_publish(mqtt_client, NULL);
MQTT_state = MQTT_STATE_CONNECTED;
break;
and this gives error because the function deffinition is different.
Any idea how to do this?
In function ProcessLWIP there is function call for ethernetif_input which I’m not able to locate. I think this is defined in #include “ethernetif.h” which is not available anywhere.
The request to the broker needs to be POST and GET which I think I saw in some file but I’m not able to locate it. Do you have an example where you’re making a request for POST or GET using these files and functions? I’ll be able to implement using that as a reference.
Thank you. And sorry for so many questions. I have an existing project and I’m trying to implement mqtt and I don’t have too much time.
Make it 0 if you are not using RTOS: #define RNG1_CONFIG_REENTRANT 0
YOu can generate events fro your application code viz. Connect to broker/ publish data to broker etc. By doing so you can remove piece of code given at starting of “MqttDoStateMachine()” function.
You can modify publish function definition as : my_mqtt_publish(mqtt_client, msg.publish.topic, msg.publish.payload, NULL);
YOu can avoid that “ethernetif_input()” if you are aware of using lwip stack.
While using mqtt, you don’t need POST/GET method. It is required when you go for WS protocol i.e. web socket protocol.