Skip to content

Commit

Permalink
Merge pull request #183 from JAndrassy/wifis3_mac_bytes_ordering
Browse files Browse the repository at this point in the history
WiFiS3 - macAddress() return normal bytes ordering
  • Loading branch information
aentinger authored Dec 14, 2023
2 parents 6174969 + 9aeaca9 commit 05feca5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 28 deletions.
8 changes: 4 additions & 4 deletions libraries/WiFiS3/examples/ConnectWithWPA/ConnectWithWPA.ino
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ void printCurrentNet() {
}

void printMacAddress(byte mac[]) {
for (int i = 5; i >= 0; i--) {
for (int i = 0; i < 6; i++) {
if (i > 0) {
Serial.print(":");
}
if (mac[i] < 16) {
Serial.print("0");
}
Serial.print(mac[i], HEX);
if (i > 0) {
Serial.print(":");
}
}
Serial.println();
}
10 changes: 5 additions & 5 deletions libraries/WiFiS3/examples/ScanNetworks/ScanNetworks.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
connect to any network, so no encryption scheme is specified.
Circuit:
* Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and Uno WiFi Rev.2)
* Uno R4 WiFi
created 13 July 2010
by dlf (Metodo2 srl)
Expand Down Expand Up @@ -108,14 +108,14 @@ void printEncryptionType(int thisType) {


void printMacAddress(byte mac[]) {
for (int i = 5; i >= 0; i--) {
for (int i = 0; i < 6; i++) {
if (i > 0) {
Serial.print(":");
}
if (mac[i] < 16) {
Serial.print("0");
}
Serial.print(mac[i], HEX);
if (i > 0) {
Serial.print(":");
}
}
Serial.println();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
BSSID and WiFi channel are printed
Circuit:
* Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and Uno WiFi Rev.2)
* Uno R4 WiFi
This example is based on ScanNetworks
Expand Down Expand Up @@ -130,14 +130,14 @@ void print2Digits(byte thisByte) {
}

void printMacAddress(byte mac[]) {
for (int i = 5; i >= 0; i--) {
for (int i = 0; i < 6; i++) {
if (i > 0) {
Serial.print(":");
}
if (mac[i] < 16) {
Serial.print("0");
}
Serial.print(mac[i], HEX);
if (i > 0) {
Serial.print(":");
}
}
Serial.println();
}
15 changes: 2 additions & 13 deletions libraries/WiFiS3/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ using namespace std;

/* -------------------------------------------------------------------------- */
CWifi::CWifi() : _timeout(50000){
mac[0] = 0;
mac[1] = 0;
mac[2] = 0;
mac[3] = 0;
mac[4] = 0;
mac[5] = 0;
}
/* -------------------------------------------------------------------------- */

Expand Down Expand Up @@ -242,21 +236,16 @@ uint8_t* CWifi::macAddress(uint8_t* _mac) {
if(modem.write(string(PROMPT(_MODE)),res, "%s" , CMD_READ(_MODE))) {
if(atoi(res.c_str()) == 1) {
if(modem.write(string(PROMPT(_MACSTA)),res, "%s" , CMD_READ(_MACSTA))) {
macStr2macArray(mac, res.c_str());
macStr2macArray(_mac, res.c_str());
}
}
else if(atoi(res.c_str()) == 2) {
if(modem.write(string(PROMPT(_MACSOFTAP)),res, "%s" , CMD_READ(_MACSOFTAP))) {
macStr2macArray(mac, res.c_str());
macStr2macArray(_mac, res.c_str());
}
}
}

for(int i = 0; i < 6; i++)
{
_mac[i] = mac[5 - i];
}

return _mac;
}

Expand Down
1 change: 0 additions & 1 deletion libraries/WiFiS3/src/WiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class CWifi {
private:
void _config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2);
unsigned long _timeout;
uint8_t mac[6];
std::vector<CAccessPoint> access_points;
std::string ssid;
std::string apssid;
Expand Down

0 comments on commit 05feca5

Please sign in to comment.