Skip to content

Commit 743d816

Browse files
author
jantje
committed
removed system hash
1 parent 8b88e2f commit 743d816

File tree

3 files changed

+43
-118
lines changed

3 files changed

+43
-118
lines changed

io.sloeber.core/src/io/sloeber/core/api/Other.java

-9
This file was deleted.

io.sloeber.core/src/io/sloeber/core/common/ConfigurationPreferences.java

-45
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
import static io.sloeber.core.common.Const.*;
44

55
import java.io.File;
6-
import java.net.NetworkInterface;
7-
import java.net.SocketException;
8-
import java.util.Collection;
9-
import java.util.Enumeration;
10-
import java.util.TreeSet;
116

127
import org.eclipse.core.runtime.IPath;
138
import org.eclipse.core.runtime.Path;
@@ -38,36 +33,6 @@ public class ConfigurationPreferences {
3833
// preference nodes
3934
private static final String PACKAGES_FOLDER_NAME = "packages"; //$NON-NLS-1$
4035

41-
private static String systemHash = "no hash generated"; //$NON-NLS-1$
42-
static {
43-
// make a hashkey to identify the system
44-
Collection<String> macs = new TreeSet<>();
45-
Enumeration<NetworkInterface> inters;
46-
try {
47-
inters = NetworkInterface.getNetworkInterfaces();
48-
49-
while (inters.hasMoreElements()) {
50-
NetworkInterface inter = inters.nextElement();
51-
if (inter.getHardwareAddress() == null) {
52-
continue;
53-
}
54-
if (inter.isVirtual()) {
55-
continue;
56-
}
57-
byte curmac[] = inter.getHardwareAddress();
58-
StringBuilder b = new StringBuilder();
59-
for (byte curbyte : curmac) {
60-
b.append(String.format("%02X", Byte.valueOf(curbyte))); //$NON-NLS-1$
61-
}
62-
macs.add(b.toString());
63-
}
64-
} catch (@SuppressWarnings("unused") SocketException e) {
65-
// ignore
66-
}
67-
Integer hascode = Integer.valueOf(macs.toString().hashCode());
68-
systemHash = hascode.toString();
69-
}
70-
7136
public static void removeKey(String key) {
7237
IEclipsePreferences myScope = ConfigurationScope.INSTANCE.getNode(NODE_ARDUINO);
7338
myScope.remove(key);
@@ -166,14 +131,4 @@ public static void setUpdateJasonFilesFlag(boolean newFlag) {
166131
setBoolean(KEY_UPDATE_JASONS, newFlag);
167132
}
168133

169-
/**
170-
* Make a unique hashKey based on system parameters so we can identify users To
171-
* make the key the mac addresses of the network cards are used
172-
*
173-
* @return a unique key identifying the system
174-
*/
175-
public static String getSystemHash() {
176-
return systemHash;
177-
}
178-
179134
}

io.sloeber.tests/src/io/sloeber/core/MySystem.java

+43-64
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static org.junit.Assert.*;
44

5-
import io.sloeber.core.api.Other;
65
import io.sloeber.providers.Arduino;
76
import io.sloeber.providers.ESP8266;
87
import io.sloeber.providers.MCUBoard;
@@ -14,69 +13,49 @@
1413
*/
1514
@SuppressWarnings("nls")
1615
public class MySystem {
17-
private static final String jantjesWindowsMachineHashKey = "1248215851";
18-
//the one below is based on one mac address Fysiek adres (MAC): C0-3F-D5-66-04-58
19-
private static final String jantjesWindowsMachineHashkeyAfterUpdate="139705674";
20-
private static final String jantjesLinuxMachineHashKey = "88937904";
21-
private static final String jantjeWindowsMachineHashkeyAfterSecondUpdate="-441525448";
16+
private static final String jantjesWindowsMachine = "1248215851";
17+
//the one below is based on one mac address Fysiek adres (MAC): C0-3F-D5-66-04-58
18+
private static final String jantjesLinuxMachine = "88937904";
19+
private static final String currentMachine = jantjesWindowsMachine;
2220

23-
public static String getTeensyPlatform() {
24-
switch (Other.getSystemHash()) {
25-
case jantjesWindowsMachineHashKey:
26-
case jantjesWindowsMachineHashkeyAfterUpdate:
27-
case jantjeWindowsMachineHashkeyAfterSecondUpdate:
28-
return "E:\\arduino\\arduino-1.8.12 - teensy\\hardware\\teensy";
29-
case jantjesLinuxMachineHashKey:
30-
return "/home/jan/tensyduino/arduino-1.8.12/hardware/teensy";
31-
default:
32-
return new String();
33-
}
34-
}
21+
public static String getTeensyPlatform() {
22+
switch (currentMachine) {
23+
case jantjesWindowsMachine:
24+
return "E:\\arduino\\arduino-1.8.12 - teensy\\hardware\\teensy";
25+
case jantjesLinuxMachine:
26+
return "/home/jan/tensyduino/arduino-1.8.12/hardware/teensy";
27+
default:
28+
return new String();
29+
}
30+
}
3531

36-
public static String getTeensyBoard_txt() {
37-
return getTeensyPlatform() + "/avr/boards.txt";
38-
}
39-
public static MCUBoard[] getUploadBoards() {
40-
switch (Other.getSystemHash()) {
41-
case jantjesLinuxMachineHashKey: {
42-
MCUBoard[] boards = {
43-
Teensy.teensypp2("/dev/ttyACM0"),
44-
Arduino.leonardo("/dev/ttyS0"), //werkt niet
45-
Arduino.fried2016("/dev/ttyS0"), //werkt niet
46-
Arduino.zeroNatviePort("/dev/ttyS0"), //werkt niet
47-
Arduino.yun("COM20"),
48-
ESP8266.wemosD1("/dev/ttyUSB0"),
49-
Arduino.arduino_101("COM15"),
50-
Arduino.zeroProgrammingPort("COM14"),
51-
Arduino.getMega2560Board("COM11"),
52-
Arduino.dueprogramming("COM8"),
53-
Arduino.uno("COM6"),
54-
};
55-
return boards;
56-
}
57-
case jantjesWindowsMachineHashKey:
58-
case jantjeWindowsMachineHashkeyAfterSecondUpdate:
59-
case jantjesWindowsMachineHashkeyAfterUpdate:{
60-
//due native upload gives to mutch trouble even in arduino IDE
61-
MCUBoard[] boards = {
62-
Teensy.teensypp2("COM103"),
63-
// Teensy.Teensy3_1("COM24"),
64-
Arduino.leonardo("COM101"),
65-
Arduino.fried2016("COM102"),
66-
Arduino.zeroNatviePort("COM104"), //boardSponsor
67-
Arduino.yun("COM106"),
68-
ESP8266.wemosD1("COM108"),
69-
Arduino.arduino_101("COM110"),
70-
Arduino.zeroProgrammingPort("COM111"),
71-
Arduino.getMega2560Board("COM112"),
72-
Arduino.dueprogramming("COM124"),
73-
Arduino.uno("COM126"),
74-
};
75-
return boards;
76-
}
77-
default:
78-
fail("Boards for the system with haskey " + Other.getSystemHash() + " are not found");
79-
return null;
80-
}
81-
}
32+
public static String getTeensyBoard_txt() {
33+
return getTeensyPlatform() + "/avr/boards.txt";
34+
}
35+
36+
public static MCUBoard[] getUploadBoards() {
37+
switch (currentMachine) {
38+
case jantjesLinuxMachine: {
39+
MCUBoard[] boards = { Teensy.teensypp2("/dev/ttyACM0"), Arduino.leonardo("/dev/ttyS0"), //werkt niet
40+
Arduino.fried2016("/dev/ttyS0"), //werkt niet
41+
Arduino.zeroNatviePort("/dev/ttyS0"), //werkt niet
42+
Arduino.yun("COM20"), ESP8266.wemosD1("/dev/ttyUSB0"), Arduino.arduino_101("COM15"),
43+
Arduino.zeroProgrammingPort("COM14"), Arduino.getMega2560Board("COM11"),
44+
Arduino.dueprogramming("COM8"), Arduino.uno("COM6"), };
45+
return boards;
46+
}
47+
case jantjesWindowsMachine:
48+
//due native upload gives to mutch trouble even in arduino IDE
49+
MCUBoard[] boards = { Teensy.teensypp2("COM103"),
50+
// Teensy.Teensy3_1("COM24"),
51+
Arduino.leonardo("COM101"), Arduino.fried2016("COM102"), Arduino.zeroNatviePort("COM104"), //boardSponsor
52+
Arduino.yun("COM106"), ESP8266.wemosD1("COM108"), Arduino.arduino_101("COM110"),
53+
Arduino.zeroProgrammingPort("COM111"), Arduino.getMega2560Board("COM112"),
54+
Arduino.dueprogramming("COM124"), Arduino.uno("COM126"), };
55+
return boards;
56+
default:
57+
fail("Boards for the system with haskey " + currentMachine + " are not found");
58+
return null;
59+
}
60+
}
8261
}

0 commit comments

Comments
 (0)