# BLE Argon/Boron/Photon2 as Central Device - packet fragmention loss of 1 character

**URL:** <https://community.particle.io/t/ble-argon-boron-photon2-as-central-device-packet-fragmention-loss-of-1-character/66148>\
**Category:** Device OS\
**Tags:** bluetooth\
**Created:** [January 14, 2024, 4:49pm UTC](https://community.particle.io/t/ble-argon-boron-photon2-as-central-device-packet-fragmention-loss-of-1-character/66148 "2024-01-14T16:49:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tnilsen](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@tnilsen](https://community.particle.io/u/tnilsen)\
**Post date:** [January 14, 2024, 4:49pm UTC](https://community.particle.io/t/ble-argon-boron-photon2-as-central-device-packet-fragmention-loss-of-1-character/66148/1 "2024-01-14T16:49:33Z")

</div>

I'm using (right now) an Argon running OS4.2.0. I'm using it in the BLE Central Role and have connected to a peripheral. I'm polling it for data. The peripheral reports it will send 297 bytes of data via the UUID characteristic. This of course causes packet fragmentation.

I then read the peripheral for data. I get 244 bytes on the first read and by review I see the data is intact. I get 52 bytes on the second read which is 1 byte short of 297. By review, it loses the first byte of the second message. I have verified that using Linux box to effect the same BLE coms.

Are there OS versions that address this?

---

<div class="post-metadata">

**Author:** ![jalbersr](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jalbersr/32/29046_2.png) [@jalbersr](https://community.particle.io/u/jalbersr)\
**Post date:** [January 17, 2024, 7:01pm UTC](https://community.particle.io/t/ble-argon-boron-photon2-as-central-device-packet-fragmention-loss-of-1-character/66148/2 "2024-01-17T19:01:24Z")

</div>

Hi @tnilsen!

Just to clarify, this post is related to this? [Photon2 BLE Fragmented packet loss](https://community.particle.io/t/photon2-ble-fragmented-packet-loss/66137)

---

<div class="post-metadata">

**Author:** ![tnilsen](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@tnilsen](https://community.particle.io/u/tnilsen)\
**Post date:** [January 17, 2024, 7:18pm UTC](https://community.particle.io/t/ble-argon-boron-photon2-as-central-device-packet-fragmention-loss-of-1-character/66148/3 "2024-01-17T19:18:54Z")

</div>

Sorry for confusion. No, these aren't related. This one is real. I have verified it on several OS versions (including 5.6.0, 4.2.0, 4.0.1 and 4.0.2). It drops the first byte on the second packet. Easy to reproduce.

---

<div class="post-metadata">

**Author:** ![tnilsen](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@tnilsen](https://community.particle.io/u/tnilsen)\
**Post date:** [January 24, 2024, 1:18pm UTC](https://community.particle.io/t/ble-argon-boron-photon2-as-central-device-packet-fragmention-loss-of-1-character/66148/4 "2024-01-24T13:18:32Z")

</div>

> **[GitHub - tbnilsen/Particle-BLE-to-Shelly-Switch: Particle IoT chip in BLE...](https://github.com/tbnilsen/Particle-BLE-to-Shelly-Switch)**
>
> Particle IoT chip in BLE Central Mode - Connect to a Shelly switch and operate - GitHub - tbnilsen/Particle-BLE-to-Shelly-Switch: Particle IoT chip in BLE Central Mode - Connect to a Shelly switch ...

Here’s some code for a Shelly Plus 1 PM switch. They’re $22 on Amazon. This demonstrates the loss of a byte on a fragmented message.

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [January 25, 2024, 10:22pm UTC](https://community.particle.io/t/ble-argon-boron-photon2-as-central-device-packet-fragmention-loss-of-1-character/66148/5 "2024-01-25T22:22:36Z")

</div>

Hi @tnilsen

I read through your code and while I don't directly see problem, I do see that you are doing a lot of String operations with substrings based on the found indices of various characters. so my question is:

Can you reproduce this **without** all the String work and just dump the raw data to a log? Maybe even just dump it in hex if you have to. That would make it a lot easier to figure out what in the BLE layers is going wrong.

---

<div class="post-metadata">

**Author:** ![tnilsen](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@tnilsen](https://community.particle.io/u/tnilsen)\
**Post date:** [January 25, 2024, 11:02pm UTC](https://community.particle.io/t/ble-argon-boron-photon2-as-central-device-packet-fragmention-loss-of-1-character/66148/6 "2024-01-25T23:02:54Z")

</div>

Thanks for looking at this. I get what you’re saying - potential memory leaks. The code I placed on GitHub was made much after I found the this issue. I spent time first just getting the BLE exchanges going and that’s when I discovered a byte was being dropped. Fortunately the byte doesn’t contain relevant data for me so I just powered on coding.

Here’s the clue:

 ![IMG_9553](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/7/d/7d5a24bcdf1003f7c6bfd76c3e3bedfb364b9ba8.jpeg)  
The first Log message of 4 bytes long says (for example) that 259 bytes are coming (this is the Shelly device sending that info) and then in the next read Log displays 258 bytes received.  
I compare the rx’ed message byte for byte with a PC running a python program and there is a byte missing and it’s the 245th one in the message (ie first byte of the second packet/fragment).
