Skip to content

Commit 567eedc

Browse files
committed
nanostack: fix astyle coding style
1 parent 884a774 commit 567eedc

33 files changed

+846
-781
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

features/nanostack/mbed-mesh-api/mbed-mesh-api/MeshInterfaceNanostack.h

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,35 @@ class Nanostack::Interface : public OnboardNetworkStack::Interface, private mbed
3232
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
3333
virtual nsapi_connection_status_t get_connection_status() const;
3434

35-
void get_mac_address(uint8_t *buf) const { interface_phy.get_mac_address(buf); }
35+
void get_mac_address(uint8_t *buf) const
36+
{
37+
interface_phy.get_mac_address(buf);
38+
}
3639

3740
/**
3841
* \brief Callback from C-layer
3942
* \param status state of the network
4043
* */
4144
void network_handler(mesh_connection_status_t status);
4245

43-
int8_t get_interface_id() const { return interface_id; }
44-
int8_t get_driver_id() const { return _device_id; }
46+
int8_t get_interface_id() const
47+
{
48+
return interface_id;
49+
}
50+
int8_t get_driver_id() const
51+
{
52+
return _device_id;
53+
}
4554

4655
private:
4756
NanostackPhy &interface_phy;
4857
protected:
4958
Interface(NanostackPhy &phy);
5059
virtual nsapi_error_t register_phy();
51-
NanostackPhy &get_phy() const { return interface_phy; }
60+
NanostackPhy &get_phy() const
61+
{
62+
return interface_phy;
63+
}
5264
int8_t interface_id;
5365
int8_t _device_id;
5466
rtos::Semaphore connect_semaphore;
@@ -62,7 +74,10 @@ class Nanostack::Interface : public OnboardNetworkStack::Interface, private mbed
6274
class Nanostack::MeshInterface : public Nanostack::Interface {
6375
protected:
6476
MeshInterface(NanostackRfPhy &phy) : Interface(phy) { }
65-
NanostackRfPhy &get_phy() const { return static_cast<NanostackRfPhy &>(Interface::get_phy()); }
77+
NanostackRfPhy &get_phy() const
78+
{
79+
return static_cast<NanostackRfPhy &>(Interface::get_phy());
80+
}
6681
};
6782

6883

@@ -116,12 +131,18 @@ class InterfaceNanostack : public virtual NetworkInterface {
116131
/** Get the interface ID
117132
/return Interface identifier
118133
*/
119-
int8_t get_interface_id() const { return _interface->get_interface_id(); }
134+
int8_t get_interface_id() const
135+
{
136+
return _interface->get_interface_id();
137+
}
120138

121139
protected:
122140
InterfaceNanostack();
123141
virtual Nanostack *get_stack(void);
124-
Nanostack::Interface *get_interface() const { return _interface; }
142+
Nanostack::Interface *get_interface() const
143+
{
144+
return _interface;
145+
}
125146
virtual nsapi_error_t do_initialize() = 0;
126147

127148
Nanostack::Interface *_interface;
@@ -147,7 +168,10 @@ class MeshInterfaceNanostack : public InterfaceNanostack, public MeshInterface,
147168
protected:
148169
MeshInterfaceNanostack() : _phy(NULL) { }
149170
MeshInterfaceNanostack(NanostackRfPhy *phy) : _phy(phy) { }
150-
Nanostack::MeshInterface *get_interface() const { return static_cast<Nanostack::MeshInterface *>(_interface); }
171+
Nanostack::MeshInterface *get_interface() const
172+
{
173+
return static_cast<Nanostack::MeshInterface *>(_interface);
174+
}
151175
NanostackRfPhy *_phy;
152176
};
153177

features/nanostack/mbed-mesh-api/mbed-mesh-api/NanostackEthernetInterface.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class Nanostack::EthernetInterface : public Nanostack::Interface {
3535
EthernetInterface(NanostackEthernetPhy &phy) : Interface(phy) {}
3636
nsapi_error_t initialize();
3737
protected:
38-
NanostackEthernetPhy &get_phy() const { return static_cast<NanostackEthernetPhy &>(Interface::get_phy()); }
38+
NanostackEthernetPhy &get_phy() const
39+
{
40+
return static_cast<NanostackEthernetPhy &>(Interface::get_phy());
41+
}
3942
};
4043

4144
/** Ethernet interface for Nanostack.
@@ -50,7 +53,10 @@ class NanostackEthernetInterface : public InterfaceNanostack, public EthInterfac
5053
nsapi_error_t initialize(NanostackEthernetPhy *phy);
5154

5255
protected:
53-
Nanostack::EthernetInterface *get_interface() const { return static_cast<Nanostack::EthernetInterface *>(_interface); }
56+
Nanostack::EthernetInterface *get_interface() const
57+
{
58+
return static_cast<Nanostack::EthernetInterface *>(_interface);
59+
}
5460
virtual nsapi_error_t do_initialize();
5561

5662
};

features/nanostack/mbed-mesh-api/source/LoWPANNDInterface.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#include "ns_trace.h"
99
#define TRACE_GROUP "nslp"
1010

11-
class Nanostack::LoWPANNDInterface : public Nanostack::MeshInterface
12-
{
11+
class Nanostack::LoWPANNDInterface : public Nanostack::MeshInterface {
1312
public:
1413
virtual nsapi_error_t bringup(bool dhcp, const char *ip,
1514
const char *netmask, const char *gw,
@@ -29,7 +28,7 @@ class Nanostack::LoWPANNDInterface : public Nanostack::MeshInterface
2928

3029
Nanostack::LoWPANNDInterface *LoWPANNDInterface::get_interface() const
3130
{
32-
return static_cast<Nanostack::LoWPANNDInterface*>(_interface);
31+
return static_cast<Nanostack::LoWPANNDInterface *>(_interface);
3332
}
3433

3534
nsapi_error_t LoWPANNDInterface::do_initialize()

features/nanostack/mbed-mesh-api/source/MeshInterfaceNanostack.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void Nanostack::Interface::attach(
6969
}
7070

7171
Nanostack::Interface::Interface(NanostackPhy &phy) : interface_phy(phy), interface_id(-1), _device_id(-1),
72-
_connect_status(NSAPI_STATUS_DISCONNECTED), _previous_connection_status(NSAPI_STATUS_DISCONNECTED), _blocking(true)
72+
_connect_status(NSAPI_STATUS_DISCONNECTED), _previous_connection_status(NSAPI_STATUS_DISCONNECTED), _blocking(true)
7373
{
7474
mesh_system_init();
7575
}
@@ -119,7 +119,7 @@ nsapi_error_t MeshInterfaceNanostack::initialize(NanostackRfPhy *phy)
119119
void Nanostack::Interface::network_handler(mesh_connection_status_t status)
120120
{
121121
if ((status == MESH_CONNECTED || status == MESH_CONNECTED_LOCAL ||
122-
status == MESH_CONNECTED_GLOBAL) && _blocking) {
122+
status == MESH_CONNECTED_GLOBAL) && _blocking) {
123123
connect_semaphore.release();
124124
}
125125

@@ -131,10 +131,10 @@ void Nanostack::Interface::network_handler(mesh_connection_status_t status)
131131
_connect_status = NSAPI_STATUS_LOCAL_UP;
132132
}
133133
if (arm_net_address_get(interface_id, ADDR_IPV6_GP, temp_ipv6_global) == 0
134-
&& (memcmp(temp_ipv6_global, temp_ipv6_local, 16) != 0)) {
134+
&& (memcmp(temp_ipv6_global, temp_ipv6_local, 16) != 0)) {
135135
_connect_status = NSAPI_STATUS_GLOBAL_UP;
136136
}
137-
} else if (status == MESH_CONNECTED_LOCAL ) {
137+
} else if (status == MESH_CONNECTED_LOCAL) {
138138
_connect_status = NSAPI_STATUS_LOCAL_UP;
139139
} else if (status == MESH_CONNECTED_GLOBAL) {
140140
_connect_status = NSAPI_STATUS_GLOBAL_UP;

features/nanostack/mbed-mesh-api/source/NanostackEMACInterface.cpp

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88
#include "arm_hal_phy.h"
99
#include "EMAC.h"
1010

11-
class EMACPhy : public NanostackEthernetPhy
12-
{
11+
class EMACPhy : public NanostackEthernetPhy {
1312
public:
1413
EMACPhy(NanostackMemoryManager &mem, EMAC &m);
1514
virtual int8_t phy_register();
1615
virtual void get_mac_address(uint8_t *mac);
1716
virtual void set_mac_address(uint8_t *mac);
1817

19-
int8_t address_write(phy_address_type_e , uint8_t *);
20-
int8_t tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle,data_protocol_e data_flow);
18+
int8_t address_write(phy_address_type_e, uint8_t *);
19+
int8_t tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle, data_protocol_e data_flow);
2120

2221
void emac_phy_rx(emac_mem_buf_t *mem);
2322

@@ -34,65 +33,65 @@ static EMACPhy *single_phy;
3433

3534
extern "C"
3635
{
37-
static int8_t emac_phy_address_write(phy_address_type_e address_type, uint8_t *address_ptr)
38-
{
39-
return single_phy->address_write(address_type, address_ptr);
40-
}
36+
static int8_t emac_phy_address_write(phy_address_type_e address_type, uint8_t *address_ptr)
37+
{
38+
return single_phy->address_write(address_type, address_ptr);
39+
}
4140

42-
static int8_t emac_phy_interface_state_control(phy_interface_state_e, uint8_t)
43-
{
44-
return -1;
45-
}
41+
static int8_t emac_phy_interface_state_control(phy_interface_state_e, uint8_t)
42+
{
43+
return -1;
44+
}
4645

47-
static int8_t emac_phy_tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle,data_protocol_e data_flow)
48-
{
49-
return single_phy->tx(data_ptr, data_len, tx_handle, data_flow);
50-
}
46+
static int8_t emac_phy_tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle, data_protocol_e data_flow)
47+
{
48+
return single_phy->tx(data_ptr, data_len, tx_handle, data_flow);
49+
}
5150

52-
EMACPhy::EMACPhy(NanostackMemoryManager &mem, EMAC &m) : memory_manager(mem), emac(m), device_id(-1)
53-
{
54-
/* Same default address logic as lwIP glue uses */
51+
EMACPhy::EMACPhy(NanostackMemoryManager &mem, EMAC &m) : memory_manager(mem), emac(m), device_id(-1)
52+
{
53+
/* Same default address logic as lwIP glue uses */
5554
#if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE)
56-
mac_addr[0] = MBED_MAC_ADDR_0;
57-
mac_addr[1] = MBED_MAC_ADDR_1;
58-
mac_addr[2] = MBED_MAC_ADDR_2;
59-
mac_addr[3] = MBED_MAC_ADDR_3;
60-
mac_addr[4] = MBED_MAC_ADDR_4;
61-
mac_addr[5] = MBED_MAC_ADDR_5;
55+
mac_addr[0] = MBED_MAC_ADDR_0;
56+
mac_addr[1] = MBED_MAC_ADDR_1;
57+
mac_addr[2] = MBED_MAC_ADDR_2;
58+
mac_addr[3] = MBED_MAC_ADDR_3;
59+
mac_addr[4] = MBED_MAC_ADDR_4;
60+
mac_addr[5] = MBED_MAC_ADDR_5;
6261
#else
63-
mbed_mac_address((char *) mac_addr);
62+
mbed_mac_address((char *) mac_addr);
6463
#endif
65-
/* We have a default MAC address, so do don't force them to supply one */
66-
/* They may or may not update hwaddr with their address */
67-
emac.get_hwaddr(mac_addr);
68-
}
64+
/* We have a default MAC address, so do don't force them to supply one */
65+
/* They may or may not update hwaddr with their address */
66+
emac.get_hwaddr(mac_addr);
67+
}
6968

7069

71-
void EMACPhy::emac_phy_rx(emac_mem_buf_t *mem)
72-
{
73-
const uint8_t *ptr = NULL;
74-
uint8_t *tmpbuf = NULL;
75-
uint32_t total_len;
76-
77-
if (memory_manager.get_next(mem) == NULL) {
78-
// Easy contiguous case
79-
ptr = static_cast<const uint8_t*>(memory_manager.get_ptr(mem));
80-
total_len = memory_manager.get_len(mem);
81-
} else {
82-
// Nanostack can't accept chunked data - make temporary contiguous copy
83-
total_len = memory_manager.get_total_len(mem);
84-
ptr = tmpbuf = static_cast<uint8_t *>(ns_dyn_mem_temporary_alloc(total_len));
85-
if (tmpbuf) {
86-
memory_manager.copy_from_buf(tmpbuf, total_len, mem);
70+
void EMACPhy::emac_phy_rx(emac_mem_buf_t *mem)
71+
{
72+
const uint8_t *ptr = NULL;
73+
uint8_t *tmpbuf = NULL;
74+
uint32_t total_len;
75+
76+
if (memory_manager.get_next(mem) == NULL) {
77+
// Easy contiguous case
78+
ptr = static_cast<const uint8_t *>(memory_manager.get_ptr(mem));
79+
total_len = memory_manager.get_len(mem);
80+
} else {
81+
// Nanostack can't accept chunked data - make temporary contiguous copy
82+
total_len = memory_manager.get_total_len(mem);
83+
ptr = tmpbuf = static_cast<uint8_t *>(ns_dyn_mem_temporary_alloc(total_len));
84+
if (tmpbuf) {
85+
memory_manager.copy_from_buf(tmpbuf, total_len, mem);
86+
}
8787
}
88-
}
8988

90-
if (ptr && phy.phy_rx_cb) {
91-
phy.phy_rx_cb(ptr, total_len, 0xff, 0, device_id);
89+
if (ptr && phy.phy_rx_cb) {
90+
phy.phy_rx_cb(ptr, total_len, 0xff, 0, device_id);
91+
}
92+
ns_dyn_mem_free(tmpbuf);
93+
memory_manager.free(mem);
9294
}
93-
ns_dyn_mem_free(tmpbuf);
94-
memory_manager.free(mem);
95-
}
9695

9796
} // extern "C"
9897

@@ -106,7 +105,7 @@ int8_t EMACPhy::address_write(phy_address_type_e address_type, uint8_t *address_
106105
return 0;
107106
}
108107

109-
int8_t EMACPhy::tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle,data_protocol_e data_flow)
108+
int8_t EMACPhy::tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle, data_protocol_e data_flow)
110109
{
111110
emac_mem_buf_t *mem = memory_manager.alloc_pool(data_len, 0);
112111
if (!mem) {
@@ -126,7 +125,7 @@ int8_t EMACPhy::phy_register()
126125

127126
phy.PHY_MAC = mac_addr;
128127
phy.address_write = emac_phy_address_write;
129-
phy.driver_description = const_cast<char*>("ETH");
128+
phy.driver_description = const_cast<char *>("ETH");
130129
phy.link_type = PHY_LINK_ETHERNET_TYPE;
131130
phy.phy_MTU = 0;
132131
phy.phy_header_length = 0;
@@ -153,9 +152,9 @@ int8_t EMACPhy::phy_register()
153152
emac.set_all_multicast(true);
154153

155154
device_id = arm_net_phy_register(&phy);
156-
// driver_readiness_status_callback = driver_status_cb;
155+
// driver_readiness_status_callback = driver_status_cb;
157156

158-
if (device_id < 0){
157+
if (device_id < 0) {
159158
//tr_error("Ethernet Driver failed to register with Stack. RetCode=%i", eth_driver_enabled);
160159
//driver_readiness_status_callback(0, eth_interface_id);
161160
emac.power_down();
@@ -188,7 +187,7 @@ nsapi_error_t Nanostack::add_ethernet_interface(EMAC &emac, bool default_if, Nan
188187
}
189188

190189
if (mac_addr) {
191-
single_phy->set_mac_address(const_cast<uint8_t*>(mac_addr));
190+
single_phy->set_mac_address(const_cast<uint8_t *>(mac_addr));
192191
}
193192

194193
Nanostack::EthernetInterface *interface;

features/nanostack/mbed-mesh-api/source/NanostackEthernetInterface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ nsapi_error_t NanostackEthernetInterface::initialize(NanostackEthernetPhy *phy)
4444
}
4545

4646
return get_interface()->initialize();
47-
}
47+
}
4848

4949
nsapi_error_t Nanostack::EthernetInterface::bringup(bool dhcp, const char *ip,
50-
const char *netmask, const char *gw,
51-
nsapi_ip_stack_t stack, bool blocking)
50+
const char *netmask, const char *gw,
51+
nsapi_ip_stack_t stack, bool blocking)
5252
{
5353
if (stack == IPV4_STACK) {
5454
return NSAPI_ERROR_UNSUPPORTED;

features/nanostack/mbed-mesh-api/source/NanostackMemoryManager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
#include "mbed_assert.h"
2020
#include "NanostackMemoryManager.h"
2121

22-
struct ns_stack_mem_t
23-
{
22+
struct ns_stack_mem_t {
2423
ns_stack_mem_t *next;
2524
void *payload;
2625
uint32_t len;

features/nanostack/mbed-mesh-api/source/ThreadInterface.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#include "ns_trace.h"
88
#define TRACE_GROUP "nsth"
99

10-
class Nanostack::ThreadInterface : public Nanostack::MeshInterface
11-
{
10+
class Nanostack::ThreadInterface : public Nanostack::MeshInterface {
1211
public:
1312
virtual nsapi_error_t bringup(bool dhcp, const char *ip,
1413
const char *netmask, const char *gw,
@@ -73,7 +72,7 @@ class Nanostack::ThreadInterface : public Nanostack::MeshInterface
7372

7473
Nanostack::ThreadInterface *ThreadInterface::get_interface() const
7574
{
76-
return static_cast<Nanostack::ThreadInterface*>(_interface);
75+
return static_cast<Nanostack::ThreadInterface *>(_interface);
7776
}
7877

7978
nsapi_error_t ThreadInterface::do_initialize()

0 commit comments

Comments
 (0)