RT-Thread / rt-thread

RT-Thread is an open source IoT real-time operating system (RTOS).
https://www.rt-thread.io
Apache License 2.0
10.03k stars 4.9k forks source link

AT device driver layer not compatible with some LTE module with link_id zero offset is 1 #5819

Closed esonhon closed 1 year ago

esonhon commented 2 years ago

In RTT release 4.1.0, the file component/net/at/at_socket/at_socket.c, function alloc_socket_by_device, the net interface id is start from zero, which can find in code line 311 "int idx = 0;", this index will transfered to at socket implementation layer, and will be passed to the AT MODULE by AT command, such as NEOWAY N58 module "AT+TCPSETUP=,, 链路编号,只能为 0~5。", but for some modules like GOSUN GM331, which says "AT+ZIPOPEN=,,,[,] link_id>:连接标识,取值范围为[1,5] " , that means link id 0 is illegal, if we transfer 0 to module, it fails. Do we have any straightforward and configurable way in this suitation?

xiangxistu commented 2 years ago

Yes, we have a solution for this suitation.

https://github.com/RT-Thread/rt-thread/blob/9d0f088e200470682ee284ea3beda78bbd7a2cf0/components/net/at/at_socket/at_socket.c#L334

You can see, when this moudle have registered "socket_ops->at_socket", the "idx" will be offered by hardware driver by "AT DEVICE".


https://github.com/RT-Thread/rt-thread/blob/9d0f088e200470682ee284ea3beda78bbd7a2cf0/components/net/at/at_socket/at_socket.h#L74

xiangxistu commented 1 year ago

This problem should be handled by "at_device".