Skip to content

Commit

Permalink
Merge pull request #3144 from ARMmbed/release-candidate
Browse files Browse the repository at this point in the history
Release candidate for 5.2.1
  • Loading branch information
0xc0170 authored Oct 27, 2016
2 parents e435a07 + 03edc37 commit e2617cc
Show file tree
Hide file tree
Showing 943 changed files with 519,311 additions and 29,831 deletions.
94 changes: 94 additions & 0 deletions TESTS/netsocket/ip_parsing/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"

using namespace utest::v1;


// IP parsing verification
void test_ip_accept(const char *string, nsapi_addr_t addr) {
SocketAddress address;
TEST_ASSERT(address.set_ip_address(string));
TEST_ASSERT(address == SocketAddress(addr));
}

template <const char *string>
void test_ip_reject() {
SocketAddress address;
TEST_ASSERT(!address.set_ip_address(string));
TEST_ASSERT(!address);
}

#define TEST_IP_ACCEPT(name, string, ...) \
void name() { \
nsapi_addr_t addr = __VA_ARGS__; \
test_ip_accept(string, addr); \
}

#define TEST_IP_REJECT(name, string) \
void name() { \
test_ip_reject(string); \
}


// Test cases
TEST_IP_ACCEPT(test_simple_ipv4_address,
"12.34.56.78",
{NSAPI_IPv4,{12,34,56,78}})
TEST_IP_ACCEPT(test_left_weighted_ipv4_address,
"255.0.0.0",
{NSAPI_IPv4,{255,0,0,0}})
TEST_IP_ACCEPT(test_right_weighted_ipv4_address,
"0.0.0.255",
{NSAPI_IPv4,{0,0,0,255}})
TEST_IP_ACCEPT(test_null_ipv4_address,
"0.0.0.0",
{NSAPI_IPv4,{0,0,0,0}})

TEST_IP_ACCEPT(test_simple_ipv6_address,
"1234:5678:9abc:def0:1234:5678:9abc:def0",
{NSAPI_IPv6,{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}})
TEST_IP_ACCEPT(test_left_weighted_ipv6_address,
"1234:5678::",
{NSAPI_IPv6,{0x12,0x34,0x56,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}})
TEST_IP_ACCEPT(test_right_weighted_ipv6_address,
"::1234:5678",
{NSAPI_IPv6,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x12,0x34,0x56,0x78}})
TEST_IP_ACCEPT(test_hollowed_ipv6_address,
"1234:5678::9abc:def8",
{NSAPI_IPv6,{0x12,0x34,0x56,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x9a,0xbc,0xde,0xf8}})
TEST_IP_ACCEPT(test_null_ipv6_address,
"::",
{NSAPI_IPv6,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}})


// Test setup
utest::v1::status_t test_setup(const size_t number_of_cases) {
GREENTEA_SETUP(10, "default_auto");
return verbose_test_setup_handler(number_of_cases);
}

Case cases[] = {
Case("Simple IPv4 address", test_simple_ipv4_address),
Case("Left-weighted IPv4 address", test_left_weighted_ipv4_address),
Case("Right-weighted IPv4 address", test_right_weighted_ipv4_address),
Case("Null IPv4 address", test_null_ipv4_address),

Case("Simple IPv6 address", test_simple_ipv6_address),
Case("Left-weighted IPv6 address", test_left_weighted_ipv6_address),
Case("Right-weighted IPv6 address", test_right_weighted_ipv6_address),
Case("Hollowed IPv6 address", test_hollowed_ipv6_address),
Case("Null IPv6 address", test_null_ipv6_address),
};

Specification specification(test_setup, cases);

int main() {
return !Harness::run(specification);
}
8 changes: 8 additions & 0 deletions cmsis/core_cm0.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@
#define __O volatile /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */

#ifdef __cplusplus
#define __IM volatile /*!< Defines 'read only' permissions */
#else
#define __IM volatile const /*!< Defines 'read only' permissions */
#endif
#define __OM volatile /*!< Defines 'write only' permissions */
#define __IOM volatile /*!< Defines 'read / write' permissions */

/*@} end of group Cortex_M0 */


Expand Down
8 changes: 8 additions & 0 deletions cmsis/core_cm0plus.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@
#define __O volatile /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */

#ifdef __cplusplus
#define __IM volatile /*!< Defines 'read only' permissions */
#else
#define __IM volatile const /*!< Defines 'read only' permissions */
#endif
#define __OM volatile /*!< Defines 'write only' permissions */
#define __IOM volatile /*!< Defines 'read / write' permissions */

/*@} end of group Cortex-M0+ */


Expand Down
8 changes: 8 additions & 0 deletions cmsis/core_cm3.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@
#define __O volatile /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */

#ifdef __cplusplus
#define __IM volatile /*!< Defines 'read only' permissions */
#else
#define __IM volatile const /*!< Defines 'read only' permissions */
#endif
#define __OM volatile /*!< Defines 'write only' permissions */
#define __IOM volatile /*!< Defines 'read / write' permissions */

/*@} end of group Cortex_M3 */


Expand Down
8 changes: 8 additions & 0 deletions cmsis/core_cm4.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@
#define __O volatile /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */

#ifdef __cplusplus
#define __IM volatile /*!< Defines 'read only' permissions */
#else
#define __IM volatile const /*!< Defines 'read only' permissions */
#endif
#define __OM volatile /*!< Defines 'write only' permissions */
#define __IOM volatile /*!< Defines 'read / write' permissions */

/*@} end of group Cortex_M4 */


Expand Down
8 changes: 8 additions & 0 deletions cmsis/core_cm7.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@
#define __O volatile /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */

#ifdef __cplusplus
#define __IM volatile /*!< Defines 'read only' permissions */
#else
#define __IM volatile const /*!< Defines 'read only' permissions */
#endif
#define __OM volatile /*!< Defines 'write only' permissions */
#define __IOM volatile /*!< Defines 'read / write' permissions */

/*@} end of group Cortex_M7 */


Expand Down
21 changes: 21 additions & 0 deletions docs/build_profiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Build Profiles
Mbed 5.0 supports three primary build profiles, *default*, *debug* and *small*. When using
the online compiler the *default* profile is used. When building from the command line
the desired profile can be can be selected by adding the ```--profile <profile>```
command line flag. Custom user defined profiles can also be specific by giving the path
the the profile.

## Default profile
* Small and fast code
* Full error information - e.x. asserts have filename and line number
* Hard to follow code flow when using a debugger

## Debug profile
* Easy to step through code with a debugger
* Full error information - e.x. asserts have filename and line number
* Largest and slowest profile

## Small profile
* Smallest profile and still fast
* Minimal error information
* Hard to follow code flow when using a debugger
12 changes: 6 additions & 6 deletions events/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class Event<void()> {
* @param a0..a4 Arguments to pass to the event
*/
void call() const {
int id = post();
MBED_UNUSED int id = post();
MBED_ASSERT(id);
}

Expand Down Expand Up @@ -540,7 +540,7 @@ class Event<void(A0)> {
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0) const {
int id = post(a0);
MBED_UNUSED int id = post(a0);
MBED_ASSERT(id);
}

Expand Down Expand Up @@ -933,7 +933,7 @@ class Event<void(A0, A1)> {
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0, A1 a1) const {
int id = post(a0, a1);
MBED_UNUSED int id = post(a0, a1);
MBED_ASSERT(id);
}

Expand Down Expand Up @@ -1326,7 +1326,7 @@ class Event<void(A0, A1, A2)> {
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0, A1 a1, A2 a2) const {
int id = post(a0, a1, a2);
MBED_UNUSED int id = post(a0, a1, a2);
MBED_ASSERT(id);
}

Expand Down Expand Up @@ -1719,7 +1719,7 @@ class Event<void(A0, A1, A2, A3)> {
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0, A1 a1, A2 a2, A3 a3) const {
int id = post(a0, a1, a2, a3);
MBED_UNUSED int id = post(a0, a1, a2, a3);
MBED_ASSERT(id);
}

Expand Down Expand Up @@ -2112,7 +2112,7 @@ class Event<void(A0, A1, A2, A3, A4)> {
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
int id = post(a0, a1, a2, a3, a4);
MBED_UNUSED int id = post(a0, a1, a2, a3, a4);
MBED_ASSERT(id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ ble_error_t ArmGap::startAdvertising(const GapAdvertisingParams &params)
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}

/* Peer Addr Type 0 = Public */
uint8_t peerAddrType = 0;
uint8_t peerAddr[6];
memset(peerAddr, 0, 6);

DmAdvSetInterval(params.getInterval(), params.getInterval());
DmAdvStart(params.getAdvertisingType(), params.getTimeout());
DmAdvStart(params.getAdvertisingType(), params.getTimeout(), peerAddrType, peerAddr);

state.advertising = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ extern "C" {
#include "nRF5xServiceDiscovery.h"
#include "nRF5xCharacteristicDescriptorDiscoverer.h"


bool isEventsSignaled = false;

extern "C" void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name);
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name);
extern "C" void SD_EVT_IRQHandler(void); // export the softdevice event handler for registration by nvic-set-vector.


static void btle_handler(ble_evt_t *p_ble_evt);

Expand Down Expand Up @@ -112,10 +115,14 @@ static uint32_t signalEvent()
return NRF_SUCCESS;
}


error_t btle_init(void)
{
nrf_clock_lf_cfg_t clockConfiguration;

// register softdevice handler vector
NVIC_SetVector(SD_EVT_IRQn, (uint32_t) SD_EVT_IRQHandler);

// Configure the LF clock according to values provided by btle_clock.h.
// It is input from the chain of the yotta configuration system.
clockConfiguration.source = LFCLK_CONF_SOURCE;
Expand Down
17 changes: 15 additions & 2 deletions features/FEATURE_LWIP/lwip-interface/lwip_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ static bool convert_mbed_addr_to_lwip(ip_addr_t *out, const nsapi_addr_t *in)
#if !LWIP_IPV4
/* For bind() and other purposes, need to accept "null" of other type */
/* (People use IPv4 0.0.0.0 as a general null) */
if (in->version == NSAPI_IPv4 && all_zeros(in->bytes, 4)) {
if (in->version == NSAPI_UNSPEC ||
(in->version == NSAPI_IPv4 && all_zeros(in->bytes, 4))) {
ip_addr_set_zero_ip6(out);
return true;
}
Expand All @@ -145,13 +146,25 @@ static bool convert_mbed_addr_to_lwip(ip_addr_t *out, const nsapi_addr_t *in)
}
#if !LWIP_IPV6
/* For symmetry with above, accept IPv6 :: as a general null */
if (in->version == NSAPI_IPv6 && all_zeros(in->bytes, 16)) {
if (in->version == NSAPI_UNSPEC ||
(in->version == NSAPI_IPv6 && all_zeros(in->bytes, 16))) {
ip_addr_set_zero_ip4(out);
return true;
}
#endif
#endif

#if LWIP_IPV4 && LWIP_IPV6
if (in->version == NSAPI_UNSPEC) {
#if IP_VERSION_PREF == PREF_IPV4
ip_addr_set_zero_ip4(out);
#else
ip_addr_set_zero_ip6(out);
#endif
return true;
}
#endif

return false;
}

Expand Down
5 changes: 0 additions & 5 deletions features/netsocket/NetworkInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ int NetworkInterface::set_dhcp(bool dhcp)
}

// DNS operations go through the underlying stack by default
int NetworkInterface::gethostbyname(const char *name, SocketAddress *address)
{
return get_stack()->gethostbyname(name, address);
}

int NetworkInterface::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version)
{
return get_stack()->gethostbyname(name, address, version);
Expand Down
19 changes: 3 additions & 16 deletions features/netsocket/NetworkInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,6 @@ class NetworkInterface {
*/
virtual int disconnect() = 0;

/** Translates a hostname to an IP address
*
* The hostname may be either a domain name or an IP address. If the
* hostname is an IP address, no network transactions will be performed.
*
* If no stack-specific DNS resolution is provided, the hostname
* will be resolve using a UDP socket on the stack.
*
* @param address Destination for the host SocketAddress
* @param host Hostname to resolve
* @return 0 on success, negative error code on failure
*/
virtual int gethostbyname(const char *host, SocketAddress *address);

/** Translates a hostname to an IP address with specific version
*
* The hostname may be either a domain name or an IP address. If the
Expand All @@ -127,10 +113,11 @@ class NetworkInterface {
*
* @param address Destination for the host SocketAddress
* @param host Hostname to resolve
* @param version IP version of address to resolve
* @param version IP version of address to resolve, NSAPI_UNSPEC indicates
* version is chosen by the stack (defaults to NSAPI_UNSPEC)
* @return 0 on success, negative error code on failure
*/
virtual int gethostbyname(const char *host, SocketAddress *address, nsapi_version_t version);
virtual int gethostbyname(const char *host, SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC);

/** Add a domain name server to list of servers to query
*
Expand Down
Loading

0 comments on commit e2617cc

Please sign in to comment.