Support alloc socket dynamically #126
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
由于部分 AT 模块/固件(比如 BC28)在申请 socket 时并不一定从 0 开始,运行过程的其他服务也可能会占用 socket(比如 DNS 域名解析),因此造成申请的 socket 并不连续。这种情况与 at socket 框架的实现存在冲突,对 at device 的实现造成较大限制。
因此我提出了一种修改方案 #3755,在 at_socket_ops 结构体增加一个成员函数 at_socket,用于申请并返回 AT 设备真实可用的 socket 号,at device 模块可以根据自身情况决定是否需要实现该函数。
同时,为了兼容本次修改,我在 at_device 其他所有设备的 at_socket_ops 构造中均添加了 at_socket 指向 RT_NULL。所以不会影响其他模块的使用。