]> git.basschouten.com Git - openhab-addons.git/blob
641c2b8eb3d4881612950260dafa4a396c66ced8
[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.playstation.internal;
14
15 import java.util.Arrays;
16 import java.util.Map;
17 import java.util.stream.Collectors;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21
22 /**
23  * Enum of response error status.
24  *
25  * @author Fredrik Ahlström - Initial contribution
26  */
27 @NonNullByDefault
28 enum PS4ErrorStatus {
29     STATUS_OK(0x00, "Status OK."),
30     STATUS_UPDATE_APP(0x02, "Plugin needs to be updated."),
31     STATUS_UPDATE_PS4(0x03, "PS4 needs to update."),
32     STATUS_DO_LOGIN(0x06, "Log in on PS4."),
33     STATUS_MAX_USERS(0x07, "Max users logged in on PS4."),
34     STATUS_RESTART_APP(0x08, "Can not log in, restart plugin."),
35     STATUS_COMMAND_NOT_GOOD(0x0b, "Command not good!"),
36     STATUS_GAME_NOT_STARTED(0x0c, "Game not started!"), // Game/app not installed or other game running.
37     STATUS_NOT_PAIRED(0x0e, "Not paired to PS4!"), // Not allowed?
38     STATUS_OSK_NOT_OPENED(0x0f, "OSK not open right now."),
39     STATUS_CLOSE_OTHER_APP(0x11, "Close the other app connected to PS4!"),
40     STATUS_SOMEONE_ELSE_USING(0x12, "Someone else is using the PS4!"),
41     STATUS_OSK_NOT_SUPPORTED(0x13, "Can't control OSK now!"),
42     STATUS_MISSING_PAIRING_CODE(0x14, "Missing pairing-code!"), // ??
43     STATUS_WRONG_USER_CREDENTIAL(0x15, "Wrong user-credential!"),
44     STATUS_MISSING_PASS_CODE(0x16, "Missing pass-code!"),
45     STATUS_WRONG_PAIRING_CODE(0x17, "Wrong pairing-code!"),
46     STATUS_WRONG_PASS_CODE(0x18, "Wrong pass-code!"),
47     STATUS_REGISTER_DEVICE_OVER(0x1a, "To many devices registered!"),
48     STATUS_COULD_NOT_LOG_IN(0x1e, "Someone else is logging in now."),
49     STATUS_CAN_NOT_PLAY_NOW(0x21, "You can not log in right now."),
50     STATUS_ERROR_IN_COMMUNICATION(-1, "Error in comunication with PS4!");
51
52     private static final Map<Integer, PS4ErrorStatus> TAG_MAP = Arrays.stream(PS4ErrorStatus.values())
53             .collect(Collectors.toMap(status -> status.value, status -> status));
54
55     public final int value;
56     public final String message;
57
58     private PS4ErrorStatus(int value, String message) {
59         this.value = value;
60         this.message = message;
61     }
62
63     /**
64      * Get error status from value
65      *
66      * @param value the integer value of the status
67      * @return error status or null if unknown
68      */
69     public static @Nullable PS4ErrorStatus valueOfTag(int value) {
70         return TAG_MAP.get(value);
71     }
72 }