Merge branch 'fix_astyle_error' of ssh://github.com/0xc0170/mbed-os into rollup-b.1

pull/8763/head
Cruz Monrreal II 2018-11-15 18:26:09 -06:00
commit 5c1c7bf71f
84 changed files with 792 additions and 671 deletions

View File

@ -16,6 +16,7 @@ hal/storage_abstraction
TESTS/mbed_hal/trng/pithy TESTS/mbed_hal/trng/pithy
features/nanostack/coap-service features/nanostack/coap-service
features/nanostack/sal-stack-nanostack features/nanostack/sal-stack-nanostack
features/nanostack/targets
rtos/TARGET_CORTEX/rtx5 rtos/TARGET_CORTEX/rtx5
TESTS/mbed_hal/trng/pithy TESTS/mbed_hal/trng/pithy
targets targets

View File

@ -132,7 +132,9 @@ matrix:
- git diff --name-only $TRAVIS_BRANCH | grep '.*\.\(h\|c\|hpp\|cpp\)' | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-files-changed.out; - git diff --name-only $TRAVIS_BRANCH | grep '.*\.\(h\|c\|hpp\|cpp\)' | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-files-changed.out;
if [ $(cat astyle-files-changed.out | grep Formatted | wc -l) -ne 0 ]; then if [ $(cat astyle-files-changed.out | grep Formatted | wc -l) -ne 0 ]; then
git --no-pager diff; git --no-pager diff;
echo "Please fix style issues as shown above"; echo "";
echo "AStyle check failed, please fix style issues as shown above";
(exit 1);
else else
echo "Coding style check OK"; echo "Coding style check OK";
fi fi
@ -155,7 +157,6 @@ matrix:
STATUSM="$STATUSM ($(python -c "print '%+d' % ($CURR-$PREV)") files)" STATUSM="$STATUSM ($(python -c "print '%+d' % ($CURR-$PREV)") files)"
fi fi
- bash -c "$STATUS" success "$STATUSM" - bash -c "$STATUS" success "$STATUSM"
- env: - env:
- NAME=events - NAME=events
- EVENTS=events - EVENTS=events

View File

@ -26,7 +26,8 @@ class stubInternetSocket : public InternetSocket {
protected: protected:
nsapi_error_t return_value; nsapi_error_t return_value;
public: public:
stubInternetSocket() { stubInternetSocket()
{
return_value = 0; return_value = 0;
} }
virtual nsapi_error_t connect(const SocketAddress &address) virtual nsapi_error_t connect(const SocketAddress &address)

View File

@ -26,7 +26,8 @@ public:
std::list<nsapi_error_t> return_values; std::list<nsapi_error_t> return_values;
nsapi_error_t return_value; nsapi_error_t return_value;
NetworkStackstub() { NetworkStackstub()
{
return_value = 0; return_value = 0;
} }

View File

@ -121,7 +121,10 @@ public:
/** Desctruct QSPIFBlockDevie /** Desctruct QSPIFBlockDevie
*/ */
~QSPIFBlockDevice() {deinit();} ~QSPIFBlockDevice()
{
deinit();
}
/** Read blocks from a block device /** Read blocks from a block device
* *

View File

@ -266,8 +266,11 @@ public:
* } * }
* @endcode * @endcode
*/ */
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename T, typename R, typename ...Args> template <typename T, typename R, typename ...Args>
int call(T *obj, R (T::*method)(Args ...args), Args ...args); int call(T *obj, R (T::*method)(Args ...args), Args ...args);
// *INDENT-ON*
/** Calls an event on the queue after a specified delay /** Calls an event on the queue after a specified delay
* *
@ -346,8 +349,11 @@ public:
* } * }
* @endcode * @endcode
*/ */
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename T, typename R, typename ...Args> template <typename T, typename R, typename ...Args>
int call_in(int ms, T *obj, R (T::*method)(Args ...args), Args ...args); int call_in(int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
// *INDENT-ON*
/** Calls an event on the queue periodically /** Calls an event on the queue periodically
* *
@ -440,8 +446,11 @@ public:
* } * }
* @endcode * @endcode
*/ */
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename T, typename R, typename ...Args> template <typename T, typename R, typename ...Args>
int call_every(int ms, T *obj, R (T::*method)(Args ...args), Args ...args); int call_every(int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
// *INDENT-ON*
/** Creates an event bound to the event queue /** Creates an event bound to the event queue
* *
@ -483,8 +492,11 @@ public:
* } * }
* @endcode * @endcode
*/ */
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename R, typename ...BoundArgs, typename ...Args> template <typename R, typename ...BoundArgs, typename ...Args>
Event<void(Args...)> event(R (*func)(BoundArgs...), Args ...args); Event<void(Args...)> event(R (*func)(BoundArgs...), Args ...args);
// *INDENT-ON*
/** Creates an event bound to the event queue /** Creates an event bound to the event queue
* *
@ -528,8 +540,11 @@ public:
* } * }
* @endcode * @endcode
*/ */
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename T, typename R, typename ...BoundArgs, typename ...ContextArgs, typename ...Args> template <typename T, typename R, typename ...BoundArgs, typename ...ContextArgs, typename ...Args>
Event<void(Args...)> event(T *obj, R (T::*method)(BoundArgs..., Args...), ContextArgs ...context_args); Event<void(Args...)> event(T *obj, R (T::*method)(BoundArgs..., Args...), ContextArgs ...context_args);
// *INDENT-ON*
/** Creates an event bound to the event queue /** Creates an event bound to the event queue
* *

View File

@ -32,7 +32,10 @@ public:
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb); virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
virtual nsapi_connection_status_t get_connection_status() const; virtual nsapi_connection_status_t get_connection_status() const;
void get_mac_address(uint8_t *buf) const { interface_phy.get_mac_address(buf); } void get_mac_address(uint8_t *buf) const
{
interface_phy.get_mac_address(buf);
}
/** /**
* \brief Callback from C-layer * \brief Callback from C-layer
@ -40,15 +43,24 @@ public:
* */ * */
void network_handler(mesh_connection_status_t status); void network_handler(mesh_connection_status_t status);
int8_t get_interface_id() const { return interface_id; } int8_t get_interface_id() const
int8_t get_driver_id() const { return _device_id; } {
return interface_id;
}
int8_t get_driver_id() const
{
return _device_id;
}
private: private:
NanostackPhy &interface_phy; NanostackPhy &interface_phy;
protected: protected:
Interface(NanostackPhy &phy); Interface(NanostackPhy &phy);
virtual nsapi_error_t register_phy(); virtual nsapi_error_t register_phy();
NanostackPhy &get_phy() const { return interface_phy; } NanostackPhy &get_phy() const
{
return interface_phy;
}
int8_t interface_id; int8_t interface_id;
int8_t _device_id; int8_t _device_id;
rtos::Semaphore connect_semaphore; rtos::Semaphore connect_semaphore;
@ -62,7 +74,10 @@ protected:
class Nanostack::MeshInterface : public Nanostack::Interface { class Nanostack::MeshInterface : public Nanostack::Interface {
protected: protected:
MeshInterface(NanostackRfPhy &phy) : Interface(phy) { } MeshInterface(NanostackRfPhy &phy) : Interface(phy) { }
NanostackRfPhy &get_phy() const { return static_cast<NanostackRfPhy &>(Interface::get_phy()); } NanostackRfPhy &get_phy() const
{
return static_cast<NanostackRfPhy &>(Interface::get_phy());
}
}; };
@ -116,12 +131,18 @@ public:
/** Get the interface ID /** Get the interface ID
/return Interface identifier /return Interface identifier
*/ */
int8_t get_interface_id() const { return _interface->get_interface_id(); } int8_t get_interface_id() const
{
return _interface->get_interface_id();
}
protected: protected:
InterfaceNanostack(); InterfaceNanostack();
virtual Nanostack *get_stack(void); virtual Nanostack *get_stack(void);
Nanostack::Interface *get_interface() const { return _interface; } Nanostack::Interface *get_interface() const
{
return _interface;
}
virtual nsapi_error_t do_initialize() = 0; virtual nsapi_error_t do_initialize() = 0;
Nanostack::Interface *_interface; Nanostack::Interface *_interface;
@ -147,7 +168,10 @@ public:
protected: protected:
MeshInterfaceNanostack() : _phy(NULL) { } MeshInterfaceNanostack() : _phy(NULL) { }
MeshInterfaceNanostack(NanostackRfPhy *phy) : _phy(phy) { } MeshInterfaceNanostack(NanostackRfPhy *phy) : _phy(phy) { }
Nanostack::MeshInterface *get_interface() const { return static_cast<Nanostack::MeshInterface *>(_interface); } Nanostack::MeshInterface *get_interface() const
{
return static_cast<Nanostack::MeshInterface *>(_interface);
}
NanostackRfPhy *_phy; NanostackRfPhy *_phy;
}; };

View File

@ -35,7 +35,10 @@ private:
EthernetInterface(NanostackEthernetPhy &phy) : Interface(phy) {} EthernetInterface(NanostackEthernetPhy &phy) : Interface(phy) {}
nsapi_error_t initialize(); nsapi_error_t initialize();
protected: protected:
NanostackEthernetPhy &get_phy() const { return static_cast<NanostackEthernetPhy &>(Interface::get_phy()); } NanostackEthernetPhy &get_phy() const
{
return static_cast<NanostackEthernetPhy &>(Interface::get_phy());
}
}; };
/** Ethernet interface for Nanostack. /** Ethernet interface for Nanostack.
@ -50,7 +53,10 @@ public:
nsapi_error_t initialize(NanostackEthernetPhy *phy); nsapi_error_t initialize(NanostackEthernetPhy *phy);
protected: protected:
Nanostack::EthernetInterface *get_interface() const { return static_cast<Nanostack::EthernetInterface *>(_interface); } Nanostack::EthernetInterface *get_interface() const
{
return static_cast<Nanostack::EthernetInterface *>(_interface);
}
virtual nsapi_error_t do_initialize(); virtual nsapi_error_t do_initialize();
}; };

View File

@ -8,8 +8,7 @@
#include "ns_trace.h" #include "ns_trace.h"
#define TRACE_GROUP "nslp" #define TRACE_GROUP "nslp"
class Nanostack::LoWPANNDInterface : public Nanostack::MeshInterface class Nanostack::LoWPANNDInterface : public Nanostack::MeshInterface {
{
public: public:
virtual nsapi_error_t bringup(bool dhcp, const char *ip, virtual nsapi_error_t bringup(bool dhcp, const char *ip,
const char *netmask, const char *gw, const char *netmask, const char *gw,

View File

@ -8,8 +8,7 @@
#include "arm_hal_phy.h" #include "arm_hal_phy.h"
#include "EMAC.h" #include "EMAC.h"
class EMACPhy : public NanostackEthernetPhy class EMACPhy : public NanostackEthernetPhy {
{
public: public:
EMACPhy(NanostackMemoryManager &mem, EMAC &m); EMACPhy(NanostackMemoryManager &mem, EMAC &m);
virtual int8_t phy_register(); virtual int8_t phy_register();

View File

@ -19,8 +19,7 @@
#include "mbed_assert.h" #include "mbed_assert.h"
#include "NanostackMemoryManager.h" #include "NanostackMemoryManager.h"
struct ns_stack_mem_t struct ns_stack_mem_t {
{
ns_stack_mem_t *next; ns_stack_mem_t *next;
void *payload; void *payload;
uint32_t len; uint32_t len;

View File

@ -7,8 +7,7 @@
#include "ns_trace.h" #include "ns_trace.h"
#define TRACE_GROUP "nsth" #define TRACE_GROUP "nsth"
class Nanostack::ThreadInterface : public Nanostack::MeshInterface class Nanostack::ThreadInterface : public Nanostack::MeshInterface {
{
public: public:
virtual nsapi_error_t bringup(bool dhcp, const char *ip, virtual nsapi_error_t bringup(bool dhcp, const char *ip,
const char *netmask, const char *gw, const char *netmask, const char *gw,

View File

@ -197,10 +197,11 @@ static void enet_tasklet_poll_network_status(void *param)
} }
} else { } else {
if (tasklet_data_ptr->connection_status != MESH_DISCONNECTED && if (tasklet_data_ptr->connection_status != MESH_DISCONNECTED &&
tasklet_data_ptr->connection_status != MESH_BOOTSTRAP_STARTED) tasklet_data_ptr->connection_status != MESH_BOOTSTRAP_STARTED) {
enet_tasklet_network_state_changed(MESH_DISCONNECTED); enet_tasklet_network_state_changed(MESH_DISCONNECTED);
} }
} }
}
/* /*
* \brief Configure and establish network connection * \brief Configure and establish network connection

View File

@ -246,12 +246,14 @@ void thread_tasklet_poll_network_status(void *param)
} }
} else { } else {
if (thread_tasklet_data_ptr->connection_status != MESH_DISCONNECTED && if (thread_tasklet_data_ptr->connection_status != MESH_DISCONNECTED &&
thread_tasklet_data_ptr->connection_status != MESH_BOOTSTRAP_STARTED) thread_tasklet_data_ptr->connection_status != MESH_BOOTSTRAP_STARTED) {
thread_tasklet_network_state_changed(MESH_DISCONNECTED); thread_tasklet_network_state_changed(MESH_DISCONNECTED);
} }
} }
}
void read_link_configuration() { void read_link_configuration()
{
thread_tasklet_data_ptr->link_config.panId = MBED_CONF_MBED_MESH_API_THREAD_CONFIG_PANID; thread_tasklet_data_ptr->link_config.panId = MBED_CONF_MBED_MESH_API_THREAD_CONFIG_PANID;
TRACE_DETAIL("PANID %x", thread_tasklet_data_ptr->link_config.panId); TRACE_DETAIL("PANID %x", thread_tasklet_data_ptr->link_config.panId);
@ -305,8 +307,7 @@ void thread_tasklet_configure_and_connect_to_network(void)
if (MBED_CONF_MBED_MESH_API_THREAD_DEVICE_TYPE == MESH_DEVICE_TYPE_THREAD_MINIMAL_END_DEVICE) { if (MBED_CONF_MBED_MESH_API_THREAD_DEVICE_TYPE == MESH_DEVICE_TYPE_THREAD_MINIMAL_END_DEVICE) {
thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_HOST; thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_HOST;
} } else if (MBED_CONF_MBED_MESH_API_THREAD_DEVICE_TYPE == MESH_DEVICE_TYPE_THREAD_SLEEPY_END_DEVICE) {
else if (MBED_CONF_MBED_MESH_API_THREAD_DEVICE_TYPE == MESH_DEVICE_TYPE_THREAD_SLEEPY_END_DEVICE) {
thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_SLEEPY_HOST; thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_SLEEPY_HOST;
} else { } else {
thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_ROUTER; thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_ROUTER;

View File

@ -36,8 +36,7 @@ static const fhss_api_t *fhss_active_handle = NULL;
static EventQueue *equeue; static EventQueue *equeue;
#endif #endif
struct fhss_timeout_s struct fhss_timeout_s {
{
void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t); void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t);
uint32_t start_time; uint32_t start_time;
uint32_t stop_time; uint32_t stop_time;

View File

@ -229,8 +229,7 @@ static int nvm_fsm_update(cs_context_t *cs_context)
int ret_val = 0; int ret_val = 0;
tr_debug("nvm_fsm_update() state=%d", (int)cs_context->state); tr_debug("nvm_fsm_update() state=%d", (int)cs_context->state);
switch (cs_context->state) switch (cs_context->state) {
{
case NVM_STATE_UNINIT_DONE: case NVM_STATE_UNINIT_DONE:
cs_context->client_cb(cs_context->client_status, cs_context->client_context); cs_context->client_cb(cs_context->client_status, cs_context->client_context);
cs_context->state = NVM_STATE_NONE; cs_context->state = NVM_STATE_NONE;

View File

@ -22,8 +22,7 @@ uint8_t buf[100];
uint16_t buf_len; uint16_t buf_len;
uint16_t data_len; uint16_t data_len;
typedef struct typedef struct {
{
platform_nvm_status status; platform_nvm_status status;
void *ctx; void *ctx;
} test_platform_nvm_api_callback_t; } test_platform_nvm_api_callback_t;

View File

@ -101,8 +101,7 @@ static int32_t test_cfstore_write(ARM_CFSTORE_HANDLE hkey, const char* data, ARM
return cfstore_stub.write_ret_val; return cfstore_stub.write_ret_val;
} }
ARM_CFSTORE_DRIVER cfstore_driver = ARM_CFSTORE_DRIVER cfstore_driver = {
{
.Close = test_cfstore_close, .Close = test_cfstore_close,
.Create = test_cfstore_create, .Create = test_cfstore_create,
.Delete = test_cfstore_delete, .Delete = test_cfstore_delete,

View File

@ -17,26 +17,20 @@ void ns_dyn_mem_init(uint8_t *heap, uint16_t h_size, void (*passed_fptr)(heap_fa
void *ns_dyn_mem_alloc(int16_t alloc_size) void *ns_dyn_mem_alloc(int16_t alloc_size)
{ {
if (nsdynmemlib_stub.returnCounter > 0) if (nsdynmemlib_stub.returnCounter > 0) {
{
nsdynmemlib_stub.returnCounter--; nsdynmemlib_stub.returnCounter--;
return malloc(alloc_size); return malloc(alloc_size);
} } else {
else
{
return (nsdynmemlib_stub.expectedPointer); return (nsdynmemlib_stub.expectedPointer);
} }
} }
void *ns_dyn_mem_temporary_alloc(int16_t alloc_size) void *ns_dyn_mem_temporary_alloc(int16_t alloc_size)
{ {
if (nsdynmemlib_stub.returnCounter > 0) if (nsdynmemlib_stub.returnCounter > 0) {
{
nsdynmemlib_stub.returnCounter--; nsdynmemlib_stub.returnCounter--;
return malloc(alloc_size); return malloc(alloc_size);
} } else {
else
{
return (nsdynmemlib_stub.expectedPointer); return (nsdynmemlib_stub.expectedPointer);
} }
} }

View File

@ -19,7 +19,8 @@ void eventOS_timeout_cancel(timeout_t *t)
} }
void test_eventOS_timeout_trigger() { void test_eventOS_timeout_trigger()
{
test_callback(test_args); test_callback(test_args);
} }

View File

@ -69,7 +69,10 @@ public:
bool open(void); bool open(void);
int accept(NanostackSocket *accepted_socket, ns_address_t *addr); int accept(NanostackSocket *accepted_socket, ns_address_t *addr);
void close(void); void close(void);
bool closed(void) {return SOCKET_MODE_CLOSED == mode;} bool closed(void)
{
return SOCKET_MODE_CLOSED == mode;
}
bool is_connecting(void); bool is_connecting(void);
void set_connecting(ns_address_t *addr); void set_connecting(ns_address_t *addr);
bool is_connected(void); bool is_connected(void);
@ -106,11 +109,16 @@ static NanostackSocket * socket_tbl[NS_INTERFACE_SOCKETS_MAX];
nsapi_error_t map_mesh_error(mesh_error_t err) nsapi_error_t map_mesh_error(mesh_error_t err)
{ {
switch (err) { switch (err) {
case MESH_ERROR_NONE: return 0; case MESH_ERROR_NONE:
case MESH_ERROR_MEMORY: return NSAPI_ERROR_NO_MEMORY; return 0;
case MESH_ERROR_PARAM: return NSAPI_ERROR_UNSUPPORTED; case MESH_ERROR_MEMORY:
case MESH_ERROR_STATE: return NSAPI_ERROR_DEVICE_ERROR; return NSAPI_ERROR_NO_MEMORY;
default: return NSAPI_ERROR_DEVICE_ERROR; case MESH_ERROR_PARAM:
return NSAPI_ERROR_UNSUPPORTED;
case MESH_ERROR_STATE:
return NSAPI_ERROR_DEVICE_ERROR;
default:
return NSAPI_ERROR_DEVICE_ERROR;
} }
} }
@ -142,10 +150,12 @@ static int8_t find_interface_by_address(const uint8_t target_addr[16])
return -1; return -1;
} }
void* NanostackSocket::operator new(std::size_t sz) { void *NanostackSocket::operator new (std::size_t sz)
{
return MALLOC(sz); return MALLOC(sz);
} }
void NanostackSocket::operator delete(void* ptr) { void NanostackSocket::operator delete (void *ptr)
{
FREE(ptr); FREE(ptr);
} }
@ -296,7 +306,8 @@ void NanostackSocket::signal_event()
} }
} }
void NanostackSocket::socket_callback(void *cb) { void NanostackSocket::socket_callback(void *cb)
{
nanostack_assert_locked(); nanostack_assert_locked();
socket_callback_t *sock_cb = (socket_callback_t *) cb; socket_callback_t *sock_cb = (socket_callback_t *) cb;
@ -979,7 +990,8 @@ void Nanostack::socket_attach(void *handle, void (*callback)(void *), void *id)
tr_debug("socket_attach(socket=%p) sock_id=%d", socket, socket->socket_id); tr_debug("socket_attach(socket=%p) sock_id=%d", socket, socket->socket_id);
} }
Nanostack &Nanostack::get_instance() { Nanostack &Nanostack::get_instance()
{
static Nanostack nanostack; static Nanostack nanostack;
return nanostack; return nanostack;
} }
@ -989,7 +1001,8 @@ Nanostack &Nanostack::get_instance() {
#define NANOSTACK 0x99119911 #define NANOSTACK 0x99119911
#if MBED_CONF_NSAPI_DEFAULT_STACK == NANOSTACK #if MBED_CONF_NSAPI_DEFAULT_STACK == NANOSTACK
#undef NANOSTACK #undef NANOSTACK
OnboardNetworkStack &OnboardNetworkStack::get_default_instance() { OnboardNetworkStack &OnboardNetworkStack::get_default_instance()
{
return Nanostack::get_instance(); return Nanostack::get_instance();
} }
#endif #endif

View File

@ -27,11 +27,13 @@
class NanostackLockGuard { class NanostackLockGuard {
public: public:
NanostackLockGuard() { NanostackLockGuard()
{
eventOS_scheduler_mutex_wait(); eventOS_scheduler_mutex_wait();
} }
~NanostackLockGuard() { ~NanostackLockGuard()
{
eventOS_scheduler_mutex_release(); eventOS_scheduler_mutex_release();
} }

View File

@ -48,12 +48,18 @@ public:
* @return Device driver ID or a negative error * @return Device driver ID or a negative error
* code on failure * code on failure
*/ */
virtual int8_t phy_register() { return rf_register();} virtual int8_t phy_register()
{
return rf_register();
}
/** Unregister this physical interface /** Unregister this physical interface
* *
*/ */
virtual void unregister() { rf_unregister(); } virtual void unregister()
{
rf_unregister();
}
}; };
#endif /* NANOSTACK_RF_PHY_H_ */ #endif /* NANOSTACK_RF_PHY_H_ */

View File

@ -78,14 +78,16 @@ static timeout_t *eventOS_timeout_at_(void (*callback)(void *), void *arg, uint3
.data_ptr = timeout .data_ptr = timeout
}; };
if (period) if (period) {
storage = eventOS_event_timer_request_every(&event, period); storage = eventOS_event_timer_request_every(&event, period);
else } else {
storage = eventOS_event_timer_request_at(&event, at); storage = eventOS_event_timer_request_at(&event, at);
}
timeout->event = storage; timeout->event = storage;
if (storage) if (storage) {
return timeout; return timeout;
}
FAIL: FAIL:
ns_dyn_mem_free(timeout); ns_dyn_mem_free(timeout);
return NULL; return NULL;
@ -103,8 +105,9 @@ timeout_t *eventOS_timeout_every_ms(void (*callback)(void *), uint32_t every, vo
void eventOS_timeout_cancel(timeout_t *t) void eventOS_timeout_cancel(timeout_t *t)
{ {
if (!t) if (!t) {
return; return;
}
eventOS_cancel(t->event); eventOS_cancel(t->event);

View File

@ -20,32 +20,69 @@
#ifdef CELLULAR_DEVICE #ifdef CELLULAR_DEVICE
using namespace mbed; using namespace mbed;
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use CellularBase::get_default_instance() instead.") MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use CellularBase::get_default_instance() instead.")
class OnboardCellularInterface : public CellularBase class OnboardCellularInterface : public CellularBase {
{
public: public:
OnboardCellularInterface() { OnboardCellularInterface()
{
context = CellularContext::get_default_instance(); context = CellularContext::get_default_instance();
MBED_ASSERT(context != NULL); MBED_ASSERT(context != NULL);
} }
public: // from NetworkInterface public: // from NetworkInterface
virtual nsapi_error_t set_blocking(bool blocking) {return context->set_blocking(blocking);} virtual nsapi_error_t set_blocking(bool blocking)
virtual NetworkStack *get_stack() {return context->get_stack();} {
virtual const char *get_ip_address() {return context->get_ip_address();} return context->set_blocking(blocking);
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb) {context->attach(status_cb);} }
virtual nsapi_error_t connect() {return context->connect();} virtual NetworkStack *get_stack()
virtual nsapi_error_t disconnect() {return context->disconnect();} {
return context->get_stack();
}
virtual const char *get_ip_address()
{
return context->get_ip_address();
}
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb)
{
context->attach(status_cb);
}
virtual nsapi_error_t connect()
{
return context->connect();
}
virtual nsapi_error_t disconnect()
{
return context->disconnect();
}
// from CellularBase // from CellularBase
virtual void set_plmn(const char *plmn) {context->set_plmn(plmn);} virtual void set_plmn(const char *plmn)
virtual void set_sim_pin(const char *sim_pin) {context->set_sim_pin(sim_pin);} {
context->set_plmn(plmn);
}
virtual void set_sim_pin(const char *sim_pin)
{
context->set_sim_pin(sim_pin);
}
virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0, const char *uname = 0, virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0, const char *uname = 0,
const char *pwd = 0) const char *pwd = 0)
{return context->connect(sim_pin, apn, uname, pwd);} {
return context->connect(sim_pin, apn, uname, pwd);
}
virtual void set_credentials(const char *apn, const char *uname = 0, const char *pwd = 0) virtual void set_credentials(const char *apn, const char *uname = 0, const char *pwd = 0)
{context->set_credentials(apn, uname, pwd);} {
virtual const char *get_netmask() {return context->get_netmask();} context->set_credentials(apn, uname, pwd);
virtual const char *get_gateway() {return context->get_gateway();} }
virtual bool is_connected() {return context->is_connected();} virtual const char *get_netmask()
{
return context->get_netmask();
}
virtual const char *get_gateway()
{
return context->get_gateway();
}
virtual bool is_connected()
{
return context->is_connected();
}
private: private:
CellularContext *context; CellularContext *context;

View File

@ -39,9 +39,10 @@ namespace span_detail {
// If From type is convertible to To type, then the compilation constant value is // If From type is convertible to To type, then the compilation constant value is
// true; otherwise, it is false. // true; otherwise, it is false.
template<typename From, typename To> template<typename From, typename To>
class is_convertible class is_convertible {
{ struct true_type {
struct true_type { char x[512]; }; char x[512];
};
struct false_type { }; struct false_type { };
static const From &generator(); static const From &generator();
@ -293,6 +294,8 @@ struct Span {
MBED_ASSERT(Extent == 0 || first != NULL); MBED_ASSERT(Extent == 0 || first != NULL);
} }
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/** /**
* Construct a Span from the reference to an array. * Construct a Span from the reference to an array.
* *
@ -322,6 +325,7 @@ struct Span {
"OtherElementType(*)[] should be convertible to ElementType (*)[]" "OtherElementType(*)[] should be convertible to ElementType (*)[]"
); );
} }
// *INDENT-ON*
/** /**
* Return the size of the sequence viewed. * Return the size of the sequence viewed.
@ -409,6 +413,8 @@ struct Span {
return Span<element_type, Count>(_data + (Extent - Count), Count); return Span<element_type, Count>(_data + (Extent - Count), Count);
} }
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/** /**
* Create a subspan that is a view of other Count elements; the view starts at * Create a subspan that is a view of other Count elements; the view starts at
* element Offset. * element Offset.
@ -439,6 +445,7 @@ struct Span {
Count == SPAN_DYNAMIC_EXTENT ? Extent - Offset : Count Count == SPAN_DYNAMIC_EXTENT ? Extent - Offset : Count
); );
} }
// *INDENT-ON*
/** /**
* Create a new Span over the first @p count elements of the existing view. * Create a new Span over the first @p count elements of the existing view.
@ -579,6 +586,8 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
MBED_ASSERT(first != NULL || (last - first) == 0); MBED_ASSERT(first != NULL || (last - first) == 0);
} }
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/** /**
* Construct a Span from the reference to an array. * Construct a Span from the reference to an array.
* *
@ -611,6 +620,7 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
"OtherElementType(*)[] should be convertible to ElementType (*)[]" "OtherElementType(*)[] should be convertible to ElementType (*)[]"
); );
} }
// *INDENT-ON*
/** /**
* Return the size of the array viewed. * Return the size of the array viewed.
@ -804,6 +814,8 @@ bool operator==(const Span<T, LhsExtent> &lhs, const Span<U, RhsExtent> &rhs)
return std::equal(lhs.data(), lhs.data() + lhs.size(), rhs.data()); return std::equal(lhs.data(), lhs.data() + lhs.size(), rhs.data());
} }
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/** /**
* Equality operation between a Span and a reference to a C++ array. * Equality operation between a Span and a reference to a C++ array.
* *
@ -959,7 +971,7 @@ Span<const T, Extent> make_const_Span(const T (&elements)[Extent])
{ {
return Span<const T, Extent>(elements); return Span<const T, Extent>(elements);
} }
// *INDENT-ON*
/** /**
* Generate a Span to a const content from a pointer to a C/C++ array. * Generate a Span to a const content from a pointer to a C/C++ array.
* *

View File

@ -96,7 +96,8 @@ public:
* *
* @note You may call this function from ISR context. * @note You may call this function from ISR context.
*/ */
T* alloc(uint32_t millisec=0) { T *alloc(uint32_t millisec = 0)
{
return _pool.alloc(); return _pool.alloc();
} }
@ -108,7 +109,8 @@ public:
* *
* @note You may call this function from ISR context. * @note You may call this function from ISR context.
*/ */
T* calloc(uint32_t millisec=0) { T *calloc(uint32_t millisec = 0)
{
return _pool.calloc(); return _pool.calloc();
} }
@ -120,7 +122,8 @@ public:
* *
* @note You may call this function from ISR context. * @note You may call this function from ISR context.
*/ */
osStatus put(T *mptr) { osStatus put(T *mptr)
{
return _queue.put(mptr); return _queue.put(mptr);
} }
@ -136,7 +139,8 @@ public:
* *
* @note You may call this function from ISR context if the millisec parameter is set to 0. * @note You may call this function from ISR context if the millisec parameter is set to 0.
*/ */
osEvent get(uint32_t millisec=osWaitForever) { osEvent get(uint32_t millisec = osWaitForever)
{
osEvent evt = _queue.get(millisec); osEvent evt = _queue.get(millisec);
if (evt.status == osEventMessage) { if (evt.status == osEventMessage) {
evt.status = osEventMail; evt.status = osEventMail;
@ -152,7 +156,8 @@ public:
* *
* @note You may call this function from ISR context. * @note You may call this function from ISR context.
*/ */
osStatus free(T *mptr) { osStatus free(T *mptr)
{
return _pool.free(mptr); return _pool.free(mptr);
} }

View File

@ -143,7 +143,8 @@ public:
* parameter is set to 0. * parameter is set to 0.
* *
*/ */
osStatus put(T* data, uint32_t millisec=0, uint8_t prio=0) { osStatus put(T *data, uint32_t millisec = 0, uint8_t prio = 0)
{
return osMessageQueuePut(_id, &data, prio, millisec); return osMessageQueuePut(_id, &data, prio, millisec);
} }
@ -182,7 +183,8 @@ public:
* @note You may call this function from ISR context if the millisec * @note You may call this function from ISR context if the millisec
* parameter is set to 0. * parameter is set to 0.
*/ */
osEvent get(uint32_t millisec=osWaitForever) { osEvent get(uint32_t millisec = osWaitForever)
{
osEvent event; osEvent event;
T *data = NULL; T *data = NULL;
osStatus_t res = osMessageQueueGet(_id, &data, NULL, millisec); osStatus_t res = osMessageQueueGet(_id, &data, NULL, millisec);

View File

@ -42,7 +42,7 @@ using namespace mbed;
static rtos::internal::SysTimer *os_timer; static rtos::internal::SysTimer *os_timer;
static uint64_t os_timer_data[sizeof(rtos::internal::SysTimer) / 8]; static uint64_t os_timer_data[sizeof(rtos::internal::SysTimer) / 8];
/// Enable System Timer. // Enable System Timer.
void OS_Tick_Enable(void) void OS_Tick_Enable(void)
{ {
// Do not use SingletonPtr since this relies on the RTOS // Do not use SingletonPtr since this relies on the RTOS
@ -55,19 +55,19 @@ void OS_Tick_Enable(void)
os_timer->schedule_tick(); os_timer->schedule_tick();
} }
/// Disable System Timer. // Disable System Timer.
void OS_Tick_Disable(void) void OS_Tick_Disable(void)
{ {
os_timer->cancel_tick(); os_timer->cancel_tick();
} }
/// Acknowledge System Timer IRQ. // Acknowledge System Timer IRQ.
void OS_Tick_AcknowledgeIRQ(void) void OS_Tick_AcknowledgeIRQ(void)
{ {
} }
/// Get System Timer count. // Get System Timer count.
uint32_t OS_Tick_GetCount(void) uint32_t OS_Tick_GetCount(void)
{ {
return os_timer->get_time() & 0xFFFFFFFF; return os_timer->get_time() & 0xFFFFFFFF;