Skip to content
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

drivers: wifi: simplelink: Add static IP address support #15832

Merged
merged 1 commit into from
May 10, 2019

Conversation

vanti
Copy link
Collaborator

@vanti vanti commented May 2, 2019

Change the SimpleLink wifi driver to use static IP address instead of
DHCP when it is set by NET_CONFIG_MY_IPV4_ADDR. We also support setting
gateway and netmask via NET_CONFIG_MY_IPV4_GW and
NET_CONFIG_MY_IPV4_NETMASK.

Fixes #14588

Signed-off-by: Vincent Wan vincent.wan@linaro.org

@@ -65,6 +65,44 @@ struct sl_connect_state sl_conn;
/* Network Coprocessor state, including role and connection state: */
static struct nwp_status nwp;

#if defined(CONFIG_NET_IPV4) && defined(CONFIG_NET_CONFIG_MY_IPV4_ADDR)
/* Convert IP addr string into an array of integers */
static int tokenize_ipv4addr(u8_t *ip_array, char const *ip_string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use net_ipaddr_parse() function here that will do basically the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use net_ipaddr_parse() function here that will do basically the same.

I guess net_addr_pton() might be even better fit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jukkar @pfalcon I have updated the code to use net_addr_pton(). It is a good idea.

@pfalcon
Copy link
Contributor

pfalcon commented May 7, 2019

It's absolutely great to see this feature implemented (and thus, cc3220 to fit much better with Zephyr network configuration model). But I agree with @jukkar's comment that we should reuse existing routines whenever possible.

Copy link
Collaborator

@GAnthony GAnthony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please mention in the commit how this was tested?
Which samples, and did wifi_shell work as well with auto init?
If this commit is all that was required, then that's great!

@vanti
Copy link
Collaborator Author

vanti commented May 10, 2019

Could you please mention in the commit how this was tested?
Which samples, and did wifi_shell work as well with auto init?
If this commit is all that was required, then that's great!

Could you please mention in the commit how this was tested?
Which samples, and did wifi_shell work as well with auto init?
If this commit is all that was required, then that's great!

@GAnthony It was tested out-of-tree against the echo sample after modifying the prj.conf file to set the IP address:

CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.191"

and then I had to comment out these lines in the board-specific config file

#CONFIG_NET_CONFIG_SETTINGS=n
#CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
#CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""

that would have overridden the NET_CONFIG_SETTINGS.

I also ran the wifi sample to verify it still runs correctly.

I have added this info to the commit message, thanks.

#if defined(CONFIG_NET_IPV4) && defined(CONFIG_NET_CONFIG_MY_IPV4_ADDR)
if (net_addr_pton(AF_INET, CONFIG_NET_CONFIG_MY_IPV4_ADDR, &addr4)
< 0) {
LOG_ERR("Please verify CONFIG_NET_CONFIG_MY_IPV4_ADDR");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but I'd say, consistent Zephyr error style would be "Invalid CONFIG_NET_CONFIG_MY_IPV4_ADDR".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

@pfalcon
Copy link
Contributor

pfalcon commented May 10, 2019

I have added this info to the commit message

Thumbs up to that, it may be very helpful to someone who will debug this stuff later.

Copy link
Contributor

@pfalcon pfalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updates.

Change the SimpleLink wifi driver to use static IP address instead of
DHCP when it is set by NET_CONFIG_MY_IPV4_ADDR. We also support setting
gateway and netmask via NET_CONFIG_MY_IPV4_GW and
NET_CONFIG_MY_IPV4_NETMASK.

This feature is tested out-of-tree against the echo sample after
modifying its prj.conf file to set the static IP address:

CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.191"

and after commenting out these lines in its board-specific config
file for cc3220sf_launchxl:

so that the NET_CONFIG_SETTINGS are not overridden.

The wifi sample is also verified to run correctly after running the
echo sample.

Fixes zephyrproject-rtos#14588

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
@jukkar jukkar merged commit 252ab55 into zephyrproject-rtos:master May 10, 2019
@vanti vanti deleted the static_ip_14588 branch May 31, 2019 17:10
nvlsianpu added a commit to nvlsianpu/zephyr that referenced this pull request Jul 4, 2019
Qemu_x86 didn't reflect emulated program memory size.
It was because chosen zephyr,flash was assigned to flash_simulator
which was helping to generate DT_FLASH properties for sim_flash node.

This change revert choice of flash0 which solve problem with
program memory size. Flash simulator have to use
DT_SOC_NV_FLASH_xxx labels for fetch its property since that.

fixes zephyrproject-rtos#15832

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
andrewboie pushed a commit that referenced this pull request Jul 17, 2019
Qemu_x86 didn't reflect emulated program memory size.
It was because chosen zephyr,flash was assigned to flash_simulator
which was helping to generate DT_FLASH properties for sim_flash node.

This change revert choice of flash0 which solve problem with
program memory size. Flash simulator have to use
DT_SOC_NV_FLASH_xxx labels for fetch its property since that.

fixes #15832

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

static IP support on cc3220sf_launchxl
4 participants