|
20 | 20 | import org.eclipse.hono.adapter.lora.LoraMessage;
|
21 | 21 | import org.eclipse.hono.adapter.lora.LoraMessageType;
|
22 | 22 | import org.eclipse.hono.adapter.lora.LoraMetaData;
|
| 23 | +import org.eclipse.hono.adapter.lora.UnknownLoraMessage; |
23 | 24 | import org.eclipse.hono.adapter.lora.UplinkLoraMessage;
|
24 | 25 | import org.eclipse.hono.util.CommandEndpoint;
|
25 | 26 | import org.eclipse.hono.util.Strings;
|
@@ -51,7 +52,7 @@ public LoraMessage getMessage(final RoutingContext ctx) {
|
51 | 52 | case UPLINK:
|
52 | 53 | return createUplinkMessage(ctx.request(), message);
|
53 | 54 | default:
|
54 |
| - throw new LoraProviderMalformedPayloadException(String.format("unsupported message type [%s]", type)); |
| 55 | + return createUnknownMessage(ctx.request(), message); |
55 | 56 | }
|
56 | 57 | } catch (final RuntimeException e) {
|
57 | 58 | // catch generic exception in order to also cover any (runtime) exceptions
|
@@ -184,4 +185,26 @@ protected UplinkLoraMessage createUplinkMessage(final HttpServerRequest request,
|
184 | 185 | message.setAdditionalData(getAdditionalData(requestBody));
|
185 | 186 | return message;
|
186 | 187 | }
|
| 188 | + |
| 189 | + /** |
| 190 | + * Creates an object representation of a Lora unknown message. |
| 191 | + * <p> |
| 192 | + * This method uses the {@link #getDevEui(JsonObject)} |
| 193 | + * method to extract relevant information from the request body to add |
| 194 | + * to the returned message. |
| 195 | + * |
| 196 | + * @param request The request sent by the provider's Network Server. |
| 197 | + * @param requestBody The JSON object contained in the request's body. |
| 198 | + * @return The message. |
| 199 | + * @throws RuntimeException if the message cannot be parsed. |
| 200 | + */ |
| 201 | + protected UnknownLoraMessage createUnknownMessage(final HttpServerRequest request, final JsonObject requestBody) { |
| 202 | + |
| 203 | + Objects.requireNonNull(requestBody); |
| 204 | + |
| 205 | + final UnknownLoraMessage message = new UnknownLoraMessage(); |
| 206 | + return message; |
| 207 | + } |
| 208 | + |
| 209 | + |
187 | 210 | }
|
0 commit comments