LTKCPP-- LLRP Toolkit C Plus Plus Library
custom_select_1.cpp
1 
2 /*
3  *****************************************************************************
4  * *
5  * IMPINJ CONFIDENTIAL AND PROPRIETARY *
6  * *
7  * This source code is the sole property of Impinj, Inc. Reproduction or *
8  * utilization of this source code in whole or in part is forbidden without *
9  * the prior written consent of Impinj, Inc. *
10  * *
11  * (c) Copyright Impinj, Inc. 2007,2009. All rights reserved. *
12  * *
13  *****************************************************************************/
14 
44 #include <stdio.h>
45 #include "ltkcpp.h"
46 #include "impinj_ltkcpp.h"
47 #include "time.h"
48 
49 using namespace LLRP;
50 
51 /*
52 ** Sorry, we use this linux safe method
53 ** to print buffers. WIndows has the same
54 ** method, but by a different name
55 */
56 #if (WIN32)
57 #define snprintf _snprintf
58 #endif
59 
60 class CMyApplication
61 {
62  unsigned int m_messageID;
63 
64  public:
66  int m_Verbose;
67 
69  CConnection * m_pConnectionToReader;
70 
71  inline
72  CMyApplication (void)
73  : m_Verbose(0), m_pConnectionToReader(NULL)
74  {
75  m_messageID = 0;
76  }
77 
78  int
79  run (
80  char * pReaderHostName);
81 
82  int
83  checkConnectionStatus (void);
84 
85  int
86  enableImpinjExtensions (void);
87 
88  int
89  resetConfigurationToFactoryDefaults (void);
90 
91  int
92  addROSpec (void);
93 
94  int
95  enableROSpec (void);
96 
97  int
98  startROSpec (void);
99 
100  int
101  stopROSpec (void);
102 
103  int
104  awaitAndPrintReport (int timeoutSec);
105 
106  void
107  printTagReportData (
108  CRO_ACCESS_REPORT * pRO_ACCESS_REPORT);
109 
110  void
111  printOneTagReportData (
112  CTagReportData * pTagReportData);
113 
114  void
115  formatOneEPC (
116  CParameter * pEpcParameter,
117  char * buf,
118  int buflen);
119 
120  void
121  handleReaderEventNotification (
122  CReaderEventNotificationData *pNtfData);
123 
124  void
125  handleAntennaEvent (
126  CAntennaEvent * pAntennaEvent);
127 
128  void
129  handleReaderExceptionEvent (
130  CReaderExceptionEvent * pReaderExceptionEvent);
131 
132  int
133  checkLLRPStatus (
134  CLLRPStatus * pLLRPStatus,
135  char * pWhatStr);
136 
137  CMessage *
138  transact (
139  CMessage * pSendMsg);
140 
141  CMessage *
142  recvMessage (
143  int nMaxMS);
144 
145  int
146  sendMessage (
147  CMessage * pSendMsg);
148 
149  void
150  printXMLMessage (
151  CMessage * pMessage);
152 };
153 
154 
155 /* BEGIN forward declarations */
156 int
157 main (
158  int ac,
159  char * av[]);
160 
161 void
162 usage (
163  char * pProgName);
164 /* END forward declarations */
165 
166 
182 int
183 main (
184  int ac,
185  char * av[])
186 {
187  CMyApplication myApp;
188  char * pReaderHostName;
189  int rc;
190 
191  /*
192  * Process comand arguments, determine reader name
193  * and verbosity level.
194  */
195  if(ac == 2)
196  {
197  pReaderHostName = av[1];
198  }
199  else if(ac == 3)
200  {
201  char * p = av[1];
202 
203  while(*p)
204  {
205  switch(*p++)
206  {
207  case '-': /* linux conventional option warn char */
208  case '/': /* Windows/DOS conventional option warn char */
209  break;
210 
211  case 'v':
212  case 'V':
213  myApp.m_Verbose++;
214  break;
215 
216  default:
217  usage(av[0]);
218  /* no return */
219  break;
220  }
221  }
222 
223  pReaderHostName = av[2];
224  }
225  else
226  {
227  usage(av[0]);
228  /* no return */
229  }
230 
231  /*
232  * Run application, capture return value for exit status
233  */
234  rc = myApp.run(pReaderHostName);
235 
236  printf("INFO: Done\n");
237 
238  /*
239  * Exit with the right status.
240  */
241  if(0 == rc)
242  {
243  exit(0);
244  }
245  else
246  {
247  exit(2);
248  }
249  /*NOTREACHED*/
250 }
251 
252 
264 void
265 usage (
266  char * pProgName)
267 {
268 #ifdef linux
269  printf("Usage: %s [-v[v]] READERHOSTNAME\n", pProgName);
270  printf("\n");
271  printf("Each -v increases verbosity level\n");
272 #endif /* linux */
273 #ifdef WIN32
274  printf("Usage: %s [/v[v]] READERHOSTNAME\n", pProgName);
275  printf("\n");
276  printf("Each /v increases verbosity level\n");
277 #endif /* WIN32 */
278  exit(1);
279 }
280 
281 
315 int
316 CMyApplication::run (
317  char * pReaderHostName)
318 {
319  CTypeRegistry * pTypeRegistry;
320  CConnection * pConn;
321  int rc;
322 
323  /*
324  * Allocate the type registry. This is needed
325  * by the connection to decode.
326  */
327  pTypeRegistry = getTheTypeRegistry();
328  if(NULL == pTypeRegistry)
329  {
330  printf("ERROR: getTheTypeRegistry failed\n");
331  return -1;
332  }
333 
334  /*
335  * Enroll impinj extension types into the
336  * type registry, in preparation for using
337  * Impinj extension params.
338  */
340 
341  /*
342  * Construct a connection (LLRP::CConnection).
343  * Using a 32kb max frame size for send/recv.
344  * The connection object is ready for business
345  * but not actually connected to the reader yet.
346  */
347  pConn = new CConnection(pTypeRegistry, 32u*1024u);
348  if(NULL == pConn)
349  {
350  printf("ERROR: new CConnection failed\n");
351  return -2;
352  }
353 
354  /*
355  * Open the connection to the reader
356  */
357  if(m_Verbose)
358  {
359  printf("INFO: Connecting to %s....\n", pReaderHostName);
360  }
361 
362  rc = pConn->openConnectionToReader(pReaderHostName);
363  if(0 != rc)
364  {
365  printf("ERROR: connect: %s (%d)\n", pConn->getConnectError(), rc);
366  delete pConn;
367  return -3;
368  }
369 
370  /*
371  * Record the pointer to the connection object so other
372  * routines can use it.
373  */
374  m_pConnectionToReader = pConn;
375 
376  if(m_Verbose)
377  {
378  printf("INFO: Connected, checking status....\n");
379  }
380 
381  /*
382  * Commence the sequence and check for errors as we go.
383  * See comments for each routine for details.
384  * Each routine prints messages.
385  */
386  rc = 1;
387  if(0 == checkConnectionStatus())
388  {
389  rc = 2;
390  if(0 == enableImpinjExtensions())
391  {
392  rc = 3;
393  if(0 == resetConfigurationToFactoryDefaults())
394  {
395  rc = 4;
396  if(0 == addROSpec())
397  {
398  rc = 5;
399  if(0 == enableROSpec())
400  {
401  //rc = 6;
402  //if(0 == startROSpec())
403  //{
404  rc = 7;
405  if(0 == awaitAndPrintReport(10))
406  {
407  rc = 8;
408  if(0 == stopROSpec())
409  {
410  rc = 0;
411  }
412  }
413  //}
414  }
415  }
416  }
417 
418  /*
419  * After we're done, try to leave the reader
420  * in a clean state for next use. This is best
421  * effort and no checking of the result is done.
422  */
423  if(m_Verbose)
424  {
425  printf("INFO: Clean up reader configuration...\n");
426  }
427  resetConfigurationToFactoryDefaults();
428  }
429  }
430 
431  if(m_Verbose)
432  {
433  printf("INFO: Finished\n");
434  }
435 
436  /*
437  * Close the connection and release its resources
438  */
439  pConn->closeConnectionToReader();
440  delete pConn;
441 
442  /*
443  * Done with the registry.
444  */
445  delete pTypeRegistry;
446 
447  /*
448  * When we get here all allocated memory should have been deallocated.
449  */
450 
451  return rc;
452 }
453 
454 
485 int
486 CMyApplication::checkConnectionStatus (void)
487 {
488  CMessage * pMessage;
491  CConnectionAttemptEvent * pEvent;
492 
493  /*
494  * Expect the notification within 10 seconds.
495  * It is suppose to be the very first message sent.
496  */
497  pMessage = recvMessage(10000);
498 
499  /*
500  * recvMessage() returns NULL if something went wrong.
501  */
502  if(NULL == pMessage)
503  {
504  /* recvMessage already tattled */
505  goto fail;
506  }
507 
508  /*
509  * Check to make sure the message is of the right type.
510  * The type label (pointer) in the message should be
511  * the type descriptor for READER_EVENT_NOTIFICATION.
512  */
513  if(&CREADER_EVENT_NOTIFICATION::s_typeDescriptor != pMessage->m_pType)
514  {
515  goto fail;
516  }
517 
518  /*
519  * Now that we are sure it is a READER_EVENT_NOTIFICATION,
520  * traverse to the ReaderEventNotificationData parameter.
521  */
522  pNtf = (CREADER_EVENT_NOTIFICATION *) pMessage;
523  pNtfData = pNtf->getReaderEventNotificationData();
524  if(NULL == pNtfData)
525  {
526  goto fail;
527  }
528 
529  /*
530  * The ConnectionAttemptEvent parameter must be present.
531  */
532  pEvent = pNtfData->getConnectionAttemptEvent();
533  if(NULL == pEvent)
534  {
535  goto fail;
536  }
537 
538  /*
539  * The status in the ConnectionAttemptEvent parameter
540  * must indicate connection success.
541  */
543  {
544  goto fail;
545  }
546 
547  /*
548  * Done with the message
549  */
550  delete pMessage;
551 
552  if(m_Verbose)
553  {
554  printf("INFO: Connection status OK\n");
555  }
556 
557  /*
558  * Victory.
559  */
560  return 0;
561 
562  fail:
563  /*
564  * Something went wrong. Tattle. Clean up. Return error.
565  */
566  printf("ERROR: checkConnectionStatus failed\n");
567  delete pMessage;
568  return -1;
569 }
570 
588 int
589 CMyApplication::enableImpinjExtensions (void)
590 {
592  CMessage * pRspMsg;
594 
595  /*
596  * Compose the command message
597  */
598  pCmd = new CIMPINJ_ENABLE_EXTENSIONS();
599  pCmd->setMessageID(m_messageID++);
600  /*
601  * Send the message, expect the response of certain type
602  */
603  pRspMsg = transact(pCmd);
604 
605  /*
606  * Done with the command message
607  */
608  delete pCmd;
609 
610  /*
611  * transact() returns NULL if something went wrong.
612  */
613  if(NULL == pRspMsg)
614  {
615  /* transact already tattled */
616  return -1;
617  }
618 
619  /*
620  * Cast to a CIMPINJ_ENABLE_EXTENSIONS_RESPONSE message.
621  */
622  pRsp = (CIMPINJ_ENABLE_EXTENSIONS_RESPONSE *) pRspMsg;
623 
624  /*
625  * Check the LLRPStatus parameter.
626  */
627  if(0 != checkLLRPStatus(pRsp->getLLRPStatus(),
628  "enableImpinjExtensions"))
629  {
630  /* checkLLRPStatus already tattled */
631  delete pRspMsg;
632  return -1;
633  }
634 
635  /*
636  * Done with the response message.
637  */
638  delete pRspMsg;
639 
640  /*
641  * Tattle progress, maybe
642  */
643  if(m_Verbose)
644  {
645  printf("INFO: Impinj Extensions are enabled\n");
646  }
647 
648  /*
649  * Victory.
650  */
651  return 0;
652 }
653 
674 int
675 CMyApplication::resetConfigurationToFactoryDefaults (void)
676 {
677  CSET_READER_CONFIG * pCmd;
678  CMessage * pRspMsg;
680 
681  /*
682  * Compose the command message
683  */
684  pCmd = new CSET_READER_CONFIG();
685  pCmd->setMessageID(m_messageID++);
686  pCmd->setResetToFactoryDefault(1);
687 
688  /*
689  * Send the message, expect the response of certain type
690  */
691  pRspMsg = transact(pCmd);
692 
693  /*
694  * Done with the command message
695  */
696  delete pCmd;
697 
698  /*
699  * transact() returns NULL if something went wrong.
700  */
701  if(NULL == pRspMsg)
702  {
703  /* transact already tattled */
704  return -1;
705  }
706 
707  /*
708  * Cast to a SET_READER_CONFIG_RESPONSE message.
709  */
710  pRsp = (CSET_READER_CONFIG_RESPONSE *) pRspMsg;
711 
712  /*
713  * Check the LLRPStatus parameter.
714  */
715  if(0 != checkLLRPStatus(pRsp->getLLRPStatus(),
716  "resetConfigurationToFactoryDefaults"))
717  {
718  /* checkLLRPStatus already tattled */
719  delete pRspMsg;
720  return -1;
721  }
722 
723  /*
724  * Done with the response message.
725  */
726  delete pRspMsg;
727 
728  /*
729  * Tattle progress, maybe
730  */
731  if(m_Verbose)
732  {
733  printf("INFO: Configuration reset to factory defaults\n");
734  }
735 
736  /*
737  * Victory.
738  */
739  return 0;
740 }
741 
742 
790 int
791 CMyApplication::addROSpec (void)
792 {
793  CROSpecStartTrigger * pROSpecStartTrigger =
794  new CROSpecStartTrigger();
795  pROSpecStartTrigger->setROSpecStartTriggerType(
797 
798  CROSpecStopTrigger * pROSpecStopTrigger = new CROSpecStopTrigger();
800  pROSpecStopTrigger->setDurationTriggerValue(0); /* n/a */
801 
802  CROBoundarySpec * pROBoundarySpec = new CROBoundarySpec();
803  pROBoundarySpec->setROSpecStartTrigger(pROSpecStartTrigger);
804  pROBoundarySpec->setROSpecStopTrigger(pROSpecStopTrigger);
805 
806  CAISpecStopTrigger * pAISpecStopTrigger = new CAISpecStopTrigger();
808  pAISpecStopTrigger->setDurationTrigger(0);
809 
811 
812 
813  CInventoryParameterSpec * pInventoryParameterSpec =
815  pInventoryParameterSpec->setInventoryParameterSpecID(1234);
816  pInventoryParameterSpec->setProtocolID(AirProtocols_EPCGlobalClass1Gen2);
817 
818  CAntennaConfiguration * pAntennaConfig = new CAntennaConfiguration();
819  pAntennaConfig->setAntennaID(1);
820 
821  CRFTransmitter * pRFTransmitter = new CRFTransmitter();
822  pRFTransmitter->setHopTableID(1);
823  pRFTransmitter->setChannelIndex(0);
824  pRFTransmitter->setTransmitPower(81);
825  pAntennaConfig->setRFTransmitter(pRFTransmitter);
826 
827  CC1G2InventoryCommand * pC1G2InventoryCmd = new CC1G2InventoryCommand();
828  pC1G2InventoryCmd->setTagInventoryStateAware(1);
829 
830 // Filter 1
831  CC1G2Filter * pC1G2Filter1 = new CC1G2Filter();
833 
834  CC1G2TagInventoryMask * pC1G2TagInvMask1 = new CC1G2TagInventoryMask();
835  pC1G2TagInvMask1->setMB(2);
836  pC1G2TagInvMask1->setPointer(0);
837 
838  llrp_u1v_t tagMask1 = llrp_u1v_t(15);
839  tagMask1.m_nBit = 15;
840  tagMask1.m_pValue[0] = 0xE2;
841  tagMask1.m_pValue[1] = 0x00;
842  pC1G2TagInvMask1->setTagMask(tagMask1);
843 
844  pC1G2Filter1->setC1G2TagInventoryMask(pC1G2TagInvMask1);
845 
846  CC1G2TagInventoryStateAwareFilterAction * pC1G2TagInvStateAwareFilterAction1 = new CC1G2TagInventoryStateAwareFilterAction();
847  pC1G2TagInvStateAwareFilterAction1->setTarget(C1G2StateAwareTarget_Inventoried_State_For_Session_S3);
848  pC1G2TagInvStateAwareFilterAction1->setAction(C1G2StateAwareAction_AssertSLOrA_DeassertSLOrB);
849 
850  pC1G2Filter1->setC1G2TagInventoryStateAwareFilterAction(pC1G2TagInvStateAwareFilterAction1);
851 
852  pC1G2InventoryCmd->addC1G2Filter(pC1G2Filter1);
853 
854  // Filter 2
855  CC1G2Filter * pC1G2Filter2 = new CC1G2Filter();
857 
858  CC1G2TagInventoryMask * pC1G2TagInvMask2 = new CC1G2TagInventoryMask();
859  pC1G2TagInvMask2->setMB(1);
860  pC1G2TagInvMask2->setPointer(0);
861 
862  llrp_u1v_t tagMask2 = llrp_u1v_t(16);
863  tagMask2.m_nBit = 16;
864  tagMask2.m_pValue[0] = 0xE2;
865  tagMask2.m_pValue[1] = 0x00;
866  pC1G2TagInvMask2->setTagMask(tagMask2);
867 
868  pC1G2Filter2->setC1G2TagInventoryMask(pC1G2TagInvMask2);
869 
870  CC1G2TagInventoryStateAwareFilterAction * pC1G2TagInvStateAwareFilterAction2 = new CC1G2TagInventoryStateAwareFilterAction();
871  pC1G2TagInvStateAwareFilterAction2->setTarget(C1G2StateAwareTarget_Inventoried_State_For_Session_S2);
872  pC1G2TagInvStateAwareFilterAction2->setAction(C1G2StateAwareAction_AssertSLOrA_DeassertSLOrB);
873 
874  pC1G2Filter2->setC1G2TagInventoryStateAwareFilterAction(pC1G2TagInvStateAwareFilterAction2);
875 
876  pC1G2InventoryCmd->addC1G2Filter(pC1G2Filter2);
877 
878 // Filter 3
879  CC1G2Filter * pC1G2Filter3 = new CC1G2Filter();
881 
882  CC1G2TagInventoryMask * pC1G2TagInvMask3 = new CC1G2TagInventoryMask();
883  pC1G2TagInvMask3->setMB(3);
884  pC1G2TagInvMask3->setPointer(0);
885 
886  llrp_u1v_t tagMask3 = llrp_u1v_t(32);
887  tagMask3.m_nBit = 32;
888  tagMask3.m_pValue[0] = 0xFF;
889  tagMask3.m_pValue[1] = 0xFF;
890  tagMask3.m_pValue[2] = 0xE2;
891  tagMask3.m_pValue[3] = 0x00;
892  pC1G2TagInvMask3->setTagMask(tagMask3);
893 
894  pC1G2Filter3->setC1G2TagInventoryMask(pC1G2TagInvMask3);
895 
896  CC1G2TagInventoryStateAwareFilterAction * pC1G2TagInvStateAwareFilterAction3 = new CC1G2TagInventoryStateAwareFilterAction();
897  pC1G2TagInvStateAwareFilterAction3->setTarget(C1G2StateAwareTarget_Inventoried_State_For_Session_S1);
898  pC1G2TagInvStateAwareFilterAction3->setAction(C1G2StateAwareAction_AssertSLOrA_DeassertSLOrB);
899 
900  pC1G2Filter3->setC1G2TagInventoryStateAwareFilterAction(pC1G2TagInvStateAwareFilterAction3);
901 
902  pC1G2InventoryCmd->addC1G2Filter(pC1G2Filter3);
903 
904 // Filter 4
905  CC1G2Filter * pC1G2Filter4 = new CC1G2Filter();
907 
908  CC1G2TagInventoryMask * pC1G2TagInvMask4 = new CC1G2TagInventoryMask();
909  pC1G2TagInvMask4->setMB(2);
910  pC1G2TagInvMask4->setPointer(0);
911 
912  llrp_u1v_t tagMask4 = llrp_u1v_t(8);
913  tagMask4.m_nBit = 8;
914  tagMask4.m_pValue[0] = 0xAA;
915  pC1G2TagInvMask4->setTagMask(tagMask4);
916 
917  pC1G2Filter4->setC1G2TagInventoryMask(pC1G2TagInvMask4);
918 
919  CC1G2TagInventoryStateAwareFilterAction * pC1G2TagInvStateAwareFilterAction4 = new CC1G2TagInventoryStateAwareFilterAction();
920  pC1G2TagInvStateAwareFilterAction4->setTarget(C1G2StateAwareTarget_Inventoried_State_For_Session_S0);
921  pC1G2TagInvStateAwareFilterAction4->setAction(C1G2StateAwareAction_AssertSLOrA_DeassertSLOrB);
922 
923  pC1G2Filter4->setC1G2TagInventoryStateAwareFilterAction(pC1G2TagInvStateAwareFilterAction4);
924 
925  pC1G2InventoryCmd->addC1G2Filter(pC1G2Filter4);
926 
927 // Filter 5
928  CC1G2Filter * pC1G2Filter5 = new CC1G2Filter();
930 
931  CC1G2TagInventoryMask * pC1G2TagInvMask5 = new CC1G2TagInventoryMask();
932  pC1G2TagInvMask5->setMB(1);
933  pC1G2TagInvMask5->setPointer(0);
934 
935  llrp_u1v_t tagMask5 = llrp_u1v_t(16);
936  tagMask5.m_nBit = 16;
937  tagMask5.m_pValue[0] = 0xFF;
938  tagMask5.m_pValue[1] = 0xFF;
939  pC1G2TagInvMask5->setTagMask(tagMask5);
940 
941  pC1G2Filter5->setC1G2TagInventoryMask(pC1G2TagInvMask5);
942 
943  CC1G2TagInventoryStateAwareFilterAction * pC1G2TagInvStateAwareFilterAction5 = new CC1G2TagInventoryStateAwareFilterAction();
944  pC1G2TagInvStateAwareFilterAction5->setTarget(C1G2StateAwareTarget_SL);
945  pC1G2TagInvStateAwareFilterAction5->setAction(C1G2StateAwareAction_AssertSLOrA_DeassertSLOrB);
946 
947  pC1G2Filter5->setC1G2TagInventoryStateAwareFilterAction(pC1G2TagInvStateAwareFilterAction5);
948 
949  pC1G2InventoryCmd->addC1G2Filter(pC1G2Filter5);
950 
951 //
952 
953 
954  CC1G2SingulationControl * pC1G2SingulationControl = new CC1G2SingulationControl();
955  pC1G2SingulationControl->setSession(1);
956  pC1G2SingulationControl->setTagPopulation(32);
957  pC1G2SingulationControl->setTagTransitTime(0);
958 
960  pC1G2TagInvStateAwareSingAction->setI(C1G2TagInventoryStateAwareI_State_B);
961  pC1G2TagInvStateAwareSingAction->setS(C1G2TagInventoryStateAwareS_SL);
962 
963  pC1G2SingulationControl->setC1G2TagInventoryStateAwareSingulationAction(pC1G2TagInvStateAwareSingAction);
964 
965  pC1G2InventoryCmd->setC1G2SingulationControl(pC1G2SingulationControl);
966 
967  pAntennaConfig->addAirProtocolInventoryCommandSettings(pC1G2InventoryCmd);
968 
969  pInventoryParameterSpec->addAntennaConfiguration(pAntennaConfig);
970 
972  llrp_u16v_t AntennaIDs = llrp_u16v_t(1);
973  AntennaIDs.m_pValue[0] = 1;
974 
975  CAISpec * pAISpec = new CAISpec();
976  pAISpec->setAntennaIDs(AntennaIDs);
977  pAISpec->setAISpecStopTrigger(pAISpecStopTrigger);
978  pAISpec->addInventoryParameterSpec(pInventoryParameterSpec);
979 
980 
982  CROReportSpec * pROReportSpec = new CROReportSpec();
984  pROReportSpec->setN(1000);
985 
986  CTagReportContentSelector * pTagRptContentSelector = new CTagReportContentSelector();
987  pTagRptContentSelector->setEnableROSpecID(1);
988  pTagRptContentSelector->setEnableSpecIndex(1);
989  pTagRptContentSelector->setEnableInventoryParameterSpecID(1);
990  pTagRptContentSelector->setEnableAntennaID(1);
991  pTagRptContentSelector->setEnableChannelIndex(1);
992  pTagRptContentSelector->setEnablePeakRSSI(1);
993  pTagRptContentSelector->setEnableFirstSeenTimestamp(1);
994  pTagRptContentSelector->setEnableLastSeenTimestamp(1);
995  pTagRptContentSelector->setEnableTagSeenCount(1);
996  pTagRptContentSelector->setEnableAccessSpecID(1);
997 
998  pROReportSpec->setTagReportContentSelector(pTagRptContentSelector);
1000 
1001 
1002  CROSpec * pROSpec = new CROSpec();
1003  pROSpec->setROSpecID(1);
1004  pROSpec->setPriority(0);
1006  pROSpec->setROBoundarySpec(pROBoundarySpec);
1007  pROSpec->addSpecParameter(pAISpec);
1008  pROSpec->setROReportSpec(pROReportSpec);
1009 
1010  CADD_ROSPEC * pCmd;
1011  CMessage * pRspMsg;
1012  CADD_ROSPEC_RESPONSE * pRsp;
1013 
1014  /*
1015  * Compose the command message.
1016  * N.B.: After the message is composed, all the parameters
1017  * constructed, immediately above, are considered "owned"
1018  * by the command message. When it is destructed so
1019  * too will the parameters be.
1020  */
1021  pCmd = new CADD_ROSPEC();
1022  pCmd->setMessageID(m_messageID++);
1023  pCmd->setROSpec(pROSpec);
1024 
1025  /*
1026  * Send the message, expect the response of certain type
1027  */
1028  pRspMsg = transact(pCmd);
1029 
1030  /*
1031  * Done with the command message.
1032  * N.B.: And the parameters
1033  */
1034  delete pCmd;
1035 
1036  /*
1037  * transact() returns NULL if something went wrong.
1038  */
1039  if(NULL == pRspMsg)
1040  {
1041  /* transact already tattled */
1042  return -1;
1043  }
1044 
1045  /*
1046  * Cast to a ADD_ROSPEC_RESPONSE message.
1047  */
1048  pRsp = (CADD_ROSPEC_RESPONSE *) pRspMsg;
1049 
1050  /*
1051  * Check the LLRPStatus parameter.
1052  */
1053  if(0 != checkLLRPStatus(pRsp->getLLRPStatus(), "addROSpec"))
1054  {
1055  /* checkLLRPStatus already tattled */
1056  delete pRspMsg;
1057  return -1;
1058  }
1059 
1060  /*
1061  * Done with the response message.
1062  */
1063  delete pRspMsg;
1064 
1065  /*
1066  * Tattle progress, maybe
1067  */
1068  if(m_Verbose)
1069  {
1070  printf("INFO: ROSpec added\n");
1071  }
1072 
1073  /*
1074  * Victory.
1075  */
1076  return 0;
1077 }
1078 
1079 
1097 int
1098 CMyApplication::enableROSpec (void)
1099 {
1100  CENABLE_ROSPEC * pCmd;
1101  CMessage * pRspMsg;
1102  CENABLE_ROSPEC_RESPONSE * pRsp;
1103 
1104  /*
1105  * Compose the command message
1106  */
1107  pCmd = new CENABLE_ROSPEC();
1108  pCmd->setMessageID(m_messageID++);
1109  pCmd->setROSpecID(1);
1110 
1111  /*
1112  * Send the message, expect the response of certain type
1113  */
1114  pRspMsg = transact(pCmd);
1115 
1116  /*
1117  * Done with the command message
1118  */
1119  delete pCmd;
1120 
1121  /*
1122  * transact() returns NULL if something went wrong.
1123  */
1124  if(NULL == pRspMsg)
1125  {
1126  /* transact already tattled */
1127  return -1;
1128  }
1129 
1130  /*
1131  * Cast to a ENABLE_ROSPEC_RESPONSE message.
1132  */
1133  pRsp = (CENABLE_ROSPEC_RESPONSE *) pRspMsg;
1134 
1135  /*
1136  * Check the LLRPStatus parameter.
1137  */
1138  if(0 != checkLLRPStatus(pRsp->getLLRPStatus(), "enableROSpec"))
1139  {
1140  /* checkLLRPStatus already tattled */
1141  delete pRspMsg;
1142  return -1;
1143  }
1144 
1145  /*
1146  * Done with the response message.
1147  */
1148  delete pRspMsg;
1149 
1150  /*
1151  * Tattle progress, maybe
1152  */
1153  if(m_Verbose)
1154  {
1155  printf("INFO: ROSpec enabled\n");
1156  }
1157 
1158  /*
1159  * Victory.
1160  */
1161  return 0;
1162 }
1163 
1164 
1182 int
1183 CMyApplication::startROSpec (void)
1184 {
1185  CSTART_ROSPEC * pCmd;
1186  CMessage * pRspMsg;
1187  CSTART_ROSPEC_RESPONSE * pRsp;
1188 
1189  /*
1190  * Compose the command message
1191  */
1192  pCmd = new CSTART_ROSPEC();
1193  pCmd->setMessageID(m_messageID++);
1194  pCmd->setROSpecID(1);
1195 
1196  /*
1197  * Send the message, expect the response of certain type
1198  */
1199  pRspMsg = transact(pCmd);
1200 
1201  /*
1202  * Done with the command message
1203  */
1204  delete pCmd;
1205 
1206  /*
1207  * transact() returns NULL if something went wrong.
1208  */
1209  if(NULL == pRspMsg)
1210  {
1211  /* transact already tattled */
1212  return -1;
1213  }
1214 
1215  /*
1216  * Cast to a START_ROSPEC_RESPONSE message.
1217  */
1218  pRsp = (CSTART_ROSPEC_RESPONSE *) pRspMsg;
1219 
1220  /*
1221  * Check the LLRPStatus parameter.
1222  */
1223  if(0 != checkLLRPStatus(pRsp->getLLRPStatus(), "startROSpec"))
1224  {
1225  /* checkLLRPStatus already tattled */
1226  delete pRspMsg;
1227  return -1;
1228  }
1229 
1230  /*
1231  * Done with the response message.
1232  */
1233  delete pRspMsg;
1234 
1235  /*
1236  * Tattle progress
1237  */
1238  if(m_Verbose)
1239  {
1240  printf("INFO: ROSpec started\n");
1241  }
1242 
1243  /*
1244  * Victory.
1245  */
1246  return 0;
1247 }
1248 
1266 int
1267 CMyApplication::stopROSpec (void)
1268 {
1269  CSTOP_ROSPEC * pCmd;
1270  CMessage * pRspMsg;
1271  CSTOP_ROSPEC_RESPONSE * pRsp;
1272 
1273  /*
1274  * Compose the command message
1275  */
1276  pCmd = new CSTOP_ROSPEC();
1277  pCmd->setMessageID(m_messageID++);
1278  pCmd->setROSpecID(1);
1279 
1280  /*
1281  * Send the message, expect the response of certain type
1282  */
1283  pRspMsg = transact(pCmd);
1284 
1285  /*
1286  * Done with the command message
1287  */
1288  delete pCmd;
1289 
1290  /*
1291  * transact() returns NULL if something went wrong.
1292  */
1293  if(NULL == pRspMsg)
1294  {
1295  /* transact already tattled */
1296  return -1;
1297  }
1298 
1299  /*
1300  * Cast to a STOP_ROSPEC_RESPONSE message.
1301  */
1302  pRsp = (CSTOP_ROSPEC_RESPONSE *) pRspMsg;
1303 
1304  /*
1305  * Check the LLRPStatus parameter.
1306  */
1307  if(0 != checkLLRPStatus(pRsp->getLLRPStatus(), "stopROSpec"))
1308  {
1309  /* checkLLRPStatus already tattled */
1310  delete pRspMsg;
1311  return -1;
1312  }
1313 
1314  /*
1315  * Done with the response message.
1316  */
1317  delete pRspMsg;
1318 
1319  /*
1320  * Tattle progress
1321  */
1322  if(m_Verbose)
1323  {
1324  printf("INFO: ROSpec stopped\n");
1325  }
1326 
1327  /*
1328  * Victory.
1329  */
1330  return 0;
1331 }
1332 
1333 
1353 int
1354 CMyApplication::awaitAndPrintReport (int timeout)
1355 {
1356  int bDone = 0;
1357  int retVal = 0;
1358  time_t startTime = time(NULL);
1359  time_t tempTime;
1360  /*
1361  * Keep receiving messages until done or until
1362  * something bad happens.
1363  */
1364  while(!bDone)
1365  {
1366  CMessage * pMessage;
1367  const CTypeDescriptor * pType;
1368 
1369  /*
1370  * Wait up to 1 second for a report. Check
1371  * That way, we can check the timestamp even if
1372  * there are no reports coming in
1373  */
1374  pMessage = recvMessage(1000);
1375 
1376  /* validate the timestamp */
1377  tempTime = time(NULL);
1378  if(difftime(tempTime, startTime) > timeout)
1379  {
1380  bDone=1;
1381  }
1382 
1383  if(NULL == pMessage)
1384  {
1385  continue;
1386  }
1387 
1388  /*
1389  * What happens depends on what kind of message
1390  * received. Use the type label (m_pType) to
1391  * discriminate message types.
1392  */
1393  pType = pMessage->m_pType;
1394 
1395  /*
1396  * Is it a tag report? If so, print it out.
1397  */
1398  if(&CRO_ACCESS_REPORT::s_typeDescriptor == pType)
1399  {
1400  CRO_ACCESS_REPORT * pNtf;
1401 
1402  pNtf = (CRO_ACCESS_REPORT *) pMessage;
1403 
1404  printTagReportData(pNtf);
1405  }
1406 
1407  /*
1408  * Is it a reader event? This example only recognizes
1409  * AntennaEvents.
1410  */
1411  else if(&CREADER_EVENT_NOTIFICATION::s_typeDescriptor == pType)
1412  {
1414  CReaderEventNotificationData *pNtfData;
1415 
1416  pNtf = (CREADER_EVENT_NOTIFICATION *) pMessage;
1417 
1418  pNtfData = pNtf->getReaderEventNotificationData();
1419  if(NULL != pNtfData)
1420  {
1421  handleReaderEventNotification(pNtfData);
1422  }
1423  else
1424  {
1425  /*
1426  * This should never happen. Using continue
1427  * to keep indent depth down.
1428  */
1429  printf("WARNING: READER_EVENT_NOTIFICATION without data\n");
1430  }
1431  }
1432 
1433  /*
1434  * Hmmm. Something unexpected. Just tattle and keep going.
1435  */
1436  else
1437  {
1438  printf("WARNING: Ignored unexpected message during monitor: %s\n",
1439  pType->m_pName);
1440  }
1441 
1442  /*
1443  * Done with the received message
1444  */
1445  delete pMessage;
1446  }
1447 
1448  return retVal;
1449 }
1450 
1451 
1466 void
1467 CMyApplication::printTagReportData (
1468  CRO_ACCESS_REPORT * pRO_ACCESS_REPORT)
1469 {
1470  std::list<CTagReportData *>::iterator Cur;
1471 
1472  unsigned int nEntry = 0;
1473 
1474  /*
1475  * Loop through and count the number of entries
1476  */
1477  for(
1478  Cur = pRO_ACCESS_REPORT->beginTagReportData();
1479  Cur != pRO_ACCESS_REPORT->endTagReportData();
1480  Cur++)
1481  {
1482  nEntry++;
1483  }
1484 
1485  if(m_Verbose)
1486  {
1487  printf("INFO: %u tag report entries\n", nEntry);
1488  }
1489 
1490  /*
1491  * Loop through again and print each entry.
1492  */
1493  for(
1494  Cur = pRO_ACCESS_REPORT->beginTagReportData();
1495  Cur != pRO_ACCESS_REPORT->endTagReportData();
1496  Cur++)
1497  {
1498  printOneTagReportData(*Cur);
1499  }
1500 }
1501 
1502 
1511 void
1512 CMyApplication::formatOneEPC (
1513  CParameter *pEPCParameter,
1514  char *buf,
1515  int buflen)
1516 {
1517  char * p = buf;
1518  int bufsize = buflen;
1519  int written = 0;
1520 
1521  if(NULL != pEPCParameter)
1522  {
1523  const CTypeDescriptor * pType;
1524  llrp_u96_t my_u96;
1525  llrp_u1v_t my_u1v;
1526  llrp_u8_t * pValue = NULL;
1527  unsigned int n, i;
1528 
1529  pType = pEPCParameter->m_pType;
1530  if(&CEPC_96::s_typeDescriptor == pType)
1531  {
1532  CEPC_96 *pEPC_96;
1533 
1534  pEPC_96 = (CEPC_96 *) pEPCParameter;
1535  my_u96 = pEPC_96->getEPC();
1536  pValue = my_u96.m_aValue;
1537  n = 12u;
1538  }
1539  else if(&CEPCData::s_typeDescriptor == pType)
1540  {
1541  CEPCData * pEPCData;
1542 
1543  pEPCData = (CEPCData *) pEPCParameter;
1544  my_u1v = pEPCData->getEPC();
1545  pValue = my_u1v.m_pValue;
1546  n = (my_u1v.m_nBit + 7u) / 8u;
1547  }
1548 
1549  if(NULL != pValue)
1550  {
1551  for(i = 0; i < n; i++)
1552  {
1553  if(0 < i && i%2 == 0 && 1 < bufsize)
1554  {
1555  *p++ = '-';
1556  bufsize--;
1557  }
1558  if(bufsize > 2)
1559  {
1560  written = snprintf(p, bufsize, "%02X", pValue[i]);
1561  bufsize -= written;
1562  p+= written;
1563  }
1564  }
1565  }
1566  else
1567  {
1568  written = snprintf(p, bufsize, "%s", "---unknown-epc-data-type---");
1569  bufsize -= written;
1570  p += written;
1571  }
1572  }
1573  else
1574  {
1575  written = snprintf(p, bufsize, "%s", "--null epc---");
1576  bufsize -= written;
1577  p += written;
1578  }
1579 
1580  // null terminate this for good practice
1581  buf[buflen-1] = '\0';
1582 
1583 }
1584 
1593 void
1594 CMyApplication::printOneTagReportData (
1595  CTagReportData * pTagReportData)
1596 {
1597  char aBuf[64];
1598 
1599  /*
1600  * Print the EPC. It could be an 96-bit EPC_96 parameter
1601  * or an variable length EPCData parameter.
1602  */
1603 
1604  CParameter * pEPCParameter =
1605  pTagReportData->getEPCParameter();
1606 
1607  formatOneEPC(pEPCParameter, aBuf, 64);
1608 
1609  /*
1610  * End of line
1611  */
1612  printf("EPC: %s\n", aBuf);
1613 }
1614 
1615 
1629 void
1630 CMyApplication::handleReaderEventNotification (
1631  CReaderEventNotificationData *pNtfData)
1632 {
1633  CAntennaEvent * pAntennaEvent;
1634  CReaderExceptionEvent * pReaderExceptionEvent;
1635  int nReported = 0;
1636 
1637  pAntennaEvent = pNtfData->getAntennaEvent();
1638  if(NULL != pAntennaEvent)
1639  {
1640  handleAntennaEvent(pAntennaEvent);
1641  nReported++;
1642  }
1643 
1644  pReaderExceptionEvent = pNtfData->getReaderExceptionEvent();
1645  if(NULL != pReaderExceptionEvent)
1646  {
1647  handleReaderExceptionEvent(pReaderExceptionEvent);
1648  nReported++;
1649  }
1650 
1651  /*
1652  * Similarly handle other events here:
1653  * HoppingEvent
1654  * GPIEvent
1655  * ROSpecEvent
1656  * ReportBufferLevelWarningEvent
1657  * ReportBufferOverflowErrorEvent
1658  * RFSurveyEvent
1659  * AISpecEvent
1660  * ConnectionAttemptEvent
1661  * ConnectionCloseEvent
1662  * Custom
1663  */
1664 
1665  if(0 == nReported)
1666  {
1667  printf("NOTICE: Unexpected (unhandled) ReaderEvent\n");
1668  }
1669 }
1670 
1671 
1683 void
1684 CMyApplication::handleAntennaEvent (
1685  CAntennaEvent * pAntennaEvent)
1686 {
1687  EAntennaEventType eEventType;
1688  llrp_u16_t AntennaID;
1689  char * pStateStr;
1690 
1691  eEventType = pAntennaEvent->getEventType();
1692  AntennaID = pAntennaEvent->getAntennaID();
1693 
1694  switch(eEventType)
1695  {
1697  pStateStr = "disconnected";
1698  break;
1699 
1701  pStateStr = "connected";
1702  break;
1703 
1704  default:
1705  pStateStr = "?unknown-event?";
1706  break;
1707  }
1708 
1709  printf("NOTICE: Antenna %d is %s\n", AntennaID, pStateStr);
1710 }
1711 
1712 
1725 void
1726 CMyApplication::handleReaderExceptionEvent (
1727  CReaderExceptionEvent * pReaderExceptionEvent)
1728 {
1729  llrp_utf8v_t Message;
1730 
1731  Message = pReaderExceptionEvent->getMessage();
1732 
1733  if(0 < Message.m_nValue && NULL != Message.m_pValue)
1734  {
1735  printf("NOTICE: ReaderException '%.*s'\n",
1736  Message.m_nValue, Message.m_pValue);
1737  }
1738  else
1739  {
1740  printf("NOTICE: ReaderException but no message\n");
1741  }
1742 }
1743 
1744 
1763 int
1764 CMyApplication::checkLLRPStatus (
1765  CLLRPStatus * pLLRPStatus,
1766  char * pWhatStr)
1767 {
1768  /*
1769  * The LLRPStatus parameter is mandatory in all responses.
1770  * If it is missing there should have been a decode error.
1771  * This just makes sure (remember, this program is a
1772  * diagnostic and suppose to catch LTKC mistakes).
1773  */
1774  if(NULL == pLLRPStatus)
1775  {
1776  printf("ERROR: %s missing LLRP status\n", pWhatStr);
1777  return -1;
1778  }
1779 
1780  /*
1781  * Make sure the status is M_Success.
1782  * If it isn't, print the error string if one.
1783  * This does not try to pretty-print the status
1784  * code. To get that, run this program with -vv
1785  * and examine the XML output.
1786  */
1787  if(StatusCode_M_Success != pLLRPStatus->getStatusCode())
1788  {
1789  llrp_utf8v_t ErrorDesc;
1790 
1791  ErrorDesc = pLLRPStatus->getErrorDescription();
1792 
1793  if(0 == ErrorDesc.m_nValue)
1794  {
1795  printf("ERROR: %s failed, no error description given\n",
1796  pWhatStr);
1797  }
1798  else
1799  {
1800  printf("ERROR: %s failed, %.*s\n",
1801  pWhatStr, ErrorDesc.m_nValue, ErrorDesc.m_pValue);
1802  }
1803  return -2;
1804  }
1805 
1806  /*
1807  * Victory. Everything is fine.
1808  */
1809  return 0;
1810 }
1811 
1812 
1836 CMessage *
1837 CMyApplication::transact (
1838  CMessage * pSendMsg)
1839 {
1840  CConnection * pConn = m_pConnectionToReader;
1841  CMessage * pRspMsg;
1842 
1843  /*
1844  * Print the XML text for the outbound message if
1845  * verbosity is 2 or higher.
1846  */
1847  if(1 < m_Verbose)
1848  {
1849  printf("\n===================================\n");
1850  printf("INFO: Transact sending\n");
1851  printXMLMessage(pSendMsg);
1852  }
1853 
1854  /*
1855  * Send the message, expect the response of certain type.
1856  * If LLRP::CConnection::transact() returns NULL then there was
1857  * an error. In that case we try to print the error details.
1858  */
1859  pRspMsg = pConn->transact(pSendMsg, 5000);
1860 
1861  if(NULL == pRspMsg)
1862  {
1863  const CErrorDetails * pError = pConn->getTransactError();
1864 
1865  printf("ERROR: %s transact failed, %s\n",
1866  pSendMsg->m_pType->m_pName,
1867  pError->m_pWhatStr ? pError->m_pWhatStr : "no reason given");
1868 
1869  if(NULL != pError->m_pRefType)
1870  {
1871  printf("ERROR: ... reference type %s\n",
1872  pError->m_pRefType->m_pName);
1873  }
1874 
1875  if(NULL != pError->m_pRefField)
1876  {
1877  printf("ERROR: ... reference field %s\n",
1878  pError->m_pRefField->m_pName);
1879  }
1880 
1881  return NULL;
1882  }
1883 
1884  /*
1885  * Print the XML text for the inbound message if
1886  * verbosity is 2 or higher.
1887  */
1888  if(1 < m_Verbose)
1889  {
1890  printf("\n- - - - - - - - - - - - - - - - - -\n");
1891  printf("INFO: Transact received response\n");
1892  printXMLMessage(pRspMsg);
1893  }
1894 
1895  /*
1896  * If it is an ERROR_MESSAGE (response from reader
1897  * when it can't understand the request), tattle
1898  * and declare defeat.
1899  */
1900  if(&CERROR_MESSAGE::s_typeDescriptor == pRspMsg->m_pType)
1901  {
1902  const CTypeDescriptor * pResponseType;
1903 
1904  pResponseType = pSendMsg->m_pType->m_pResponseType;
1905 
1906  printf("ERROR: Received ERROR_MESSAGE instead of %s\n",
1907  pResponseType->m_pName);
1908  delete pRspMsg;
1909  pRspMsg = NULL;
1910  }
1911 
1912  return pRspMsg;
1913 }
1914 
1915 
1940 CMessage *
1941 CMyApplication::recvMessage (
1942  int nMaxMS)
1943 {
1944  CConnection * pConn = m_pConnectionToReader;
1945  CMessage * pMessage;
1946 
1947  /*
1948  * Receive the message subject to a time limit
1949  */
1950  pMessage = pConn->recvMessage(nMaxMS);
1951 
1952  /*
1953  * If LLRP::CConnection::recvMessage() returns NULL then there was
1954  * an error. In that case we try to print the error details.
1955  */
1956  if(NULL == pMessage)
1957  {
1958  const CErrorDetails * pError = pConn->getRecvError();
1959 
1960  /* don't warn on timeout since this is a polling example */
1961  if(pError->m_eResultCode != RC_RecvTimeout)
1962  {
1963  printf("ERROR: recvMessage failed, %s\n",
1964  pError->m_pWhatStr ? pError->m_pWhatStr : "no reason given");
1965  }
1966 
1967  if(NULL != pError->m_pRefType)
1968  {
1969  printf("ERROR: ... reference type %s\n",
1970  pError->m_pRefType->m_pName);
1971  }
1972 
1973  if(NULL != pError->m_pRefField)
1974  {
1975  printf("ERROR: ... reference field %s\n",
1976  pError->m_pRefField->m_pName);
1977  }
1978 
1979  return NULL;
1980  }
1981 
1982  /*
1983  * Print the XML text for the inbound message if
1984  * verbosity is 2 or higher.
1985  */
1986  if(1 < m_Verbose)
1987  {
1988  printf("\n===================================\n");
1989  printf("INFO: Message received\n");
1990  printXMLMessage(pMessage);
1991  }
1992 
1993  return pMessage;
1994 }
1995 
1996 
2014 int
2015 CMyApplication::sendMessage (
2016  CMessage * pSendMsg)
2017 {
2018  CConnection * pConn = m_pConnectionToReader;
2019 
2020  /*
2021  * Print the XML text for the outbound message if
2022  * verbosity is 2 or higher.
2023  */
2024  if(1 < m_Verbose)
2025  {
2026  printf("\n===================================\n");
2027  printf("INFO: Sending\n");
2028  printXMLMessage(pSendMsg);
2029  }
2030 
2031  /*
2032  * If LLRP::CConnection::sendMessage() returns other than RC_OK
2033  * then there was an error. In that case we try to print
2034  * the error details.
2035  */
2036  if(RC_OK != pConn->sendMessage(pSendMsg))
2037  {
2038  const CErrorDetails * pError = pConn->getSendError();
2039 
2040  printf("ERROR: %s sendMessage failed, %s\n",
2041  pSendMsg->m_pType->m_pName,
2042  pError->m_pWhatStr ? pError->m_pWhatStr : "no reason given");
2043 
2044  if(NULL != pError->m_pRefType)
2045  {
2046  printf("ERROR: ... reference type %s\n",
2047  pError->m_pRefType->m_pName);
2048  }
2049 
2050  if(NULL != pError->m_pRefField)
2051  {
2052  printf("ERROR: ... reference field %s\n",
2053  pError->m_pRefField->m_pName);
2054  }
2055 
2056  return -1;
2057  }
2058 
2059  /*
2060  * Victory
2061  */
2062  return 0;
2063 }
2064 
2065 
2079 void
2080 CMyApplication::printXMLMessage (
2081  CMessage * pMessage)
2082 {
2083  char aBuf[100*1024];
2084 
2085  /*
2086  * Convert the message to an XML string.
2087  * This fills the buffer with either the XML string
2088  * or an error message. The return value could
2089  * be checked.
2090  */
2091 
2092  pMessage->toXMLString(aBuf, sizeof aBuf);
2093 
2094  /*
2095  * Print the XML Text to the standard output.
2096  */
2097  printf("%s", aBuf);
2098 }
void setChannelIndex(llrp_u16_t value)
Set accessor functions for the LLRP ChannelIndex field.
Definition: ltkcpp.h:13259
Class Definition CROBoundarySpec for LLRP parameter ROBoundarySpec.
Definition: ltkcpp.h:9540
void enrollImpinjTypesIntoRegistry(CTypeRegistry *pTypeRegistry)
Enrolls the types for Impinj into the LTKCPP registry.
void setDurationTrigger(llrp_u32_t value)
Set accessor functions for the LLRP DurationTrigger field.
Definition: ltkcpp.h:10523
void setAction(EC1G2StateAwareAction value)
Set accessor functions for the LLRP Action field.
Definition: ltkcpp.h:20616
char * m_pName
String name of field (e.g. "ROSpecID")
Definition: ltkcpp_base.h:840
void setAntennaIDs(llrp_u16v_t value)
Set accessor functions for the LLRP AntennaIDs field.
Definition: ltkcpp.h:10303
const CTypeDescriptor * m_pType
The type descriptor desribing this element.
Definition: ltkcpp_base.h:972
void setROSpecID(llrp_u32_t value)
Set accessor functions for the LLRP ROSpecID field.
Definition: ltkcpp.h:2922
Class Definition CAntennaConfiguration for LLRP parameter AntennaConfiguration.
Definition: ltkcpp.h:12905
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
Definition: ltkcpp.h:2437
llrp_u8_t * m_pValue
Pointer to the first array element.
Definition: ltkcpp_base.h:443
Class for LLRP basic type u16v (List of unsigned 16-bit values)
Definition: ltkcpp_base.h:179
EResultCode setTagReportContentSelector(CTagReportContentSelector *pValue)
Set accessor functions for the LLRP TagReportContentSelector sub-parameter.
EResultCode addC1G2Filter(CC1G2Filter *pValue)
Add a C1G2Filter to the LLRP sub-parameter list.
std::list< CTagReportData * >::iterator beginTagReportData(void)
Returns the first element of the TagReportData sub-parameter list.
Definition: ltkcpp.h:6187
const CFieldDescriptor * m_pRefField
If non-NULL this is the field descriptors for the errored field.
Definition: ltkcpp_base.h:641
void setEnableFirstSeenTimestamp(llrp_u1_t value)
Set accessor functions for the LLRP EnableFirstSeenTimestamp field.
Definition: ltkcpp.h:14003
Class Definition CAISpec for LLRP parameter AISpec.
Definition: ltkcpp.h:10245
void setEnablePeakRSSI(llrp_u1_t value)
Set accessor functions for the LLRP EnablePeakRSSI field.
Definition: ltkcpp.h:13977
Class Definition CC1G2Filter for LLRP parameter C1G2Filter.
Definition: ltkcpp.h:20217
void setPriority(llrp_u8_t value)
Set accessor functions for the LLRP Priority field.
Definition: ltkcpp.h:9401
void usage(char *pProgName)
Print usage message and exit.
Definition: example1.cpp:247
const CTypeDescriptor * m_pRefType
If non-NULL this is the type descriptors for the errored type.
Definition: ltkcpp_base.h:639
Class Definition CInventoryParameterSpec for LLRP parameter InventoryParameterSpec.
Definition: ltkcpp.h:10807
EResultCode m_eResultCode
Result code from operation.
Definition: ltkcpp_base.h:635
Class for LLRP basic type u96 (96-bit value)
Definition: ltkcpp_base.h:566
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
Definition: ltkcpp.h:5847
void setEnableAccessSpecID(llrp_u1_t value)
Set accessor functions for the LLRP EnableAccessSpecID field.
Definition: ltkcpp.h:14081
Class Definition CSTOP_ROSPEC for LLRP message STOP_ROSPEC.
Definition: ltkcpp.h:2864
llrp_u96_t getEPC(void)
Get accessor functions for the LLRP EPC field.
Definition: ltkcpp.h:14952
Class Definition CSTART_ROSPEC for LLRP message START_ROSPEC.
Definition: ltkcpp.h:2674
void setCurrentState(EROSpecState value)
Set accessor functions for the LLRP CurrentState field.
Definition: ltkcpp.h:9427
EStatusCode getStatusCode(void)
Get accessor functions for the LLRP StatusCode field.
Definition: ltkcpp.h:18940
const char * m_pWhatStr
Descriptive printable error string.
Definition: ltkcpp_base.h:637
EResultCode toXMLString(char *pBuffer, int nBuffer)
A wrapper around LLRP::toXMLString()
CReaderEventNotificationData * getReaderEventNotificationData(void)
Get accessor functions for the LLRP ReaderEventNotificationData sub-parameter.
Definition: ltkcpp.h:6517
Class Definition CROSpecStartTrigger for LLRP parameter ROSpecStartTrigger.
Definition: ltkcpp.h:9648
void setTransmitPower(llrp_u16_t value)
Set accessor functions for the LLRP TransmitPower field.
Definition: ltkcpp.h:13285
Class Definition CEPC_96 for LLRP parameter EPC_96.
Definition: ltkcpp.h:14901
void setEnableChannelIndex(llrp_u1_t value)
Set accessor functions for the LLRP EnableChannelIndex field.
Definition: ltkcpp.h:13951
Class Definition CENABLE_ROSPEC_RESPONSE for LLRP message ENABLE_ROSPEC_RESPONSE. ...
Definition: ltkcpp.h:3152
Class Definition CROReportSpec for LLRP parameter ROReportSpec.
Definition: ltkcpp.h:13599
Class Definition CRO_ACCESS_REPORT for LLRP message RO_ACCESS_REPORT.
Definition: ltkcpp.h:6142
llrp_u16_t m_nValue
The number of arrray elements.
Definition: ltkcpp_base.h:484
int closeConnectionToReader(void)
Close connection to reader, allow reuse of instance.
EConnectionAttemptStatusType getStatus(void)
Get accessor functions for the LLRP Status field.
Definition: ltkcpp.h:18764
void setEnableROSpecID(llrp_u1_t value)
Set accessor functions for the LLRP EnableROSpecID field.
Definition: ltkcpp.h:13847
A collection of pointers to CTypeDescriptors.
Definition: ltkcpp_base.h:885
Class Definition CREADER_EVENT_NOTIFICATION for LLRP message READER_EVENT_NOTIFICATION.
Definition: ltkcpp.h:6472
llrp_u16_t getAntennaID(void)
Get accessor functions for the LLRP AntennaID field.
Definition: ltkcpp.h:18666
const CErrorDetails * getTransactError(void)
Get the details that explains transact() error.
void setAntennaID(llrp_u16_t value)
Set accessor functions for the LLRP AntennaID field.
Definition: ltkcpp.h:12963
void setTagMask(llrp_u1v_t value)
Set accessor functions for the LLRP TagMask field.
Definition: ltkcpp.h:20472
void setTarget(EC1G2StateAwareTarget value)
Set accessor functions for the LLRP Target field.
Definition: ltkcpp.h:20590
Class Definition CConnectionAttemptEvent for LLRP parameter ConnectionAttemptEvent.
Definition: ltkcpp.h:18713
Class Definition CSTART_ROSPEC_RESPONSE for LLRP message START_ROSPEC_RESPONSE.
Definition: ltkcpp.h:2772
Class Definition CReaderEventNotificationData for LLRP parameter ReaderEventNotificationData.
Definition: ltkcpp.h:17017
void setROSpecID(llrp_u32_t value)
Set accessor functions for the LLRP ROSpecID field.
Definition: ltkcpp.h:2732
Class Definition CADD_ROSPEC for LLRP message ADD_ROSPEC.
Definition: ltkcpp.h:2303
void setResetToFactoryDefault(llrp_u1_t value)
Set accessor functions for the LLRP ResetToFactoryDefault field.
Definition: ltkcpp.h:5487
CMessage * recvMessage(int nMaxMS)
Receive a message from a connection.
Class Definition CTagReportContentSelector for LLRP parameter TagReportContentSelector.
Definition: ltkcpp.h:13789
Class Definition CADD_ROSPEC_RESPONSE for LLRP message ADD_ROSPEC_RESPONSE.
Definition: ltkcpp.h:2392
File that includes all Impinj Custom extension classes and types.
void setROReportTrigger(EROReportTriggerType value)
Set accessor functions for the LLRP ROReportTrigger field.
Definition: ltkcpp.h:13657
void setDurationTriggerValue(llrp_u32_t value)
Set accessor functions for the LLRP DurationTriggerValue field.
Definition: ltkcpp.h:10185
llrp_utf8v_t getErrorDescription(void)
Get accessor functions for the LLRP ErrorDescription field.
Definition: ltkcpp.h:18966
EResultCode setROSpec(CROSpec *pValue)
Set accessor functions for the LLRP ROSpec sub-parameter.
CMessage * transact(CMessage *pSendMessage, int nMaxMS)
Transact a LLRP request and response to a connection.
EResultCode addAntennaConfiguration(CAntennaConfiguration *pValue)
Add a AntennaConfiguration to the LLRP sub-parameter list.
Class Definition CAntennaEvent for LLRP parameter AntennaEvent.
Definition: ltkcpp.h:18589
const CErrorDetails * getRecvError(void)
Get the details that explains recvMessage() or recvResponse() error.
Class for LLRP basic type utf8v (vector of utf-8 encoded characters)
Definition: ltkcpp_base.h:480
llrp_u16_t m_nBit
The number of arrray elements.
Definition: ltkcpp_base.h:441
EResultCode setC1G2SingulationControl(CC1G2SingulationControl *pValue)
Set accessor functions for the LLRP C1G2SingulationControl sub-parameter.
Class for LLRP basic type u1v (vector of unsigned 1-bit values)
Definition: ltkcpp_base.h:437
Class Definition CENABLE_ROSPEC for LLRP message ENABLE_ROSPEC.
Definition: ltkcpp.h:3054
int openConnectionToReader(const char *pReaderHostName)
Open a connection to the reader over an unencrypted socket.
void setProtocolID(EAirProtocols value)
Set accessor functions for the LLRP ProtocolID field.
Definition: ltkcpp.h:10891
void setHopTableID(llrp_u16_t value)
Set accessor functions for the LLRP HopTableID field.
Definition: ltkcpp.h:13233
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
Definition: ltkcpp.h:3007
EResultCode addSpecParameter(CParameter *pValue)
Add a SpecParameter to the LLRP sub-parameter list.
Class Definition CLLRPStatus for LLRP parameter LLRPStatus.
Definition: ltkcpp.h:18889
void setEnableSpecIndex(llrp_u1_t value)
Set accessor functions for the LLRP EnableSpecIndex field.
Definition: ltkcpp.h:13873
const CTypeDescriptor * m_pResponseType
For messages (bIsMessage==TRUE), this is the type descriptor for the corresponding response...
Definition: ltkcpp_base.h:776
EResultCode addAirProtocolInventoryCommandSettings(CParameter *pValue)
Add a AirProtocolInventoryCommandSettings to the LLRP sub-parameter list.
Class Definition CC1G2SingulationControl for LLRP parameter C1G2SingulationControl.
Definition: ltkcpp.h:20948
Class Definition CSTOP_ROSPEC_RESPONSE for LLRP message STOP_ROSPEC_RESPONSE.
Definition: ltkcpp.h:2962
void setROSpecID(llrp_u32_t value)
Set accessor functions for the LLRP ROSpecID field.
Definition: ltkcpp.h:3112
CReaderExceptionEvent * getReaderExceptionEvent(void)
Get accessor functions for the LLRP ReaderExceptionEvent sub-parameter.
Definition: ltkcpp.h:17164
void setN(llrp_u16_t value)
Set accessor functions for the LLRP N field.
Definition: ltkcpp.h:13683
EResultCode sendMessage(CMessage *pMessage)
Send a LLRP message to a connection.
CParameter * getEPCParameter(void)
Get accessor functions for the LLRP EPCParameter sub-parameter.
Definition: ltkcpp.h:14441
Class to return error details in LTKCPP operations.
Definition: ltkcpp_base.h:631
Class Definition CC1G2TagInventoryMask for LLRP parameter C1G2TagInventoryMask.
Definition: ltkcpp.h:20362
Class Definition CROSpec for LLRP parameter ROSpec.
Definition: ltkcpp.h:9317
void setMB(llrp_u2_t value)
Set accessor functions for the LLRP MB field.
Definition: ltkcpp.h:20420
EResultCode setROBoundarySpec(CROBoundarySpec *pValue)
Set accessor functions for the LLRP ROBoundarySpec sub-parameter.
char * m_pName
String name of parameter/message type (e.g. "ROSpec")
Definition: ltkcpp_base.h:762
Class Definition CC1G2InventoryCommand for LLRP parameter C1G2InventoryCommand.
Definition: ltkcpp.h:19981
File that includes all LLRP classes and types.
Class Definition CEPCData for LLRP parameter EPCData.
Definition: ltkcpp.h:14803
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
Definition: ltkcpp.h:3197
Class Definition CSET_READER_CONFIG for LLRP message SET_READER_CONFIG.
Definition: ltkcpp.h:5429
void setEnableAntennaID(llrp_u1_t value)
Set accessor functions for the LLRP EnableAntennaID field.
Definition: ltkcpp.h:13925
void setTagInventoryStateAware(llrp_u1_t value)
Set accessor functions for the LLRP TagInventoryStateAware field.
Definition: ltkcpp.h:20039
void setSession(llrp_u2_t value)
Set accessor functions for the LLRP Session field.
Definition: ltkcpp.h:21006
void setROSpecStopTriggerType(EROSpecStopTriggerType value)
Set accessor functions for the LLRP ROSpecStopTriggerType field.
Definition: ltkcpp.h:10159
llrp_u1v_t getEPC(void)
Get accessor functions for the LLRP EPC field.
Definition: ltkcpp.h:14854
llrp_u16_t * m_pValue
Pointer to the first array element.
Definition: ltkcpp_base.h:185
EResultCode setRFTransmitter(CRFTransmitter *pValue)
Set accessor functions for the LLRP RFTransmitter sub-parameter.
EResultCode setROSpecStopTrigger(CROSpecStopTrigger *pValue)
Set accessor functions for the LLRP ROSpecStopTrigger sub-parameter.
llrp_u8_t m_aValue[12]
Simple array of basic type llrp_u8_t.
Definition: ltkcpp_base.h:570
void setInventoryParameterSpecID(llrp_u16_t value)
Set accessor functions for the LLRP InventoryParameterSpecID field.
Definition: ltkcpp.h:10865
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
Definition: ltkcpp.h:2817
Base Class for All LLRP LTK Parameters.
Definition: ltkcpp_base.h:1125
Base Class for All LLRP LTK Messages.
Definition: ltkcpp_base.h:1088
EResultCode setC1G2TagInventoryMask(CC1G2TagInventoryMask *pValue)
Set accessor functions for the LLRP C1G2TagInventoryMask sub-parameter.
EResultCode setROSpecStartTrigger(CROSpecStartTrigger *pValue)
Set accessor functions for the LLRP ROSpecStartTrigger sub-parameter.
Class Definition CIMPINJ_ENABLE_EXTENSIONS_RESPONSE for LLRP message IMPINJ_ENABLE_EXTENSIONS_RESPONS...
std::list< CTagReportData * >::iterator endTagReportData(void)
Returns the last element of the TagReportData sub-parameter list.
Definition: ltkcpp.h:6194
llrp_utf8v_t getMessage(void)
Get accessor functions for the LLRP Message field.
Definition: ltkcpp.h:17979
const char * getConnectError(void)
Get the string that explains openReaderConnection() error.
void setTagTransitTime(llrp_u32_t value)
Set accessor functions for the LLRP TagTransitTime field.
Definition: ltkcpp.h:21058
Class Definition CSET_READER_CONFIG_RESPONSE for LLRP message SET_READER_CONFIG_RESPONSE.
Definition: ltkcpp.h:5802
Class Definition CIMPINJ_ENABLE_EXTENSIONS for LLRP message IMPINJ_ENABLE_EXTENSIONS.
Class Definition CReaderExceptionEvent for LLRP parameter ReaderExceptionEvent.
Definition: ltkcpp.h:17928
CAntennaEvent * getAntennaEvent(void)
Get accessor functions for the LLRP AntennaEvent sub-parameter.
Definition: ltkcpp.h:17215
void setEnableLastSeenTimestamp(llrp_u1_t value)
Set accessor functions for the LLRP EnableLastSeenTimestamp field.
Definition: ltkcpp.h:14029
void setEnableTagSeenCount(llrp_u1_t value)
Set accessor functions for the LLRP EnableTagSeenCount field.
Definition: ltkcpp.h:14055
void setROSpecID(llrp_u32_t value)
Set accessor functions for the LLRP ROSpecID field.
Definition: ltkcpp.h:9375
Class Definition CTagReportData for LLRP parameter TagReportData.
Definition: ltkcpp.h:14396
void setMessageID(llrp_u32_t MessageID)
Sets the LLRP Message ID for the Message.
Definition: ltkcpp_base.h:1097
void setAISpecStopTriggerType(EAISpecStopTriggerType value)
Set accessor functions for the LLRP AISpecStopTriggerType field.
Definition: ltkcpp.h:10497
void setS(EC1G2TagInventoryStateAwareS value)
Set accessor functions for the LLRP S field.
Definition: ltkcpp.h:21201
Class Definition CAISpecStopTrigger for LLRP parameter AISpecStopTrigger.
Definition: ltkcpp.h:10439
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
Class Definition CC1G2TagInventoryStateAwareSingulationAction for LLRP parameter C1G2TagInventoryStat...
Definition: ltkcpp.h:21117
void setI(EC1G2TagInventoryStateAwareI value)
Set accessor functions for the LLRP I field.
Definition: ltkcpp.h:21175
void setPointer(llrp_u16_t value)
Set accessor functions for the LLRP Pointer field.
Definition: ltkcpp.h:20446
EResultCode addInventoryParameterSpec(CInventoryParameterSpec *pValue)
Add a InventoryParameterSpec to the LLRP sub-parameter list.
void setTagPopulation(llrp_u16_t value)
Set accessor functions for the LLRP TagPopulation field.
Definition: ltkcpp.h:21032
LLRP connection class.
int main(int ac, char *av[])
Command main routine.
Definition: example1.cpp:165
Class Definition CRFTransmitter for LLRP parameter RFTransmitter.
Definition: ltkcpp.h:13175
EAntennaEventType
Global enumeration EAntennaEventType for LLRP enumerated field AntennaEventType.
Definition: ltkcpp.h:1041
EResultCode setROReportSpec(CROReportSpec *pValue)
Set accessor functions for the LLRP ROReportSpec sub-parameter.
void setEnableInventoryParameterSpecID(llrp_u1_t value)
Set accessor functions for the LLRP EnableInventoryParameterSpecID field.
Definition: ltkcpp.h:13899
CConnectionAttemptEvent * getConnectionAttemptEvent(void)
Get accessor functions for the LLRP ConnectionAttemptEvent sub-parameter.
Definition: ltkcpp.h:17232
llrp_utf8_t * m_pValue
Pointer to the first array element.
Definition: ltkcpp_base.h:486
void setT(EC1G2TruncateAction value)
Set accessor functions for the LLRP T field.
Definition: ltkcpp.h:20275
Class Definition CC1G2TagInventoryStateAwareFilterAction for LLRP parameter C1G2TagInventoryStateAwar...
Definition: ltkcpp.h:20532
EAntennaEventType getEventType(void)
Get accessor functions for the LLRP EventType field.
Definition: ltkcpp.h:18640
EResultCode setAISpecStopTrigger(CAISpecStopTrigger *pValue)
Set accessor functions for the LLRP AISpecStopTrigger sub-parameter.
Describes a message or parameter type.
Definition: ltkcpp_base.h:755
void setROSpecStartTriggerType(EROSpecStartTriggerType value)
Set accessor functions for the LLRP ROSpecStartTriggerType field.
Definition: ltkcpp.h:9706
Class Definition CROSpecStopTrigger for LLRP parameter ROSpecStopTrigger.
Definition: ltkcpp.h:10101
const CErrorDetails * getSendError(void)
Get the details that explains sendMessage() error.
EResultCode setC1G2TagInventoryStateAwareFilterAction(CC1G2TagInventoryStateAwareFilterAction *pValue)
Set accessor functions for the LLRP C1G2TagInventoryStateAwareFilterAction sub-parameter.
EResultCode setC1G2TagInventoryStateAwareSingulationAction(CC1G2TagInventoryStateAwareSingulationAction *pValue)
Set accessor functions for the LLRP C1G2TagInventoryStateAwareSingulationAction sub-parameter.