Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ethernet, initCallback, ctor and eth_if#901

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pennam merged 6 commits intoarduino:mainfrompennam:rm_initCallback
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
19 changes: 12 additions & 7 deletionslibraries/Ethernet/src/Ethernet.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
#include "Ethernet.h"

#define SSID_MAX_LENGTH 32

int arduino::EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
if (eth_if == nullptr) {
//Q: What is the callback for?
_initializerCallback();
if (eth_if == nullptr) return 0;
return 0;
}
eth_if->set_dhcp(true);
return _begin(mac, timeout, responseTimeout);
Expand DownExpand Up@@ -51,6 +47,10 @@ int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPA
}

int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
if(eth_if == nullptr) {
return 0;
}

config(ip, dns, gateway, subnet);

eth_if->set_dhcp(false);
Expand All@@ -68,6 +68,9 @@ void arduino::EthernetClass::end() {
}

EthernetLinkStatus arduino::EthernetClass::linkStatus() {
if(eth_if == nullptr) {
return LinkOFF;
}
return (eth_if->get_connection_status() == NSAPI_STATUS_GLOBAL_UP ? LinkON : LinkOFF);
}

Expand All@@ -77,7 +80,9 @@ EthernetHardwareStatus arduino::EthernetClass::hardwareStatus() {


int arduino::EthernetClass::disconnect() {
eth_if->disconnect();
if(eth_if != nullptr) {
eth_if->disconnect();
}
return 1;
}

Expand All@@ -99,4 +104,4 @@ void arduino::EthernetClass::MACAddress(uint8_t *mac_address)
macAddress(mac_address);
}

arduino::EthernetClass Ethernet;
arduino::EthernetClass Ethernet(static_cast<EthernetInterface*>(EthInterface::get_default_instance()));
16 changes: 4 additions & 12 deletionslibraries/Ethernet/src/Ethernet.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,21 +50,15 @@ enum { // compatibility with Arduino ::maintain()
DHCP_CHECK_REBIND_OK = 4
};

typedef void *(*voidPrtFuncPtr)(void);

class EthernetClass : public MbedSocketClass {

public:
// Initialise the Ethernet shield to use the provided MAC address and
// gain the rest of the configuration through DHCP.
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
EthernetClass(EthernetInterface *_if)
: eth_if(_if){};
EthernetClass(){};

EthernetClass(voidPrtFuncPtr _cb)
: _initializerCallback(_cb){};

// Initialise the Ethernet shield to use the provided MAC address and
// gain the rest of the configuration through DHCP.
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
int begin(uint8_t *mac = nullptr, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
EthernetLinkStatus linkStatus();
EthernetHardwareStatus hardwareStatus();
Expand DownExpand Up@@ -119,9 +113,7 @@ class EthernetClass : public MbedSocketClass {
int _begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout);

volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
EthernetInterface net;
EthernetInterface *eth_if = &net;
voidPrtFuncPtr _initializerCallback;
EthernetInterface *eth_if = nullptr;
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
};

Expand Down
2 changes: 0 additions & 2 deletionslibraries/GPS/src/GPS.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,8 +25,6 @@

namespace arduino {

typedef void* (*voidPrtFuncPtr)(void);

class GPSClass : public HardwareSerial {
public:

Expand Down
2 changes: 0 additions & 2 deletionslibraries/GSM/src/GSM.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,8 +65,6 @@

namespace arduino {

typedef void* (*voidPrtFuncPtr)(void);

class GSMClass : public MbedSocketClass {
public:

Expand Down
2 changes: 0 additions & 2 deletionslibraries/WiFi/src/WiFi.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,8 +46,6 @@ extern "C" {

namespace arduino {

typedef void* (*voidPrtFuncPtr)(void);

class WiFiClass : public MbedSocketClass {
public:
static int16_t _state[MAX_SOCK_NUM];
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp