mirror of https://github.com/ARMmbed/mbed-os.git
commit
d84bf7fc43
|
@ -112,7 +112,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual const char *get_gateway() = 0;
|
virtual const char *get_gateway() = 0;
|
||||||
|
|
||||||
virtual CellularBase *cellularBase() {
|
virtual CellularBase *cellularBase()
|
||||||
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,7 @@
|
||||||
* the credentials have been set. This is necessary to support specialised
|
* the credentials have been set. This is necessary to support specialised
|
||||||
* applications such as 6LoWPAN mesh border routers.
|
* applications such as 6LoWPAN mesh border routers.
|
||||||
*/
|
*/
|
||||||
class EMACInterface : public virtual NetworkInterface
|
class EMACInterface : public virtual NetworkInterface {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/** Create an EMAC-based network interface.
|
/** Create an EMAC-based network interface.
|
||||||
*
|
*
|
||||||
|
@ -52,8 +51,7 @@ public:
|
||||||
* @param emac Reference to EMAC to use
|
* @param emac Reference to EMAC to use
|
||||||
* @param stack Reference to onboard-network stack to use
|
* @param stack Reference to onboard-network stack to use
|
||||||
*/
|
*/
|
||||||
EMACInterface(
|
EMACInterface(EMAC &emac = EMAC::get_default_instance(),
|
||||||
EMAC &emac = EMAC::get_default_instance(),
|
|
||||||
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
|
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
|
||||||
|
|
||||||
/** Set a static IP address
|
/** Set a static IP address
|
||||||
|
@ -67,8 +65,7 @@ public:
|
||||||
* @param gateway Null-terminated representation of the local gateway
|
* @param gateway Null-terminated representation of the local gateway
|
||||||
* @return 0 on success, negative error code on failure
|
* @return 0 on success, negative error code on failure
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t set_network(
|
virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway);
|
||||||
const char *ip_address, const char *netmask, const char *gateway);
|
|
||||||
|
|
||||||
/** Enable or disable DHCP on the network
|
/** Enable or disable DHCP on the network
|
||||||
*
|
*
|
||||||
|
@ -148,9 +145,13 @@ public:
|
||||||
*
|
*
|
||||||
* @return Reference to the EMAC in use
|
* @return Reference to the EMAC in use
|
||||||
*/
|
*/
|
||||||
EMAC &get_emac() const { return _emac; }
|
EMAC &get_emac() const
|
||||||
|
{
|
||||||
|
return _emac;
|
||||||
|
}
|
||||||
|
|
||||||
virtual EMACInterface *emacInterface() {
|
virtual EMACInterface *emacInterface()
|
||||||
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,11 @@
|
||||||
*
|
*
|
||||||
* Common interface that is shared between ethernet hardware.
|
* Common interface that is shared between ethernet hardware.
|
||||||
*/
|
*/
|
||||||
class EthInterface : public virtual NetworkInterface
|
class EthInterface : public virtual NetworkInterface {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual EthInterface *ethInterface() {
|
virtual EthInterface *ethInterface()
|
||||||
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
/** EthernetInterface class
|
/** EthernetInterface class
|
||||||
* Implementation of the NetworkStack for an EMAC-based Ethernet driver
|
* Implementation of the NetworkStack for an EMAC-based Ethernet driver
|
||||||
*/
|
*/
|
||||||
class EthernetInterface : public EMACInterface, public EthInterface
|
class EthernetInterface : public EMACInterface, public EthInterface {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/** Create an EMAC-based ethernet interface.
|
/** Create an EMAC-based ethernet interface.
|
||||||
*
|
*
|
||||||
|
@ -41,8 +40,7 @@ public:
|
||||||
* @param emac Reference to EMAC to use
|
* @param emac Reference to EMAC to use
|
||||||
* @param stack Reference to onboard-network stack to use
|
* @param stack Reference to onboard-network stack to use
|
||||||
*/
|
*/
|
||||||
EthernetInterface(
|
EthernetInterface(EMAC &emac = EMAC::get_default_instance(),
|
||||||
EMAC &emac = EMAC::get_default_instance(),
|
|
||||||
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance()) : EMACInterface(emac, stack) { }
|
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance()) : EMACInterface(emac, stack) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@ public:
|
||||||
nsapi_error_t open(NetworkStack *stack);
|
nsapi_error_t open(NetworkStack *stack);
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
nsapi_error_t open(S *stack) {
|
nsapi_error_t open(S *stack)
|
||||||
|
{
|
||||||
return open(nsapi_create_stack(stack));
|
return open(nsapi_create_stack(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +212,8 @@ public:
|
||||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||||
"The attach function does not support cv-qualifiers. Replaced by "
|
"The attach function does not support cv-qualifiers. Replaced by "
|
||||||
"attach(callback(obj, method)).")
|
"attach(callback(obj, method)).")
|
||||||
void attach(T *obj, M method) {
|
void attach(T *obj, M method)
|
||||||
|
{
|
||||||
attach(mbed::callback(obj, method));
|
attach(mbed::callback(obj, method));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,11 @@
|
||||||
*
|
*
|
||||||
* Common interface that is shared between mesh hardware
|
* Common interface that is shared between mesh hardware
|
||||||
*/
|
*/
|
||||||
class MeshInterface : public virtual NetworkInterface
|
class MeshInterface : public virtual NetworkInterface {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual MeshInterface *meshInterface() {
|
virtual MeshInterface *meshInterface()
|
||||||
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,7 @@ public:
|
||||||
* @param gateway Null-terminated representation of the local gateway
|
* @param gateway Null-terminated representation of the local gateway
|
||||||
* @return 0 on success, negative error code on failure
|
* @return 0 on success, negative error code on failure
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t set_network(
|
virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway);
|
||||||
const char *ip_address, const char *netmask, const char *gateway);
|
|
||||||
|
|
||||||
/** Enable or disable DHCP on the network
|
/** Enable or disable DHCP on the network
|
||||||
*
|
*
|
||||||
|
@ -245,27 +244,32 @@ public:
|
||||||
virtual nsapi_error_t set_blocking(bool blocking);
|
virtual nsapi_error_t set_blocking(bool blocking);
|
||||||
|
|
||||||
/** Dynamic downcast to an EthInterface */
|
/** Dynamic downcast to an EthInterface */
|
||||||
virtual EthInterface *ethInterface() {
|
virtual EthInterface *ethInterface()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dynamic downcast to a WiFiInterface */
|
/** Dynamic downcast to a WiFiInterface */
|
||||||
virtual WiFiInterface *wifiInterface() {
|
virtual WiFiInterface *wifiInterface()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dynamic downcast to a MeshInterface */
|
/** Dynamic downcast to a MeshInterface */
|
||||||
virtual MeshInterface *meshInterface() {
|
virtual MeshInterface *meshInterface()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dynamic downcast to a CellularBase */
|
/** Dynamic downcast to a CellularBase */
|
||||||
virtual CellularBase *cellularBase() {
|
virtual CellularBase *cellularBase()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dynamic downcast to an EMACInterface */
|
/** Dynamic downcast to an EMACInterface */
|
||||||
virtual EMACInterface *emacInterface() {
|
virtual EMACInterface *emacInterface()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,8 +148,7 @@ call_in_callback_cb_t NetworkStack::get_call_in_callback()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkStackWrapper class for encapsulating the raw nsapi_stack structure
|
// NetworkStackWrapper class for encapsulating the raw nsapi_stack structure
|
||||||
class NetworkStackWrapper : public NetworkStack
|
class NetworkStackWrapper : public NetworkStack {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
inline nsapi_stack_t *_stack()
|
inline nsapi_stack_t *_stack()
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,8 +34,7 @@ class OnboardNetworkStack;
|
||||||
* for instantiating network sockets.
|
* for instantiating network sockets.
|
||||||
* @addtogroup netsocket
|
* @addtogroup netsocket
|
||||||
*/
|
*/
|
||||||
class NetworkStack: public DNS
|
class NetworkStack: public DNS {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual ~NetworkStack() {};
|
virtual ~NetworkStack() {};
|
||||||
|
|
||||||
|
@ -162,7 +161,10 @@ public:
|
||||||
virtual nsapi_error_t getstackopt(int level, int optname, void *optval, unsigned *optlen);
|
virtual nsapi_error_t getstackopt(int level, int optname, void *optval, unsigned *optlen);
|
||||||
|
|
||||||
/** Dynamic downcast to a OnboardNetworkStack */
|
/** Dynamic downcast to a OnboardNetworkStack */
|
||||||
virtual OnboardNetworkStack *onboardNetworkStack() { return 0; }
|
virtual OnboardNetworkStack *onboardNetworkStack()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class InternetSocket;
|
friend class InternetSocket;
|
||||||
|
|
|
@ -58,7 +58,10 @@ public:
|
||||||
/** Override multicast functions to return error for TCP
|
/** Override multicast functions to return error for TCP
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual int join_multicast_group(const SocketAddress &address) { return NSAPI_ERROR_UNSUPPORTED; }
|
virtual int join_multicast_group(const SocketAddress &address)
|
||||||
|
{
|
||||||
|
return NSAPI_ERROR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
/** Connects TCP socket to a remote host
|
/** Connects TCP socket to a remote host
|
||||||
*
|
*
|
||||||
|
|
|
@ -97,8 +97,9 @@ nsapi_size_or_error_t UDPSocket::sendto(const SocketAddress &address, const void
|
||||||
|
|
||||||
nsapi_size_or_error_t UDPSocket::send(const void *data, nsapi_size_t size)
|
nsapi_size_or_error_t UDPSocket::send(const void *data, nsapi_size_t size)
|
||||||
{
|
{
|
||||||
if (!_remote_peer)
|
if (!_remote_peer) {
|
||||||
return NSAPI_ERROR_NO_ADDRESS;
|
return NSAPI_ERROR_NO_ADDRESS;
|
||||||
|
}
|
||||||
return sendto(_remote_peer, data, size);
|
return sendto(_remote_peer, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
* Class that represents a WiFi Access Point
|
* Class that represents a WiFi Access Point
|
||||||
* Common interface that is shared between WiFi devices
|
* Common interface that is shared between WiFi devices
|
||||||
*/
|
*/
|
||||||
class WiFiAccessPoint
|
class WiFiAccessPoint {
|
||||||
{
|
|
||||||
/** WiFiAccessPoint lifetime
|
/** WiFiAccessPoint lifetime
|
||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
* Common interface that is shared between WiFi devices
|
* Common interface that is shared between WiFi devices
|
||||||
* @addtogroup netsocket
|
* @addtogroup netsocket
|
||||||
*/
|
*/
|
||||||
class WiFiInterface: public virtual NetworkInterface
|
class WiFiInterface: public virtual NetworkInterface {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/** Get the default WiFi interface.
|
/** Get the default WiFi interface.
|
||||||
*
|
*
|
||||||
|
@ -106,7 +105,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count) = 0;
|
virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count) = 0;
|
||||||
|
|
||||||
virtual WiFiInterface *wifiInterface() {
|
virtual WiFiInterface *wifiInterface()
|
||||||
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ static void nsapi_dns_query_async_socket_callback_handle(NetworkStack *stack);
|
||||||
static void nsapi_dns_query_async_response(void *ptr);
|
static void nsapi_dns_query_async_response(void *ptr);
|
||||||
static void nsapi_dns_query_async_initiate_next(void);
|
static void nsapi_dns_query_async_initiate_next(void);
|
||||||
|
|
||||||
|
// *INDENT-OFF*
|
||||||
static nsapi_addr_t dns_servers[DNS_SERVERS_SIZE] = {
|
static nsapi_addr_t dns_servers[DNS_SERVERS_SIZE] = {
|
||||||
{NSAPI_IPv4, {8, 8, 8, 8}}, // Google
|
{NSAPI_IPv4, {8, 8, 8, 8}}, // Google
|
||||||
{NSAPI_IPv4, {209, 244, 0, 3}}, // Level 3
|
{NSAPI_IPv4, {209, 244, 0, 3}}, // Level 3
|
||||||
|
@ -110,6 +111,7 @@ static nsapi_addr_t dns_servers[DNS_SERVERS_SIZE] = {
|
||||||
{NSAPI_IPv6, {0x20,0x01, 0x16,0x08, 0,0x10, 0,0x25, // DNS.WATCH
|
{NSAPI_IPv6, {0x20,0x01, 0x16,0x08, 0,0x10, 0,0x25, // DNS.WATCH
|
||||||
0,0, 0,0, 0x1c,0x04, 0xb1,0x2f}},
|
0,0, 0,0, 0x1c,0x04, 0xb1,0x2f}},
|
||||||
};
|
};
|
||||||
|
// *INDENT-ON*
|
||||||
|
|
||||||
#if (MBED_CONF_NSAPI_DNS_CACHE_SIZE > 0)
|
#if (MBED_CONF_NSAPI_DNS_CACHE_SIZE > 0)
|
||||||
static DNS_CACHE *dns_cache[MBED_CONF_NSAPI_DNS_CACHE_SIZE];
|
static DNS_CACHE *dns_cache[MBED_CONF_NSAPI_DNS_CACHE_SIZE];
|
||||||
|
|
|
@ -320,8 +320,7 @@ typedef struct nsapi_ip_mreq {
|
||||||
*
|
*
|
||||||
* Unsupported operations can be left as null pointers.
|
* Unsupported operations can be left as null pointers.
|
||||||
*/
|
*/
|
||||||
typedef struct nsapi_stack_api
|
typedef struct nsapi_stack_api {
|
||||||
{
|
|
||||||
/** Get the local IP address
|
/** Get the local IP address
|
||||||
*
|
*
|
||||||
* @param stack Stack handle
|
* @param stack Stack handle
|
||||||
|
|
Loading…
Reference in New Issue