2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.plugwise.internal.protocol;
15 import static org.openhab.binding.plugwise.internal.protocol.field.MessageType.MODULE_JOINED_NETWORK_REQUEST;
17 import java.util.regex.Matcher;
18 import java.util.regex.Pattern;
20 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
23 * Module joined network request. Sent when a SED (re)joins the network. E.g. when you reinsert the battery of a Scan.
25 * @author Wouter Born - Initial contribution
27 public class ModuleJoinedNetworkRequestMessage extends Message {
29 private static final Pattern PAYLOAD_PATTERN = Pattern.compile("(\\w{16})");
31 public ModuleJoinedNetworkRequestMessage(int sequenceNumber, String payload) {
32 super(MODULE_JOINED_NETWORK_REQUEST, sequenceNumber, payload);
36 protected void parsePayload() {
37 Matcher matcher = PAYLOAD_PATTERN.matcher(payload);
38 if (matcher.matches()) {
39 macAddress = new MACAddress(matcher.group(1));
41 throw new PlugwisePayloadMismatchException(MODULE_JOINED_NETWORK_REQUEST, PAYLOAD_PATTERN, payload);