# JAVA: Encode Beacon MessagePack form MQTT via AB BLE Gateway 4.0

**URL:** <https://bbs.aprbrother.com/t/java-encode-beacon-messagepack-form-mqtt-via-ab-ble-gateway-4-0/1686>\
**Category:** BLE Gateway\
**Created:** [October 7, 2020, 4:48pm UTC](https://bbs.aprbrother.com/t/java-encode-beacon-messagepack-form-mqtt-via-ab-ble-gateway-4-0/1686 "2020-10-07T16:48:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![motocrossmaster](https://bbs.aprbrother.com/letter_avatar_proxy/v4/letter/m/96bed5/32.png) [@motocrossmaster](https://bbs.aprbrother.com/u/motocrossmaster)\
**Post date:** [October 8, 2020, 7:41am UTC](https://bbs.aprbrother.com/t/java-encode-beacon-messagepack-form-mqtt-via-ab-ble-gateway-4-0/1686/2 "2020-10-08T07:41:32Z")

</div>

I found the Problem. the message was not always a Beacon, so it wasn`t always a map-format. So i have to check if the message is in map-format, then i can parse the massage like in the parse.java example.  
[https://github.com/AprilBrother/ab-ble-gateway-sdk/blob/master/gateway-v4/examples/java/http-server/Parse.java](https://github.com/AprilBrother/ab-ble-gateway-sdk/blob/master/gateway-v4/examples/java/http-server/Parse.java)

just add the line:  
if( unpacker.getNextFormat() == MessageFormat.FIXMAP) {

 ![image](https://bbs.aprbrother.com/uploads/default/original/1X/e23036909f6b79920d13646ab778fa382cd64c25.png)

---

_[View the full topic](https://bbs.aprbrother.com/t/java-encode-beacon-messagepack-form-mqtt-via-ab-ble-gateway-4-0/1686)._
