2 * Copyright (c) 2010-2023 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.playstation.internal;
15 import java.util.Arrays;
17 import java.util.stream.Collectors;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
23 * Enum of response error status.
25 * @author Fredrik Ahlström - Initial contribution
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!");
52 private static final Map<Integer, PS4ErrorStatus> TAG_MAP = Arrays.stream(PS4ErrorStatus.values())
53 .collect(Collectors.toMap(status -> status.value, status -> status));
55 public final int value;
56 public final String message;
58 private PS4ErrorStatus(int value, String message) {
60 this.message = message;
64 * Get error status from value
66 * @param value the integer value of the status
67 * @return error status or null if unknown
69 public static @Nullable PS4ErrorStatus valueOfTag(int value) {
70 return TAG_MAP.get(value);