forked from iomz/go-llrp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.go
493 lines (469 loc) · 13.4 KB
/
message.go
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
package llrp
// Keepalive generates Keepalive message.
func Keepalive(messageID uint32) []byte {
var data = []interface{}{
uint16(KeepaliveHeader), // Rsvd+Ver+Type=62 (KEEPALIVE)
uint32(10), // Length
messageID, // ID
}
return Pack(data)
}
// KeepaliveAck generates KeepaliveAck message.
func KeepaliveAck(messageID uint32) []byte {
var data = []interface{}{
uint16(KeepaliveAckHeader), // Rsvd+Ver+Type=62 (KEEPALIVE)
uint32(10), // Length
messageID, // ID
}
return Pack(data)
}
// ReaderEventNotification generates ReaderEventNotification message.
func ReaderEventNotification(messageID uint32, currentTime uint64) []byte {
readerEventNotificationData := ReaderEventNotificationData(currentTime)
readerEventNotificationLength :=
len(readerEventNotificationData) + 10 // Rsvd+Ver+Type+Length+ID->80bits=10bytes
var data = []interface{}{
uint16(ReaderEventNotificationHeader), // Rsvd+Ver+Type=63 (READER_EVENT_NOTIFICATION)
uint32(readerEventNotificationLength), // Length
messageID, // ID
readerEventNotificationData,
}
return Pack(data)
}
// SetReaderConfig generates SetReaderConfig message.
func SetReaderConfig(messageID uint32) []byte {
keepaliveSpec := KeepaliveSpec()
setReaderConfigLength :=
len(keepaliveSpec) + 11 // Rsvd+Ver+Type+Length+ID+R+Rsvd->88bits=11bytes
var data = []interface{}{
uint16(SetReaderConfigHeader), // Rsvd+Ver+Type=3 (SET_READER_CONFIG)
uint32(setReaderConfigLength), // Length
messageID, // ID
uint8(0), // RestoreFactorySetting(no=0)+Rsvd
keepaliveSpec,
}
return Pack(data)
}
// SetReaderConfig generates SetReaderConfig message.
func SetEnableMode(messageID uint32) []byte {
var data = []interface{}{
uint16(ImpinjEnableCutomMessageHeader),
uint32(19), // Length
messageID, // ID
uint32(25882),
uint8(21),
uint32(0),
}
return Pack(data)
}
// SetReaderConfigResponse generates SetReaderConfigResponse message.
func SetReaderConfigResponse(messageID uint32) []byte {
llrpStatus := Status()
setReaderConfigResponseLength :=
len(llrpStatus) + 10 // Rsvd+Ver+Type+Length+ID+R+Rsvd->80bits=10bytes
var data = []interface{}{
uint16(SetReaderConfigResponseHeader), // Rsvd+Ver+Type=13 (SET_READER_CONFIG_RESPONSE)
uint32(setReaderConfigResponseLength), // Length
messageID, // ID
llrpStatus,
}
return Pack(data)
}
//GetReaderCapability :
func GetReaderCapability(messageID uint32) []byte {
getReaderCapabilityLength := 1 + 10
var data = []interface{}{
uint16(GetReaderCapabilityHeader),
uint32(getReaderCapabilityLength),
messageID,
uint8(0), //all capabilities
}
return Pack(data)
}
//GetReaderCapabilityResponse :
func GetReaderCapabilityResponse(messageID uint32) []byte {
llrpStatus := Status()
generalCapabilites := GeneralDeviceCapabilities()
llrpCapabilities := LlrpCapabilities()
c1g2llrpCapabilities := C1G2llrpCapabilities()
reguCapabilitles := ReguCapabilities()
length := 2 + 4 + 4 + len(llrpStatus) + len(generalCapabilites) + len(llrpCapabilities) + len(reguCapabilitles) + len(c1g2llrpCapabilities)
var data = []interface{}{
uint16(GetReaderCapabilityResponseHeader),
uint32(length),
uint32(messageID),
llrpStatus,
generalCapabilites,
llrpCapabilities,
reguCapabilitles,
// uint8(0),
// uint8(0),
// uint8(0),
c1g2llrpCapabilities,
}
return Pack(data)
}
//GetReaderConfigResponse :
func GetReaderConfigResponse(messageID uint32) []byte {
llrpStatus := Status()
//numOfAntennas := 52
identification := GetReaderConfigResponseIdentification()
length := 2 + 4 + 4 + len(llrpStatus) + len(identification) //+ numOfAntennas*9 + numOfAntennas*36
var data = []interface{}{
uint16(GetReaderConfigResponseHeader),
uint32(length),
messageID,
llrpStatus,
identification,
}
// x := Pack(data)
// for i := 1; i <= numOfAntennas; i++ {
// x = append(x, AntennaProperties(uint16(i))...)
// }
// for i := 1; i <= numOfAntennas; i++ {
// x = append(x, AntennaConfiguration(uint16(i))...)
// }
return Pack(data)
}
//DeleteRospecResponse : Delete RoSpec Response
func DeleteAcessSpec(messageID uint32) []byte {
var data = []interface{}{
uint16(DeleteAccessSpecHeader),
uint32(14), //length
messageID,
uint32(0),
}
return Pack(data)
}
//DeleteAccessSpecResponse : Delete Access Spec Response
func DeleteAccessSpecResponse(messageID uint32) []byte {
llrpStatus := Status()
var data = []interface{}{
uint16(DeleteAccessSpecResponseHeader),
uint32(18), //length
messageID,
llrpStatus,
}
return Pack(data)
}
//DeleteRospecResponse : Delete RoSpec Response
func DeleteRospec(messageID uint32) []byte {
var data = []interface{}{
uint16(DeleteRospecHeader),
uint32(14), //length
messageID,
uint32(0),
}
return Pack(data)
}
//DeleteRospecResponse : Delete RoSpec Response
func DeleteRospecResponse(messageID uint32) []byte {
llrpStatus := Status()
var data = []interface{}{
uint16(DeleteRospecResponseHeader),
uint32(18), //length
messageID,
llrpStatus,
}
return Pack(data)
}
//AddRospec : Add ROSpec Response
func AddRospec(messageID uint32) []byte {
var data = []interface{}{
uint16(AddRospecHeader),
uint32(441), //length
messageID,
/*RO Spec */
uint16(177), //RO Spec
uint16(431), //length
uint32(123), //RO Spec ID
uint8(0), //Priority
uint8(0), //State
/*RO Bound Spec */
uint16(178), //RO Bound Spec
uint16(18), //length
uint16(179), //RO Spec Start Triger
uint16(5), //length
uint8(1), //RO Spec Start Triger Type
uint16(182), //RO Spec Stop Triger
uint16(9), //length
uint8(0), //RO Spec Stop Triger Type
uint32(0), //Duration triger value
/*AI Spec */
uint16(183), //AI Spec
uint16(390), //length
uint16(4), //Antena Count
uint16(1), //Antena ID
uint16(2), //Antena ID
uint16(3), //Antena ID
uint16(4), //Antena ID
uint16(184), //AI Spec Stop Triger
uint16(9), //length
uint8(0), //AI Spec Stop Triger Type
uint32(0), //Duration triger value
uint16(186), //AI Spec Invertory Parametr Spec ID
uint16(367), //length
uint16(1234), //Invertory Parametr Spec ID
uint8(1), //Protocol ID
/*TLV Antena 1 */
uint16(222), //Antena Configuration
uint16(90), //length
uint16(1), //Antena ID
uint16(224), //RF Transmiter
uint16(10), //length
uint16(0), //HOP Table ID
uint16(1), //Channel Index
uint16(81), //Transmit Power
uint16(330), //C1 G2 Ibventory Command
uint16(74), //length
uint8(0), //Tag Inventory State aware
uint16(335), //RF Control
uint16(8), //length
uint16(1000), //Mode Index
uint16(0), //Tari
uint16(336), //Sigulation Control
uint16(11), //length
uint8(128), //Session
uint16(32), //Tag Population
uint32(0), //Tag Transmit Time
uint16(1023), //Inventory Search mode
uint16(14), //length
uint32(25882), //Tag Transmit Time
uint32(23), //Parametr type
uint16(2), //Inventory Search mode value
uint16(1023), //Fixed Frequency List
uint16(18), //length
uint32(25882), //Tag Transmit Time
uint32(26), //Parametr type
uint16(1), //Fixed Frequency mode
uint16(0), //Reserverd
uint16(0), //Number Channels
uint16(1023), //Low Dyte Cycle
uint16(18), //length
uint32(25882), //Tag Transmit Time
uint32(28), //Parametr type
uint16(0), //Low Dyte Cycle mode
uint16(0), //Empty field timeout
uint16(0), //Field Ping Timeout
/*TLV Antena 2 */
uint16(222), //Antena Configuration
uint16(90), //length
uint16(2), //Antena ID
uint16(224), //RF Transmiter
uint16(10), //length
uint16(0), //HOP Table ID
uint16(1), //Channel Index
uint16(81), //Transmit Power
uint16(330), //C1 G2 Ibventory Command
uint16(74), //length
uint8(0), //Tag Inventory State aware
uint16(335), //RF Control
uint16(8), //length
uint16(1000), //Mode Index
uint16(0), //Tari
uint16(336), //Sigulation Control
uint16(11), //length
uint8(128), //Session
uint16(32), //Tag Population
uint32(0), //Tag Transmit Time
uint16(1023), //Inventory Search mode
uint16(14), //length
uint32(25882), //Tag Transmit Time
uint32(23), //Parametr type
uint16(2), //Inventory Search mode value
uint16(1023), //Fixed Frequency List
uint16(18), //length
uint32(25882), //Tag Transmit Time
uint32(26), //Parametr type
uint16(1), //Fixed Frequency mode
uint16(0), //Reserverd
uint16(0), //Number Channels
uint16(1023), //Low Dyte Cycle
uint16(18), //length
uint32(25882), //Tag Transmit Time
uint32(28), //Parametr type
uint16(0), //Low Dyte Cycle mode
uint16(0), //Empty field timeout
uint16(0), //Field Ping Timeout
/*TLV Antena 3 */
uint16(222), //Antena Configuration
uint16(90), //length
uint16(3), //Antena ID
uint16(224), //RF Transmiter
uint16(10), //length
uint16(0), //HOP Table ID
uint16(1), //Channel Index
uint16(81), //Transmit Power
uint16(330), //C1 G2 Ibventory Command
uint16(74), //length
uint8(0), //Tag Inventory State aware
uint16(335), //RF Control
uint16(8), //length
uint16(1000), //Mode Index
uint16(0), //Tari
uint16(336), //Sigulation Control
uint16(11), //length
uint8(128), //Session
uint16(32), //Tag Population
uint32(0), //Tag Transmit Time
uint16(1023), //Inventory Search mode
uint16(14), //length
uint32(25882), //Tag Transmit Time
uint32(23), //Parametr type
uint16(2), //Inventory Search mode value
uint16(1023), //Fixed Frequency List
uint16(18), //length
uint32(25882), //Tag Transmit Time
uint32(26), //Parametr type
uint16(1), //Fixed Frequency mode
uint16(0), //Reserverd
uint16(0), //Number Channels
uint16(1023), //Low Dyte Cycle
uint16(18), //length
uint32(25882), //Tag Transmit Time
uint32(28), //Parametr type
uint16(0), //Low Dyte Cycle mode
uint16(0), //Empty field timeout
uint16(0), //Field Ping Timeout
/*TLV Antena 4 */
uint16(222), //Antena Configuration
uint16(90), //length
uint16(4), //Antena ID
uint16(224), //RF Transmiter
uint16(10), //length
uint16(0), //HOP Table ID
uint16(1), //Channel Index
uint16(81), //Transmit Power
uint16(330), //C1 G2 Ibventory Command
uint16(74), //length
uint8(0), //Tag Inventory State aware
uint16(335), //RF Control
uint16(8), //length
uint16(1000), //Mode Index
uint16(0), //Tari
uint16(336), //Sigulation Control
uint16(11), //length
uint8(128), //Session
uint16(32), //Tag Population
uint32(0), //Tag Transmit Time
uint16(1023), //Inventory Search mode
uint16(14), //length
uint32(25882), //Tag Transmit Time
uint32(23), //Parametr type
uint16(2), //Inventory Search mode value
uint16(1023), //Fixed Frequency List
uint16(18), //length
uint32(25882), //Tag Transmit Time
uint32(26), //Parametr type
uint16(1), //Fixed Frequency mode
uint16(0), //Reserverd
uint16(0), //Number Channels
uint16(1023), //Low Dyte Cycle
uint16(18), //length
uint32(25882), //Tag Transmit Time
uint32(28), //Parametr type
uint16(0), //Low Dyte Cycle mode
uint16(0), //Empty field timeout
uint16(0), //Field Ping Timeout
/*RO Report Spec */
uint16(237), //RO Report Spec
uint16(13), //length
uint8(2), //RO Report triger
uint16(1), //N
uint16(238), //RO Report Spec
uint16(6), //length
uint16(7744), //Param
}
return Pack(data)
}
//AddRospecResponse : Add ROSpec Response
func AddRospecResponse(messageID uint32) []byte {
llrpStatus := Status()
var data = []interface{}{
uint16(AddRospecResponseHeader),
uint32(18), //length
messageID,
llrpStatus,
}
return Pack(data)
}
//EnableRospec : Enabled Rospec Response
func EnableRospec(messageID uint32) []byte {
var data = []interface{}{
uint16(EnableRospecHeader),
uint32(14), //length
messageID,
uint32(123),
}
return Pack(data)
}
//EnableRospecResponse : Enabled Rospec Response
func EnableRospecResponse(messageID uint32) []byte {
llrpStatus := Status()
var data = []interface{}{
uint16(EnableRospecResponseHeader),
uint32(18), //length
messageID,
llrpStatus,
}
return Pack(data)
}
//StartRospec : Enabled Rospec Response
func StartRospec(messageID uint32) []byte {
var data = []interface{}{
uint16(StartRospecHeader),
uint32(14), //length
messageID,
uint32(123),
}
return Pack(data)
}
//ReceiveSensitivityEntries : Generates ReceiveSensitivityEntries used in General capabilities
func ReceiveSensitivityEntries(numOfAntennas int) []interface{} {
var data = []interface{}{}
for i := 1; i <= numOfAntennas; i++ {
x := ReceiveSensitivityEntry(uint16(i))
data = append(data, x)
}
return data
}
//ReceiveSensitivityEntry :
func ReceiveSensitivityEntry(id uint16) []byte {
var data = []interface{}{
uint16(139), //type
uint16(8), //length
uint16(id), //id
uint16(11), //receive sentitvitiy value
}
return Pack(data)
}
//GPIOCapabilities : Generates GPIO capabilities proeprty
func GPIOCapabilities() []byte {
var data = []interface{}{
uint16(141), //type
uint16(8), //length
uint16(0), //num of GPI port
uint16(0), //num of GPO port
}
return Pack(data)
}
//AntennaAirPortList :
func AntennaAirPortList(numOfAntennas int) []interface{} {
var data = []interface{}{}
for i := 1; i <= numOfAntennas; i++ {
x := AntennaAirPort(uint16(i))
data = append(data, x)
}
return data
}
//AntennaAirPort :
func AntennaAirPort(id uint16) []byte {
var data = []interface{}{
uint16(140), //type
uint16(9), //length
uint16(id),
uint16(1), //num of protocols
uint8(1), //protocol id : EPCGlobal Class 1 Gen 2
}
return Pack(data)
}