kolbe Active Member Licensed User Longtime User May 5, 2019 #1 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. Code: bool readPassiveTargetID(uint8_t cardbaudrate, uint8_t * uid, uint8_t * uidLength, uint16_t timeout); I call this from the wrapper. Code: 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. Code: 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.
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. Code: bool readPassiveTargetID(uint8_t cardbaudrate, uint8_t * uid, uint8_t * uidLength, uint16_t timeout); I call this from the wrapper. Code: 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. Code: 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.
Erel B4X founder Staff member Licensed User Longtime User May 5, 2019 #2 pointer to a byte is an array of bytes. There are many methods that work with arrays of bytes. See rWire.WriteTo header and implementation.
pointer to a byte is an array of bytes. There are many methods that work with arrays of bytes. See rWire.WriteTo header and implementation.