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

Icetea support #7745

Merged
merged 40 commits into from
Sep 2, 2018
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e27a26e
Icetea support
Jan 23, 2018
9f3704e
Add icetea in requirements
Aug 10, 2018
75400ed
Fix mbed-client-cli part
Aug 10, 2018
fbbbc0d
Move mbed-client-cli in right place
Aug 13, 2018
db1b53e
Limit mbed-ls less than 2 because of icetea and mbed-flashed support
Aug 13, 2018
1e883c5
removed mbed-client-cli tests folder from root
Aug 13, 2018
2ddaed3
Changes needed for abstract socket interface
Aug 13, 2018
6091187
Icetea version update
Aug 14, 2018
3b3bed2
Small fixes based on github comments
Aug 14, 2018
bf1781b
Remove autoformatting
Aug 15, 2018
b35aea2
Roll back initialization with super because it does not work with ice…
Aug 15, 2018
e4e6ddc
Fix doxygen from ns_cmdline.h
Aug 15, 2018
664d98a
Remove startuml doxygen-command
Aug 15, 2018
7739040
Update copyright texts
Aug 15, 2018
912c4f5
Remove not needed test_suite.json
Aug 20, 2018
54ff956
Autoformatting files
Aug 20, 2018
49f842b
Use icetea random string generator
Aug 20, 2018
ccf4416
Move test_suite.json ignore in project level
Aug 20, 2018
c38769b
review corrections
Aug 20, 2018
d2c736b
Added nanostack mac tester and testcases
Aug 13, 2018
5eb3456
Added test config for mac tester
Aug 10, 2018
a508896
Use NanostackRfPhy::get_default_instance() for finding the driver (#2)
Aug 16, 2018
e4f4e64
Use nanostack-libservice stoip4 to check if address is ipv4
Aug 20, 2018
bf7dc1b
Fix copyrights in python scripts
Aug 20, 2018
8a107ac
Remove unused aliases
Aug 20, 2018
449ef92
Update licenses
Aug 20, 2018
b4822c8
Fix typo
Aug 20, 2018
cae3d1d
update example
Aug 20, 2018
2d787c5
Autoformatted mac tests
Aug 21, 2018
564fdd5
Astyle for test applications
Aug 21, 2018
dddac58
Fix readme based on comments in pull request
Aug 28, 2018
2f01555
Fix typo
Aug 28, 2018
b41d215
Update to icetea 1.* version
Aug 28, 2018
1209e73
Fix issues coming from network default interface
Aug 29, 2018
4e38f73
Fix after rebase
Aug 29, 2018
7014905
Remove MAC tests because not completely ready yet
Aug 30, 2018
b433687
Skip the example app
Aug 31, 2018
2edc5f0
Readme and help fixes
Aug 31, 2018
a58aa58
Remove MAC tester related code
Aug 31, 2018
6609faa
Update icetea
Aug 31, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ tags
.vscode/

features/FEATURE_BLE/targets/TARGET_CORDIO/stack_backup/

.pytest_cache
log

# Icetea related file
test_suite.json
Empty file added TEST_APPS/__init__.py
Empty file.
68 changes: 68 additions & 0 deletions TEST_APPS/device/exampleapp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2018 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdarg.h>
#include "mbed.h"
#include "mbed-client-cli/ns_cmdline.h"

#ifndef ICETEA_EXAMPLE_ENABLED
#error [NOT_SUPPORTED] Skipping example application.
#endif
/**
* Macros for setting console flow control.
*/
#define CONSOLE_FLOWCONTROL_RTS 1
#define CONSOLE_FLOWCONTROL_CTS 2
#define CONSOLE_FLOWCONTROL_RTSCTS 3
#define mbed_console_concat_(x) CONSOLE_FLOWCONTROL_##x
#define mbed_console_concat(x) mbed_console_concat_(x)
#define CONSOLE_FLOWCONTROL mbed_console_concat(MBED_CONF_TARGET_CONSOLE_UART_FLOW_CONTROL)

#define SERIAL_CONSOLE_BAUD_RATE 115200

void cmd_ready_cb(int retcode)
{
cmd_next(retcode);
}

void wrap_printf(const char *f, va_list a)
{
vprintf(f, a);
}

int main()
{
cmd_init(&wrap_printf);

int c;
while ((c = getchar()) != EOF) {
cmd_char_input(c);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: wrong indent - check whole file

return 0;
}

FileHandle *mbed::mbed_override_console(int)
{
static UARTSerial console(STDIO_UART_TX, STDIO_UART_RX, SERIAL_CONSOLE_BAUD_RATE);
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
console.set_flow_control(SerialBase::RTS, STDIO_UART_RTS, NC);
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_CTS
console.set_flow_control(SerialBase::CTS, NC, STDIO_UART_CTS);
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTSCTS
console.set_flow_control(SerialBase::RTSCTS, STDIO_UART_RTS, STDIO_UART_CTS);
#endif
return &console;
}
158 changes: 158 additions & 0 deletions TEST_APPS/device/socket_app/cmd_ifconfig.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* Copyright (c) 2018 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "NetworkStack.h"
#include "NetworkInterface.h"

#include "mbed-client-cli/ns_cmdline.h"
#include "mbed-trace/mbed_trace.h"

#include "ip4string.h"

#define WIFI 2
#if !defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) || \
(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == WIFI && !defined(MBED_CONF_NSAPI_DEFAULT_WIFI_SSID))
#error [NOT_SUPPORTED] No network configuration found for this target.
#endif

#include <string.h>

#define TRACE_GROUP "Aifc"

NetworkInterface *net;

NetworkInterface *get_interface(void)
{
return net;
}

int cmd_ifup(int argc, char *argv[]);
int cmd_ifdown(int argc, char *argv[]);
int cmd_ifconfig(int argc, char *argv[]);

const char *MAN_IFCONFIG = " ifup interface up\r\n"\
" ifdown interface down\r\n";

static void ifconfig_print()
{
if (!net) {
cmd_printf("No interface configured\r\n");
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe here should be print that no interface configured etc

}
const char *str = net->get_ip_address();
if (str) {
uint8_t buf[4];
if (stoip4(str, strlen(str), buf)) {
cmd_printf("IPv4 if addr: %s\r\n", str);
} else {
cmd_printf("IPv6 if addr:\r\n [0]: %s\r\n", str);
}
} else {
cmd_printf("No IP address\r\n");
}
str = net->get_mac_address();
if (str) {
cmd_printf("MAC-48: %s\r\n", str);
} else {
cmd_printf("MAC-48: unknown\r\n");
}
}


void cmd_ifconfig_init(void)
{
cmd_add("ifup", cmd_ifup, "ifconfig up", MAN_IFCONFIG);
cmd_add("ifdown", cmd_ifdown, "ifconfig down", MAN_IFCONFIG);
cmd_add("ifconfig", cmd_ifconfig, "ifconfig", MAN_IFCONFIG);
}

int cmd_ifconfig(int argc, char *argv[])
{
ifconfig_print();
return CMDLINE_RETCODE_SUCCESS;
}

int cmd_ifup(int argc, char *argv[])
{
if (!net) {
net = NetworkInterface::get_default_instance();
}
int err = net->connect();
if (err != NSAPI_ERROR_OK) {
return CMDLINE_RETCODE_FAIL;
}

ifconfig_print();
return CMDLINE_RETCODE_SUCCESS;
}

int cmd_ifdown(int argc, char *argv[])
{
if (!net) {
return CMDLINE_RETCODE_FAIL;
}
int err = net->disconnect();
if (err != NSAPI_ERROR_OK) {
return CMDLINE_RETCODE_FAIL;
}

return CMDLINE_RETCODE_SUCCESS;
}



const char *networkstack_error_to_str(int errorcode)
{
switch (errorcode) {
case NSAPI_ERROR_OK:
return "NSAPI_ERROR_OK";
case NSAPI_ERROR_WOULD_BLOCK:
return "NSAPI_ERROR_WOULD_BLOCK";
case NSAPI_ERROR_UNSUPPORTED:
return "NSAPI_ERROR_UNSUPPORTED";
case NSAPI_ERROR_PARAMETER:
return "NSAPI_ERROR_PARAMETER";
case NSAPI_ERROR_NO_CONNECTION:
return "NSAPI_ERROR_NO_CONNECTION";
case NSAPI_ERROR_NO_SOCKET:
return "NSAPI_ERROR_NO_SOCKET";
case NSAPI_ERROR_NO_ADDRESS:
return "NSAPI_ERROR_NO_ADDRESS";
case NSAPI_ERROR_NO_MEMORY:
return "NSAPI_ERROR_NO_MEMORY";
case NSAPI_ERROR_NO_SSID:
return "NSAPI_ERROR_NO_SSID";
case NSAPI_ERROR_DNS_FAILURE:
return "NSAPI_ERROR_DNS_FAILURE";
case NSAPI_ERROR_DHCP_FAILURE:
return "NSAPI_ERROR_DHCP_FAILURE";
case NSAPI_ERROR_AUTH_FAILURE:
return "NSAPI_ERROR_AUTH_FAILURE";
case NSAPI_ERROR_DEVICE_ERROR:
return "NSAPI_ERROR_DEVICE_ERROR";
case NSAPI_ERROR_IN_PROGRESS:
return "NSAPI_ERROR_IN_PROGRESS";
case NSAPI_ERROR_ALREADY:
return "NSAPI_ERROR_ALREADY";
case NSAPI_ERROR_IS_CONNECTED:
return "NSAPI_ERROR_IS_CONNECTED";
case NSAPI_ERROR_CONNECTION_LOST:
return "NSAPI_ERROR_CONNECTION_LOST";
case NSAPI_ERROR_CONNECTION_TIMEOUT:
return "NSAPI_ERROR_CONNECTION_TIMEOUT";
default:
return "unknown error code";
}
}
34 changes: 34 additions & 0 deletions TEST_APPS/device/socket_app/cmd_ifconfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2018 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CMD_IFCONFIG_H
#define CMD_IFCONFIG_H

#include "NetworkInterface.h"
#include "NetworkStack.h"

/** Get a pointer to a network interface instance
*
* Allowed interface types (depend on application configurations):
* cell0, wlan0, eth0, mesh0
*
* @return pointer to the network interface, or NULL if unrecognized or ambiguous
*/
NetworkInterface *get_interface(void);

void cmd_ifconfig_init(void);
const char *networkstack_error_to_str(int errorcode);

#endif
Loading