]> git.basschouten.com Git - openhab-addons.git/blob
3819ee8969c9e2a7b7dfb281a7134b5be2e441c6
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.alarmdecoder.internal.protocol;
14
15 import java.util.List;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * The {@link VersionMessage} class represents a parsed VER message.
21  *
22  * @author Bob Adair - Initial contribution
23  */
24 @NonNullByDefault
25 public class VersionMessage extends ADMessage {
26
27     // Example: !VER:ffffffff,V2.2a.8.2,TX;RX;SM;VZ;RF;ZX;RE;AU;3X;CG;DD;MF;LR;KE;MK;CB;DS;ER
28
29     /** Serial number */
30     public final String serial;
31
32     /** Firmware version */
33     public final String version;
34
35     /** Firmware capabilities */
36     public final String capabilities;
37
38     public VersionMessage(String message) throws IllegalArgumentException {
39         super(message);
40
41         String topLevel[] = message.split(":");
42         if (topLevel.length != 2) {
43             throw new IllegalArgumentException("Multiple colons found in VER message");
44         }
45
46         List<String> parts = splitMsg(topLevel[1]);
47
48         if (parts.size() != 3) {
49             throw new IllegalArgumentException("Invalid number of parts in VER message");
50         }
51
52         serial = parts.get(0);
53         version = parts.get(1);
54         capabilities = parts.get(2);
55     }
56 }