Skip to content

Commit b14bccb

Browse files
authored
Remove the macaddr function from portduino, as it's not an Arduino function (#39)
1 parent 7c04545 commit b14bccb

File tree

2 files changed

+1
-48
lines changed

2 files changed

+1
-48
lines changed

cores/portduino/Arduino.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,5 @@ void portduinoAddArguments(const struct argp_child &child, void *childArguments)
5151
* write a 6 byte 'macaddr'/unique ID to the dmac parameter
5252
* This value can be customized with the --macaddr parameter and it defaults to 00:00:00:00:00:01
5353
*/
54-
void _getMacAddr(uint8_t *dmac);
5554
void reboot();
5655
#endif

cores/portduino/main.cpp

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include <ftw.h>
77
#include <sys/socket.h>
88
#include <sys/ioctl.h>
9-
#include <bluetooth/bluetooth.h>
10-
#include <bluetooth/hci.h>
119
#include <cerrno>
1210
#include <iostream>
1311
#include <cstring>
@@ -47,14 +45,11 @@ static char args_doc[] = "...";
4745
static struct argp_option options[] = {
4846
{"erase", 'e', 0, 0, "Erase virtual filesystem before use"},
4947
{"fsdir", 'd', "DIR", 0, "The directory to use as the virtual filesystem"},
50-
{"hwid", 'h', "HWID", 0,
51-
"The mac address to assign to this virtual machine"},
5248
{0}};
5349

5450
struct TopArguments {
5551
bool erase;
5652
char *fsDir;
57-
uint32_t hwId;
5853
};
5954

6055
// In bss (inited to zero)
@@ -77,10 +72,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
7772
case 'd':
7873
args->fsDir = arg;
7974
break;
80-
case 'h':
81-
if (sscanf(arg, "%d", &args->hwId) < 1)
82-
return ARGP_ERR_UNKNOWN;
83-
break;
8475
case ARGP_KEY_ARG:
8576
return 0;
8677
default:
@@ -89,40 +80,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
8980
return 0;
9081
}
9182

92-
void _getMacAddr(uint8_t *dmac) {
93-
94-
dmac[0] = 0x80;
95-
dmac[1] = 0;
96-
dmac[2] = portduinoArguments.hwId >> 24;
97-
dmac[3] = portduinoArguments.hwId >> 16;
98-
dmac[4] = portduinoArguments.hwId >> 8;
99-
dmac[5] = portduinoArguments.hwId & 0xff;
100-
101-
if (portduinoArguments.hwId != 1) { // If this was actually set
102-
return;
103-
}
104-
struct hci_dev_info di;
105-
di.dev_id = 0;
106-
bdaddr_t bdaddr;
107-
char addr[18];
108-
int btsock;
109-
btsock = socket(AF_BLUETOOTH, SOCK_RAW, 1);
110-
if (btsock < 0) { // If anything fails, just return with the default value
111-
return;
112-
}
113-
114-
if (ioctl(btsock, HCIGETDEVINFO, (void *) &di)) {
115-
return;
116-
}
117-
118-
dmac[0] = di.bdaddr.b[5];
119-
dmac[1] = di.bdaddr.b[4];
120-
dmac[2] = di.bdaddr.b[3];
121-
dmac[3] = di.bdaddr.b[2];
122-
dmac[4] = di.bdaddr.b[1];
123-
dmac[5] = di.bdaddr.b[0];
124-
}
125-
12683
/*
12784
* Functions to remove contents of directory
12885
* Adapted from: https://stackoverflow.com/a/5467788
@@ -179,8 +136,6 @@ int main(int argc, char *argv[]) {
179136

180137
auto *args = &portduinoArguments;
181138

182-
args->hwId = 1;
183-
184139
auto parseResult = argp_parse(&argp, argc, argv, 0, 0, args);
185140
if (parseResult == 0) {
186141
String fsRoot;
@@ -199,8 +154,7 @@ int main(int argc, char *argv[]) {
199154
} else
200155
fsRoot += args->fsDir;
201156

202-
printf("Portduino is starting, HWID=%d, VFS root at %s\n", args->hwId,
203-
fsRoot.c_str());
157+
printf("Portduino is starting, VFS root at %s\n", fsRoot.c_str());
204158

205159
int status = mkdir(fsRoot.c_str(), 0700);
206160
if (status != 0 && errno == EEXIST && args->erase) {

0 commit comments

Comments
 (0)