-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT example for SWIOT1L and a couple fixes #2180
Conversation
c1cdc20
to
bb8794b
Compare
I'll have to update the documentation as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some remarks from my side, also it looks like the build is failing because the max UART flags are not found
*/ | ||
static err_t lwip_connect_callback(void *arg, struct tcp_pcb *pcb, err_t err) | ||
{ | ||
struct lwip_socket_desc *sock = arg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seeing how these APIs are static, I am not sure if we should check for null pointers...I suppose the upper layer is taking care of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The upper layer is not checking arg
. I've added the check in the lwip_connect_function
, however this pointer is shared between multiple callbacks (lwip_accept_callback()
, lwip_recv_callback()
) and an invalid value will result in a fatal error (meaning the lwip stack won't be able to recover from this and any action such as connect, accept, packet RX, etc will be broken from that point on). So, it's not much different that a null pointer access.
ret = tcp_connect(pcb, &ipaddr, addr->port, lwip_connect_callback); | ||
if (ret) | ||
return ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can return directly
projects/swiot1l/src.mk
Outdated
|
||
endif | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove extra blank line
}; | ||
struct lwip_network_desc *lwip_desc; | ||
struct tcp_socket_desc *tcp_socket; | ||
// struct connection *client_socket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented line
if (ret) | ||
return ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any memory leaks we should handle?
also, in case of returning, especially if !0, maybe it would be a good idea to print some error messages which would explain what has happened?
The UART error flags are currently not cleared in the SDK. Thus, if any of them are set, the UART interrupt will be continuosly triggered. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
bb8794b
to
9f4c87c
Compare
9f4c87c
to
98909f0
Compare
Implement the connect() and disconnect() TCP client functionality. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
Usually, the payload field of the mqtt_message struct is used in order to pass "string" data (either a static char* or a buffer formatted using sprintf). char* and int8_t* may not be equivalent, since on different CPU architectures char might be defined as either signed or unsigned, thus a compilation warning is generated. Avoid the need to cast by using the expected data type. Apply similar changes for other fields. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
Currently, all devices (ADIN1110 and ADIN2111) which may be used with the LWIP sockets layer require polling for new frames. Add a poll before socket_recv(). Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
When the AD74413R's ADC is measuring current in the voltage output mode, the result may be signed. A negative current indicates the current is sourced by the device and a positive one indicates current is sinked. Currently, since the decimal part of the result is declared as unsigned, there is no way to represent current values in the (-1:0) mA range. Fix this by declaring the decimal part as signed. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
9b7e344
to
d521ed8
Compare
Implement the remove function for the LWIP sockets layer. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
The project showcases how you may send data over MQTT (using the T1L ethernet connector on the SWIOT1L board) to a remote broker. The default IP and port configurations of the broker are assumed to be 192.168.97.1:1883. These may be changed when compiling by setting the SWIOT1L_MQTT_SERVER_IP and SWIOT1L_MQTT_SERVER_PORT make variables. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
d521ed8
to
b74ae4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Pull Request Description
PR Type
PR Checklist