57 #define snprintf _snprintf
62 unsigned int m_messageID;
73 : m_Verbose(0), m_pConnectionToReader(NULL)
80 char * pReaderHostName);
83 checkConnectionStatus (
void);
86 enableImpinjExtensions (
void);
89 resetConfigurationToFactoryDefaults (
void);
104 awaitAndPrintReport (
int timeoutSec);
111 printOneTagReportData (
121 handleReaderEventNotification (
129 handleReaderExceptionEvent (
187 CMyApplication myApp;
188 char * pReaderHostName;
197 pReaderHostName = av[1];
223 pReaderHostName = av[2];
234 rc = myApp.run(pReaderHostName);
236 printf(
"INFO: Done\n");
269 printf(
"Usage: %s [-v[v]] READERHOSTNAME\n", pProgName);
271 printf(
"Each -v increases verbosity level\n");
274 printf(
"Usage: %s [/v[v]] READERHOSTNAME\n", pProgName);
276 printf(
"Each /v increases verbosity level\n");
316 CMyApplication::run (
317 char * pReaderHostName)
327 pTypeRegistry = getTheTypeRegistry();
328 if(NULL == pTypeRegistry)
330 printf(
"ERROR: getTheTypeRegistry failed\n");
350 printf(
"ERROR: new CConnection failed\n");
359 printf(
"INFO: Connecting to %s....\n", pReaderHostName);
374 m_pConnectionToReader = pConn;
378 printf(
"INFO: Connected, checking status....\n");
387 if(0 == checkConnectionStatus())
390 if(0 == enableImpinjExtensions())
393 if(0 == resetConfigurationToFactoryDefaults())
399 if(0 == enableROSpec())
402 if(0 == startROSpec())
405 if(0 == awaitAndPrintReport(10))
408 if(0 == stopROSpec())
425 printf(
"INFO: Clean up reader configuration...\n");
427 resetConfigurationToFactoryDefaults();
433 printf(
"INFO: Finished\n");
445 delete pTypeRegistry;
486 CMyApplication::checkConnectionStatus (
void)
497 pMessage = recvMessage(10000);
513 if(&CREADER_EVENT_NOTIFICATION::s_typeDescriptor != pMessage->
m_pType)
554 printf(
"INFO: Connection status OK\n");
566 printf(
"ERROR: checkConnectionStatus failed\n");
589 CMyApplication::enableImpinjExtensions (
void)
603 pRspMsg = transact(pCmd);
628 "enableImpinjExtensions"))
645 printf(
"INFO: Impinj Extensions are enabled\n");
675 CMyApplication::resetConfigurationToFactoryDefaults (
void)
691 pRspMsg = transact(pCmd);
716 "resetConfigurationToFactoryDefaults"))
733 printf(
"INFO: Configuration reset to factory defaults\n");
791 CMyApplication::addROSpec (
void)
849 pRspMsg = transact(pCmd);
891 printf(
"INFO: ROSpec added\n");
919 CMyApplication::enableROSpec (
void)
935 pRspMsg = transact(pCmd);
959 if(0 != checkLLRPStatus(pRsp->
getLLRPStatus(),
"enableROSpec"))
976 printf(
"INFO: ROSpec enabled\n");
1004 CMyApplication::startROSpec (
void)
1020 pRspMsg = transact(pCmd);
1044 if(0 != checkLLRPStatus(pRsp->
getLLRPStatus(),
"startROSpec"))
1061 printf(
"INFO: ROSpec started\n");
1088 CMyApplication::stopROSpec (
void)
1104 pRspMsg = transact(pCmd);
1128 if(0 != checkLLRPStatus(pRsp->
getLLRPStatus(),
"stopROSpec"))
1145 printf(
"INFO: ROSpec stopped\n");
1175 CMyApplication::awaitAndPrintReport (
int timeout)
1179 time_t startTime = time(NULL);
1195 pMessage = recvMessage(1000);
1198 tempTime = time(NULL);
1199 if(difftime(tempTime, startTime) > timeout)
1204 if(NULL == pMessage)
1219 if(&CRO_ACCESS_REPORT::s_typeDescriptor == pType)
1225 printTagReportData(pNtf);
1232 else if(&CREADER_EVENT_NOTIFICATION::s_typeDescriptor == pType)
1240 if(NULL != pNtfData)
1242 handleReaderEventNotification(pNtfData);
1250 printf(
"WARNING: READER_EVENT_NOTIFICATION without data\n");
1259 printf(
"WARNING: Ignored unexpected message during monitor: %s\n",
1288 CMyApplication::printTagReportData (
1291 std::list<CTagReportData *>::iterator Cur;
1293 unsigned int nEntry = 0;
1308 printf(
"INFO: %u tag report entries\n", nEntry);
1319 printOneTagReportData(*Cur);
1333 CMyApplication::formatOneEPC (
1339 int bufsize = buflen;
1342 if(NULL != pEPCParameter)
1347 llrp_u8_t * pValue = NULL;
1350 pType = pEPCParameter->
m_pType;
1351 if(&CEPC_96::s_typeDescriptor == pType)
1355 pEPC_96 = (
CEPC_96 *) pEPCParameter;
1356 my_u96 = pEPC_96->
getEPC();
1360 else if(&CEPCData::s_typeDescriptor == pType)
1364 pEPCData = (
CEPCData *) pEPCParameter;
1365 my_u1v = pEPCData->
getEPC();
1367 n = (my_u1v.
m_nBit + 7u) / 8u;
1372 for(i = 0; i < n; i++)
1374 if(0 < i && i%2 == 0 && 1 < bufsize)
1381 written = snprintf(p, bufsize,
"%02X", pValue[i]);
1389 written = snprintf(p, bufsize,
"%s",
"---unknown-epc-data-type---");
1396 written = snprintf(p, bufsize,
"%s",
"--null epc---");
1402 buf[buflen-1] =
'\0';
1415 CMyApplication::printOneTagReportData (
1428 formatOneEPC(pEPCParameter, aBuf, 64);
1433 printf(
"EPC: %s\n", aBuf);
1451 CMyApplication::handleReaderEventNotification (
1459 if(NULL != pAntennaEvent)
1461 handleAntennaEvent(pAntennaEvent);
1466 if(NULL != pReaderExceptionEvent)
1468 handleReaderExceptionEvent(pReaderExceptionEvent);
1488 printf(
"NOTICE: Unexpected (unhandled) ReaderEvent\n");
1505 CMyApplication::handleAntennaEvent (
1509 llrp_u16_t AntennaID;
1518 pStateStr =
"disconnected";
1522 pStateStr =
"connected";
1526 pStateStr =
"?unknown-event?";
1530 printf(
"NOTICE: Antenna %d is %s\n", AntennaID, pStateStr);
1547 CMyApplication::handleReaderExceptionEvent (
1552 Message = pReaderExceptionEvent->
getMessage();
1556 printf(
"NOTICE: ReaderException '%.*s'\n",
1561 printf(
"NOTICE: ReaderException but no message\n");
1585 CMyApplication::checkLLRPStatus (
1595 if(NULL == pLLRPStatus)
1597 printf(
"ERROR: %s missing LLRP status\n", pWhatStr);
1616 printf(
"ERROR: %s failed, no error description given\n",
1621 printf(
"ERROR: %s failed, %.*s\n",
1658 CMyApplication::transact (
1670 printf(
"\n===================================\n");
1671 printf(
"INFO: Transact sending\n");
1672 printXMLMessage(pSendMsg);
1680 pRspMsg = pConn->
transact(pSendMsg, 5000);
1686 printf(
"ERROR: %s transact failed, %s\n",
1692 printf(
"ERROR: ... reference type %s\n",
1698 printf(
"ERROR: ... reference field %s\n",
1711 printf(
"\n- - - - - - - - - - - - - - - - - -\n");
1712 printf(
"INFO: Transact received response\n");
1713 printXMLMessage(pRspMsg);
1721 if(&CERROR_MESSAGE::s_typeDescriptor == pRspMsg->
m_pType)
1727 printf(
"ERROR: Received ERROR_MESSAGE instead of %s\n",
1762 CMyApplication::recvMessage (
1777 if(NULL == pMessage)
1784 printf(
"ERROR: recvMessage failed, %s\n",
1790 printf(
"ERROR: ... reference type %s\n",
1796 printf(
"ERROR: ... reference field %s\n",
1809 printf(
"\n===================================\n");
1810 printf(
"INFO: Message received\n");
1811 printXMLMessage(pMessage);
1836 CMyApplication::sendMessage (
1847 printf(
"\n===================================\n");
1848 printf(
"INFO: Sending\n");
1849 printXMLMessage(pSendMsg);
1861 printf(
"ERROR: %s sendMessage failed, %s\n",
1867 printf(
"ERROR: ... reference type %s\n",
1873 printf(
"ERROR: ... reference field %s\n",
1901 CMyApplication::printXMLMessage (
1904 char aBuf[100*1024];
Class Definition CROBoundarySpec for LLRP parameter ROBoundarySpec.
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.
char * m_pName
String name of field (e.g. "ROSpecID")
void setAntennaIDs(llrp_u16v_t value)
Set accessor functions for the LLRP AntennaIDs field.
const CTypeDescriptor * m_pType
The type descriptor desribing this element.
void setROSpecID(llrp_u32_t value)
Set accessor functions for the LLRP ROSpecID field.
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
llrp_u8_t * m_pValue
Pointer to the first array element.
Class for LLRP basic type u16v (List of unsigned 16-bit values)
std::list< CTagReportData * >::iterator beginTagReportData(void)
Returns the first element of the TagReportData sub-parameter list.
const CFieldDescriptor * m_pRefField
If non-NULL this is the field descriptors for the errored field.
Class Definition CAISpec for LLRP parameter AISpec.
void setPriority(llrp_u8_t value)
Set accessor functions for the LLRP Priority field.
void usage(char *pProgName)
Print usage message and exit.
const CTypeDescriptor * m_pRefType
If non-NULL this is the type descriptors for the errored type.
Class Definition CInventoryParameterSpec for LLRP parameter InventoryParameterSpec.
EResultCode m_eResultCode
Result code from operation.
Class for LLRP basic type u96 (96-bit value)
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
Class Definition CSTOP_ROSPEC for LLRP message STOP_ROSPEC.
llrp_u96_t getEPC(void)
Get accessor functions for the LLRP EPC field.
Class Definition CSTART_ROSPEC for LLRP message START_ROSPEC.
void setCurrentState(EROSpecState value)
Set accessor functions for the LLRP CurrentState field.
EStatusCode getStatusCode(void)
Get accessor functions for the LLRP StatusCode field.
const char * m_pWhatStr
Descriptive printable error string.
EResultCode toXMLString(char *pBuffer, int nBuffer)
A wrapper around LLRP::toXMLString()
CReaderEventNotificationData * getReaderEventNotificationData(void)
Get accessor functions for the LLRP ReaderEventNotificationData sub-parameter.
Class Definition CROSpecStartTrigger for LLRP parameter ROSpecStartTrigger.
Class Definition CEPC_96 for LLRP parameter EPC_96.
Class Definition CENABLE_ROSPEC_RESPONSE for LLRP message ENABLE_ROSPEC_RESPONSE. ...
Class Definition CRO_ACCESS_REPORT for LLRP message RO_ACCESS_REPORT.
llrp_u16_t m_nValue
The number of arrray elements.
int closeConnectionToReader(void)
Close connection to reader, allow reuse of instance.
EConnectionAttemptStatusType getStatus(void)
Get accessor functions for the LLRP Status field.
A collection of pointers to CTypeDescriptors.
Class Definition CREADER_EVENT_NOTIFICATION for LLRP message READER_EVENT_NOTIFICATION.
llrp_u16_t getAntennaID(void)
Get accessor functions for the LLRP AntennaID field.
const CErrorDetails * getTransactError(void)
Get the details that explains transact() error.
Class Definition CConnectionAttemptEvent for LLRP parameter ConnectionAttemptEvent.
Class Definition CSTART_ROSPEC_RESPONSE for LLRP message START_ROSPEC_RESPONSE.
Class Definition CReaderEventNotificationData for LLRP parameter ReaderEventNotificationData.
void setROSpecID(llrp_u32_t value)
Set accessor functions for the LLRP ROSpecID field.
Class Definition CADD_ROSPEC for LLRP message ADD_ROSPEC.
void setResetToFactoryDefault(llrp_u1_t value)
Set accessor functions for the LLRP ResetToFactoryDefault field.
CMessage * recvMessage(int nMaxMS)
Receive a message from a connection.
Class Definition CADD_ROSPEC_RESPONSE for LLRP message ADD_ROSPEC_RESPONSE.
File that includes all Impinj Custom extension classes and types.
void setDurationTriggerValue(llrp_u32_t value)
Set accessor functions for the LLRP DurationTriggerValue field.
llrp_utf8v_t getErrorDescription(void)
Get accessor functions for the LLRP ErrorDescription field.
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.
Class Definition CAntennaEvent for LLRP parameter AntennaEvent.
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)
llrp_u16_t m_nBit
The number of arrray elements.
Class for LLRP basic type u1v (vector of unsigned 1-bit values)
Class Definition CENABLE_ROSPEC for LLRP message ENABLE_ROSPEC.
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.
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
EResultCode addSpecParameter(CParameter *pValue)
Add a SpecParameter to the LLRP sub-parameter list.
Class Definition CLLRPStatus for LLRP parameter LLRPStatus.
const CTypeDescriptor * m_pResponseType
For messages (bIsMessage==TRUE), this is the type descriptor for the corresponding response...
Class Definition CSTOP_ROSPEC_RESPONSE for LLRP message STOP_ROSPEC_RESPONSE.
void setROSpecID(llrp_u32_t value)
Set accessor functions for the LLRP ROSpecID field.
CReaderExceptionEvent * getReaderExceptionEvent(void)
Get accessor functions for the LLRP ReaderExceptionEvent sub-parameter.
EResultCode sendMessage(CMessage *pMessage)
Send a LLRP message to a connection.
CParameter * getEPCParameter(void)
Get accessor functions for the LLRP EPCParameter sub-parameter.
Class to return error details in LTKCPP operations.
Class Definition CROSpec for LLRP parameter ROSpec.
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")
File that includes all LLRP classes and types.
Class Definition CEPCData for LLRP parameter EPCData.
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
Class Definition CSET_READER_CONFIG for LLRP message SET_READER_CONFIG.
void setROSpecStopTriggerType(EROSpecStopTriggerType value)
Set accessor functions for the LLRP ROSpecStopTriggerType field.
llrp_u1v_t getEPC(void)
Get accessor functions for the LLRP EPC field.
llrp_u16_t * m_pValue
Pointer to the first array element.
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.
void setInventoryParameterSpecID(llrp_u16_t value)
Set accessor functions for the LLRP InventoryParameterSpecID field.
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
Base Class for All LLRP LTK Parameters.
Base Class for All LLRP LTK Messages.
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.
llrp_utf8v_t getMessage(void)
Get accessor functions for the LLRP Message field.
const char * getConnectError(void)
Get the string that explains openReaderConnection() error.
Class Definition CSET_READER_CONFIG_RESPONSE for LLRP message SET_READER_CONFIG_RESPONSE.
Class Definition CIMPINJ_ENABLE_EXTENSIONS for LLRP message IMPINJ_ENABLE_EXTENSIONS.
Class Definition CReaderExceptionEvent for LLRP parameter ReaderExceptionEvent.
CAntennaEvent * getAntennaEvent(void)
Get accessor functions for the LLRP AntennaEvent sub-parameter.
void setROSpecID(llrp_u32_t value)
Set accessor functions for the LLRP ROSpecID field.
Class Definition CTagReportData for LLRP parameter TagReportData.
void setMessageID(llrp_u32_t MessageID)
Sets the LLRP Message ID for the Message.
void setAISpecStopTriggerType(EAISpecStopTriggerType value)
Set accessor functions for the LLRP AISpecStopTriggerType field.
Class Definition CAISpecStopTrigger for LLRP parameter AISpecStopTrigger.
CLLRPStatus * getLLRPStatus(void)
Get accessor functions for the LLRP LLRPStatus sub-parameter.
EResultCode addInventoryParameterSpec(CInventoryParameterSpec *pValue)
Add a InventoryParameterSpec to the LLRP sub-parameter list.
int main(int ac, char *av[])
Command main routine.
EAntennaEventType
Global enumeration EAntennaEventType for LLRP enumerated field AntennaEventType.
CConnectionAttemptEvent * getConnectionAttemptEvent(void)
Get accessor functions for the LLRP ConnectionAttemptEvent sub-parameter.
llrp_utf8_t * m_pValue
Pointer to the first array element.
EAntennaEventType getEventType(void)
Get accessor functions for the LLRP EventType field.
EResultCode setAISpecStopTrigger(CAISpecStopTrigger *pValue)
Set accessor functions for the LLRP AISpecStopTrigger sub-parameter.
Describes a message or parameter type.
void setROSpecStartTriggerType(EROSpecStartTriggerType value)
Set accessor functions for the LLRP ROSpecStartTriggerType field.
Class Definition CROSpecStopTrigger for LLRP parameter ROSpecStopTrigger.
const CErrorDetails * getSendError(void)
Get the details that explains sendMessage() error.