jlcout / epctagcoder

Java library for RFID EPC encode / decode
https://jlcout.github.io/epctagcoder
Apache License 2.0
51 stars 31 forks source link

Some missing source files in the project and other compile issues #13

Closed prlwtz closed 3 years ago

prlwtz commented 3 years ago

The readme claims support for SGCN - Serialized Global Coupon Number but these classes seem missing from the source (0.0.8) ?

Also, when recompiling the source, it seems missing the EPCParseException exception class. I created the following locally. I don't know if there was more to it?

package org.epctagcoder.exception;

public class EPCParseException extends Exception {
    String _message;

    public EPCParseException(String message) {
        _message = message;
    }

    public String Message() {
        return _message;
    }
}

Also, there were a few compile issues due to the lack of some "throws Exception" declarations at some parse/Builder declarations.

jlcout commented 3 years ago

Hello prlwtz!

I fixed the compilation problem. Please test and report.

Soon, I will study the SGCN specification and implement it

prlwtz commented 3 years ago

Hi José,

I replaced the whole 'org' source folder in my project and it compiled without any issues. Thanks.

With regards to SGCN, I don't have an immediate need for it at the moment, I just noticed the missing APIs while implementing the library into my RFID parser.

With regards to that parsing, I now have an iterating loop trying parse through the various objects.


private enum EPC {
        SGTIN,
        SSCC,
        SGLN,
        GRAI,
        GIAI,
        GSRN,
        GSRNP,
        GDTI,
        CPI
    };

    String data = "";
    for (int i = 0 ; i<EPC.values().length && data.length()==0 ; i++) {
                            EPC epc = EPC.values()[i];

                            switch (epc) {

                                case SGTIN:
                                    // SGTIN - Serialized Global Trade Item Number
                                    // urn:epc:id:sgtin:CompanyPrefix.ItemRefAndIndicator.SerialNumber
                                    try {
                                        ParseSGTIN parseSGTIN = ParseSGTIN.Builder().withRFIDTag(hex_data).build();
                                        SGTIN sgtin = parseSGTIN.getSGTIN();
                                        data = sgtin.getEpcPureIdentityURI();
                                    } catch (Exception parse_e) {
                                    }
                                    break;

                                case SSCC:
                                    // SSCC - Serial Shipping Container Code
                                    // urn:epc:id:sscc:CompanyPrefix.SerialReference
                                    try {
                                        ParseSSCC parseSSCC = ParseSSCC.Builder().withRFIDTag(hex_data).build();
                                        SSCC sscc = parseSSCC.getSSCC();
                                        data = sscc.getEpcPureIdentityURI();
                                    } catch (Exception parse_e) {
                                    }
                                    break;

etc etc

Is there an better way of simply parsing the hex data and just get an object with the appropriate contents? Or is this just the way it currently is?

Kind regards, Eize

jlcout commented 3 years ago

I'm glad it worked.

There is no other way to parse hexadecimal data. Each class is specific to resolve certain hexadecimal. Your loop is perfect and I don't see any other way.