Skip to content

Commit 0a91f6c

Browse files
Jarno LamsaOlli-Pekka Puolitaival
authored andcommitted
Fix issues coming from network default interface
1 parent b4381c2 commit 0a91f6c

File tree

2 files changed

+18
-39
lines changed

2 files changed

+18
-39
lines changed

TEST_APPS/device/socket_app/cmd_ifconfig.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121

2222
#include "ip4string.h"
2323

24-
#ifndef MBED_CONF_APP_CONNECT_STATEMENT
24+
#define WIFI 2
25+
#if !defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) || \
26+
(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == WIFI && !defined(MBED_CONF_NSAPI_DEFAULT_WIFI_SSID))
2527
#error [NOT_SUPPORTED] No network configuration found for this target.
2628
#endif
2729

2830
#include <string.h>
29-
#include MBED_CONF_APP_HEADER_FILE
3031

3132
#define TRACE_GROUP "Aifc"
3233

@@ -86,9 +87,9 @@ int cmd_ifconfig(int argc, char *argv[])
8687
int cmd_ifup(int argc, char *argv[])
8788
{
8889
if (!net) {
89-
net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
90+
net = NetworkInterface::get_default_instance();
9091
}
91-
int err = MBED_CONF_APP_CONNECT_STATEMENT;
92+
int err = net->connect();
9293
if (err != NSAPI_ERROR_OK) {
9394
return CMDLINE_RETCODE_FAIL;
9495
}

TEST_APPS/readme.md

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ You need Icetea and mbed-cli that supports Icetea, installed.
2222
Depending on a device, there might be a default network interface type defined in the mbed-os/targets/targets.json, which is used to locate a test-config file by default.
2323
If there is not, or you want to use a different interface than the default, you need to provide a relevant test-config -file to the mbed test with --test-config option.
2424
The test-config file contains the necessary information for the test application, there are some test-config files located under mbed-os/tools/test-configs.
25+
Devices which have their network drivers residing inside mbed-os can use generic test-configs like HeapBlockDeviceAndEthernetInterface.json and HeapBlockDeviceAndWifiInterface.json. Otherwise you need to use a device specific test-config.
2526

2627
### Running the tests
2728

@@ -41,49 +42,26 @@ Some devices may offer multiple network interfaces to operate with. For example,
4142
The tests can be run for either one of those using already existing test-config -files.
4243

4344
To run the tests with Wi-Fi interface:
44-
`>mbed test -m UBLOX_EVK_ODIN_W2 -t <toolchain> --icetea --test-config tools/test-configs/OdinInterface.json`
45+
`>mbed test -m UBLOX_EVK_ODIN_W2 -t <toolchain> --icetea --test-config tools/test-configs/HeapBlockDeviceAndWifiInterface.json.json`
4546

4647
To run the tests with ethernet interface:
47-
`>mbed test -m UBLOX_EVK_ODIN_W2 -t <toolchain> --icetea --test-config tools/test-configs/Odin_EthernetInterface.json`
48+
`>mbed test -m UBLOX_EVK_ODIN_W2 -t <toolchain> --icetea --test-config tools/test-configs/HeapBlockDeviceAndEthernetInterface.json`
4849

4950
#### Providing Wi-Fi access point information
5051

5152
If you are using Wi-Fi interface for running the tests, you need to provide also information about the used access point.
52-
The information can be provided in the used test-config -file. Depending on the used interface you might need to provide ssid, password and security.
53-
You can either provide separate WIFI_SSID, WIFI_PASSWORD and WIFI_SECURITY macros, or provide the SSID, password and security in the connect statement provided in the test-config -file.
53+
The information can be provided in the used test-config -file.
5454

55-
Example of separate macros:
55+
Example of access point information:
5656
```
57-
"wifi-ssid": {
58-
"help": "WiFi SSID",
59-
"value": "\"ssid\"",
60-
"macro_name": "WIFI_SSID"
61-
},
62-
"wifi-password": {
63-
"help": "WiFi Password",
64-
"value": "\"password\"",
65-
"macro_name": "WIFI_PASSWORD"
66-
},
67-
"wifi-security": {
68-
"help": "WiFi Security, values from nsapi_security from features/netsocket/nsapi_types.h"
69-
"value": "NSAPI_SECURITY_WPA_WPA2"
70-
"macro_name": "WIFI_SECURITY"
71-
```
72-
73-
Example of modifying the connect statement
74-
Original:
75-
```
76-
"connect-statement" : {
77-
"help" : "Must use 'net' variable name",
78-
"value" : "net->wifiInterface()->connect(WIFI_SSID, WIFI_PASSWORD, WIFI_SECURITY)"
79-
},
80-
```
81-
Modified:
82-
```
83-
"connect-statement" : {
84-
"help" : "Must use 'net' variable name",
85-
"value" : "net->wifiInterface()->connect(\"ssid\", \"password\", NSAPI_SECURITY_WPA_WPA2)"
86-
},
57+
"target_overrides": {
58+
"*": {
59+
"target.network-default-interface-type": "WIFI",
60+
"nsapi.default-wifi-ssid": "\"ssid\"",
61+
"nsapi.default-wifi-password": "\"password\"",
62+
"nsapi.default-wifi-security": "WPA_WPA2"
63+
}
64+
}
8765
```
8866

8967
### Test results

0 commit comments

Comments
 (0)