Closed mak3rm1k3 closed 4 years ago
Hi! Good find. I think the issue is that I didn't add pack_into into the Blinka bleio library here: https://github.com/adafruit/Adafruit_Blinka_bleio/blob/master/_bleio.py#L318
Would you mind adding it?
The second error looks like another issue. CPython sanity checks that bytes does as advertised. CircuitPython doesn't check. It should be an easy fix though, makes sure bytes methods return a bytes() of the bytearray.
Mind looking at that too? Sounds like you are setup to test it. I can help if you have any Git/GitHub questions.
Thanks!
Thanks so much for getting back to me on this. I'm pretty green on this level of python (hardware bytes level), so I'd love help adding in pack_into to the Blinka library. What exactly do you need me to add?
def pack_into(self, buffer, offset=0):
"""Packs the UUID into the buffer at the given offset."""
self.bleio_uuid.pack_into(buffer, offset=offset)
Something like this into the UUID class?
I think I understand your second suggestion, to just inspect the type that is returned from a bytes() when assigned to advertisement_bytes? If it doesn't return bytes, though, not sure what exception to use. Any advice?
I really appreciate your help and am very excited to get this going.
Thanks so much for getting back to me on this. I'm pretty green on this level of python (hardware bytes level), so I'd love help adding in pack_into to the Blinka library. What exactly do you need me to add?
Awesome! Thank you! I'm available on our Discord too. Just @tannewt there.
def pack_into(self, buffer, offset=0): """Packs the UUID into the buffer at the given offset.""" self.bleio_uuid.pack_into(buffer, offset=offset)
Something like this into the UUID class?
Yup! Same signature (the def
line) but with code inside that sets the values in the buffer. This is the C version: https://github.com/adafruit/circuitpython/blob/master/ports/nrf/common-hal/_bleio/UUID.c#L70
I think I understand your second suggestion, to just inspect the type that is returned from a bytes() when assigned to advertisement_bytes? If it doesn't return bytes, though, not sure what exception to use. Any advice?
Not quite. You'll want to find the advertisement class and fix it so that it returns bytes. I think you'll want to change the line here to:
return bytes(encode_data(self.data_dict))
I really appreciate your help and am very excited to get this going.
Great! I'm happy to help you fix it and appreciate your willingness to jump in.
I also encountered this issue "AttributeError: 'UUID' object has no attribute 'pack_into'". Can you please advise as to what code needs to be added to the Blinka bleio library?
Thanks!
@makermelissa Any chance you could add pack_into
into Blinka_BLE?
I missed the tag. I just created a new issue at https://github.com/adafruit/Adafruit_Blinka_bleio/issues/10
Ok, closing this in favor of https://github.com/adafruit/Adafruit_Blinka_bleio/issues/10
I'm trying this out for the first time on a rpi zero w, and after installing the library I keep getting an error:
AttributeError: 'UUID' object has no attribute 'pack_into'
Running with Python 3 here is a sample of my code:
Looking more closely the error is in line 63 of uuid/init.py:
any advice?
Edit: Seems like the issue is actually coming from declaring the advertisement with SolicitServicesAdvertisement() because the advertisement is a Nonetype and the radio advertising fails.