C/C++ Question How to handle a pointer to a Byte

kolbe

Active Member
Licensed User
I'm trying to wrap a pn532 library and not sure how to handle a pointer to a byte. This method is suppose to provide the uid length when called so it needs to stay a pointer.

The original library method is the following.

B4X:
bool readPassiveTargetID(uint8_t cardbaudrate, uint8_t * uid, uint8_t * uidLength, uint16_t timeout);
I call this from the wrapper.

B4X:
    bool B4RPN532::readPassiveTargetID(byte cardbaudrate, ArrayByte* uid, byte &uidLength, UInt timeout) {
        return pn->readPassiveTargetID(cardbaudrate,(byte*)uid->data,&uidLength,timeout);
    }
The wrapper header declares this.

B4X:
bool readPassiveTargetID(byte cardbaudrate, ArrayByte* uid, byte &uidLength, UInt timeout);
This code actually works but B4Rh2xml.jar doesn't like the reference to uidLength and ignores the variable. If i remove the reference, run B4Rh2xml.jar and then put it back the code work like it is intended.

What is the correct way of doing this?

I guess I could just change it to an ArrayByte* but was hoping for something simpler.
 
Top