summaryrefslogtreecommitdiff
path: root/recipes-bsp/multitech/mts-id-eeprom/eeprom.patch
blob: 4c19e22fe26c6243c250f226bb515e0000732c9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
diff -uNr old/src/eeprom_main.c new/src/eeprom_main.c
--- old/src/eeprom_main.c	2017-04-04 12:38:41.561484898 -0500
+++ new/src/eeprom_main.c	2017-04-04 12:30:33.877499336 -0500
@@ -1,7 +1,7 @@
 /*
  * Create an image file for the MTCDP ID EEPROM
  *
- * Copyright (C) 2016 by Multi-Tech Systems
+ * Copyright (C) 2013 by Multi-Tech Systems
  *
  * Author: James Maki <jmaki@multitech.com>
  *
@@ -160,7 +160,6 @@
 	fprintf(file, "capa-adc: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_ADC) ? "true" : "false");
 	fprintf(file, "capa-wifi: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_WIFI) ? "true" : "false");
 	fprintf(file, "capa-bluetooth: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_BLUETOOTH) ? "true" : "false");
-	fprintf(file, "capa-lora: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_LORA) ? "true" : "false");
 
 	fprintf(file, "capa: \"");
 	
@@ -188,20 +187,6 @@
 		ptr += sprintf(ptr, "%02X", id_eeprom->uuid[i]);
 	}
 	fprintf(file, "uuid: \"%s\"\n",  (char*)buf);
-
-	fprintf(file, "lora-eui: \"%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\"\n",
-			id_eeprom->lora_eui[0],
-			id_eeprom->lora_eui[1],
-			id_eeprom->lora_eui[2],
-			id_eeprom->lora_eui[3],
-			id_eeprom->lora_eui[4],
-			id_eeprom->lora_eui[5],
-			id_eeprom->lora_eui[6],
-			id_eeprom->lora_eui[7]);
-
-	fprintf(file, "lora-product-id: \"%.32s\"\n",  id_eeprom->lora_product_id);
-	fprintf(file, "lora-hw-version: \"%.32s\"\n",  id_eeprom->lora_hw_version);
-
 	fprintf(file, "...\n");
 
 	fclose(file);
@@ -307,7 +292,6 @@
 	log_info("capa-adc: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_ADC) ? "yes" : "no");
 	log_info("capa-wifi: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_WIFI) ? "yes" : "no");
 	log_info("capa-bluetooth: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_BLUETOOTH) ? "yes" : "no");
-	log_info("capa-lora: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_LORA) ?  "yes" : "no");
 
 	log_info("mac-bluetooth: %02X:%02X:%02X:%02X:%02X:%02X",
             id_eeprom->mac_bluetooth[0],
@@ -329,19 +313,6 @@
 		ptr += sprintf(ptr, "%02X", id_eeprom->uuid[i]);
 	}
 	log_info("uuid: %s", (char*)buf);
-
-	log_info("lora-eui: \"%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\"",
-			id_eeprom->lora_eui[0],
-			id_eeprom->lora_eui[1],
-			id_eeprom->lora_eui[2],
-			id_eeprom->lora_eui[3],
-			id_eeprom->lora_eui[4],
-			id_eeprom->lora_eui[5],
-			id_eeprom->lora_eui[6],
-			id_eeprom->lora_eui[7]);
-
-	log_info("lora-product-id: %.32s",  id_eeprom->lora_product_id);
-	log_info("lora-hw-version: %.32s",  id_eeprom->lora_hw_version);
 }
 
 static void mts_ap_eeprom_inspect(struct mts_ap_eeprom_layout *ap_eeprom)
@@ -391,9 +362,7 @@
 	fprintf(out, "         --mac-addr <mac-addr> |\n");
 	fprintf(out, "         --mac-bluetooth <mac-addr> |\n");
 	fprintf(out, "         --mac-wifi <mac-addr> |\n");
-	fprintf(out, "         --lora-eui <EUI-64> |\n");
-	fprintf(out, "         --lora-hw-version <hw-version> |\n");
-	fprintf(out, "         --lora-product-id <product-id> |\n");
+	fprintf(out, "         --eui <EUI-64> |\n");
 	fprintf(out, "         --imei <imei> |\n");
 	fprintf(out, "         --capa-gps |\n");
 	fprintf(out, "         --capa-din |\n");
@@ -401,9 +370,7 @@
 	fprintf(out, "         --capa-adc |\n");
 	fprintf(out, "         --capa-wifi |\n");
 	fprintf(out, "         --capa-bluetooth |\n");
-	fprintf(out, "         --capa-lora |\n");
 	fprintf(out, "         --capa-clear (clears all flags) |\n");
-	fprintf(out, "         --hex-to-bin | \n");
 	fprintf(out, "         --out-format { bin | yaml (default) } |\n");
 	fprintf(out, "         --update |\n");
 	fprintf(out, "         --accessory-card\n");
@@ -422,9 +389,7 @@
 	CMD_OPT_MAC_ADDR,
 	CMD_OPT_MAC_BLUETOOTH,
 	CMD_OPT_MAC_WIFI,
-	CMD_OPT_LORA_EUI,
-	CMD_OPT_LORA_HW_VERSION,
-	CMD_OPT_LORA_PRODUCT_ID,
+	CMD_OPT_EUI,
 	CMD_OPT_IMEI,
 	CMD_OPT_CAPA_GPS,
 	CMD_OPT_CAPA_DIN,
@@ -432,15 +397,12 @@
 	CMD_OPT_CAPA_ADC,
 	CMD_OPT_CAPA_WIFI,
 	CMD_OPT_CAPA_BLUETOOTH,
-	CMD_OPT_CAPA_LORA,
 	CMD_OPT_CAPA_CLEAR,
 	CMD_OPT_OUT_FORMAT,
 	CMD_OPT_UPDATE,
 	CMD_OPT_ACCESSORY_CARD,
-
 	CMD_OPT_VERSION,
 	CMD_OPT_HELP,
-	CMD_OPT_HEX_TO_BIN,
 };
 
 static char *short_options = "f:";
@@ -452,12 +414,10 @@
 	{"device-id", 1, NULL, CMD_OPT_DEVICE_ID},
 	{"uuid", 1, NULL, CMD_OPT_UUID},
 	{"hw-version", 1, NULL, CMD_OPT_HW_VERSION},
-	{"lora-product-id", 1, NULL, CMD_OPT_LORA_PRODUCT_ID},
-	{"lora-hw-version", 1, NULL, CMD_OPT_LORA_HW_VERSION},
 	{"mac-addr", 1, NULL, CMD_OPT_MAC_ADDR},
 	{"mac-bluetooth", 1, NULL, CMD_OPT_MAC_BLUETOOTH},
 	{"mac-wifi", 1, NULL, CMD_OPT_MAC_WIFI},
-	{"lora-eui", 1, NULL, CMD_OPT_LORA_EUI},
+	{"eui", 1, NULL, CMD_OPT_EUI},
 	{"imei", 1, NULL, CMD_OPT_IMEI},
 	{"capa-gps", 0, NULL, CMD_OPT_CAPA_GPS},
 	{"capa-din", 0, NULL, CMD_OPT_CAPA_DIN},
@@ -465,9 +425,7 @@
 	{"capa-adc", 0, NULL, CMD_OPT_CAPA_ADC},
 	{"capa-wifi", 0, NULL, CMD_OPT_CAPA_WIFI},
 	{"capa-bluetooth", 0, NULL, CMD_OPT_CAPA_BLUETOOTH},
-	{"capa-lora", 0, NULL, CMD_OPT_CAPA_LORA},
 	{"capa-clear", 0, NULL, CMD_OPT_CAPA_CLEAR},
-	{"hex-to-bin", 0, NULL, CMD_OPT_HEX_TO_BIN},
 	{"out-format", 1, NULL, CMD_OPT_OUT_FORMAT},
 	{"update", 0, NULL, CMD_OPT_UPDATE},
 	{"accessory-card", 0, NULL, CMD_OPT_ACCESSORY_CARD},
@@ -494,9 +452,7 @@
 	char *uuid = NULL;
 	char *hw_version = NULL;
 	char *mac_addr = NULL;
-	char *lora_eui = NULL;
-	char *lora_product_id = NULL;
-	char *lora_hw_version = NULL;
+	char *eui = NULL;
 
 	struct mts_id_eeprom_layout id_eeprom;
 	struct mts_ap_eeprom_layout ap_eeprom;
@@ -616,10 +572,6 @@
 			product_id = optarg;
 			break;
 
-		case CMD_OPT_LORA_PRODUCT_ID:
-			lora_product_id = optarg;
-			break;
-
 		case CMD_OPT_DEVICE_ID:
 			device_id = optarg;
 			break;
@@ -641,10 +593,6 @@
 			hw_version = optarg;
 			break;
 
-		case CMD_OPT_LORA_HW_VERSION:
-			lora_hw_version = optarg;
-			break;
-
 		case CMD_OPT_MAC_ADDR:
 			mac_addr = optarg;
 			break;
@@ -667,8 +615,8 @@
 			}
 			break;
 
-		case CMD_OPT_LORA_EUI:
-			lora_eui = optarg;
+		case CMD_OPT_EUI:
+			eui = optarg;
 			break;
 
 		case CMD_OPT_IMEI:
@@ -699,10 +647,6 @@
 		    DEVICE_CAPA_SET(id_eeprom.capa, CAPA_BLUETOOTH);
 				break;
 
-		case CMD_OPT_CAPA_LORA:
-		    DEVICE_CAPA_SET(id_eeprom.capa, CAPA_LORA);
-				break;
-				
 		case CMD_OPT_CAPA_CLEAR:
 			memset(id_eeprom.capa, 0, sizeof(id_eeprom.capa));
 			break;
@@ -716,22 +660,7 @@
 			out_format = optarg;
 
 			break;
-		case CMD_OPT_HEX_TO_BIN:
-			{
-			  char buf[1025];
-			  char outbuf[1024];
-			  size_t sz, len;
-			  while((sz=read(0,buf,sizeof buf)) > 0) {
-			    buf[sz] = 0;
-			    sz = asciiHexToBin(buf,outbuf);
-			    len = write(1,outbuf,sz);
-			    if(len != sz) {
-			      log_error("failure to write to stdout: %s",strerror(errno));
-			      exit(1);
-			    }
-			  }
-			  exit(0);
-			}
+
 		default:
 			usage(stderr);
 			exit(1);
@@ -779,35 +708,16 @@
 			exit(1);
 		}
 	}
-	// on-board lora product id
-	if (lora_product_id) {
-		if (! accessory_card) {
-			strncpy(id_eeprom.lora_product_id, lora_product_id, sizeof(id_eeprom.lora_product_id) - 1);
-		} else {
-			log_error("--lora-product-id option is not supported on accessory card eeprom");
-			usage(stderr);
-			exit(1);
-		}
-	}
-	// on-board lora hw version
-	if (lora_hw_version) {
-		if (! accessory_card) {
-			strncpy(id_eeprom.lora_hw_version, lora_hw_version, sizeof(id_eeprom.lora_hw_version) - 1);
-		} else {
-			log_error("--lora-hw-version option is not supported on accessory card eeprom");
+	if (eui) {
+		if (!accessory_card) {
+			log_error("EUI only supported on accessory card eeprom");
 			usage(stderr);
 			exit(1);
 		}
-	}
-	if (lora_eui) {
-		if (!accessory_card) {
-			tmp = hwaddr_aton(lora_eui, id_eeprom.lora_eui, sizeof(id_eeprom.lora_eui));
-		}
-		else {
-			tmp = hwaddr_aton(lora_eui, ap_eeprom.eui, sizeof(ap_eeprom.eui));
-		}
+
+		tmp = hwaddr_aton(eui, ap_eeprom.eui, sizeof(ap_eeprom.eui));
 		if (!tmp) {
-			log_error("invalid EUI %s", lora_eui);
+			log_error("invalid EUI %s", eui);
 			usage(stderr);
 			exit(1);
 		}