<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: packet.proto

namespace OS\PB\Packet;

use UnexpectedValueException;

/**
 * Transport Layer Information
 *
 * Protobuf type <code>OS.PB.Packet.PacketTypes</code>
 */
class PacketTypes
{
    /**
     * First nibble is packet from sender to receiver, can contain messages
     *
     * Generated from protobuf enum <code>PacketType_NotSet = 0;</code>
     */
    const PacketType_NotSet = 0;
    /**
     * Response required from receiver to sender
     *
     * Generated from protobuf enum <code>PacketType_Data_QoS1 = 0;</code>
     */
    const PacketType_Data_QoS1 = 0;
    /**
     * No response required from receiver to sender
     *
     * Generated from protobuf enum <code>PacketType_Data_QoS0 = 1;</code>
     */
    const PacketType_Data_QoS0 = 1;
    /**
     * Messages are encrypted and need to be decrypted before being read. Only possible if connect handshake has occured.
     *
     * Generated from protobuf enum <code>PacketType_Encrypted_QoS1 = 2;</code>
     */
    const PacketType_Encrypted_QoS1 = 2;
    /**
     * Broadcast on a networkable interface to tell other device's of its presence
     *
     * Generated from protobuf enum <code>PacketType_Advertisement = 4;</code>
     */
    const PacketType_Advertisement = 4;
    /**
     * Second nibble is response from receiver to sender, can't contain messages
     *
     * Generated from protobuf enum <code>PacketType_ACK = 16;</code>
     */
    const PacketType_ACK = 16;
    /**
     * Generic NACK for anything the transport layer does not recognise (no connection, unsuccessful challenge, etc)
     *
     * Generated from protobuf enum <code>PacketType_NACK = 32;</code>
     */
    const PacketType_NACK = 32;
    /**
     * Says the queue is full and the sender should move onto other devices if it can and come back later.
     *
     * Generated from protobuf enum <code>PacketType_NACK_Busy = 48;</code>
     */
    const PacketType_NACK_Busy = 48;
    /**
     * Says there is no route for this DestinationDeviceId and the sender should hold onto this packet until route is available.
     *
     * Generated from protobuf enum <code>PacketType_NACK_NoRoute = 64;</code>
     */
    const PacketType_NACK_NoRoute = 64;
    /**
     * Returned if the sender has not been authenticated and a connection established yet. Once connected, allows for description.
     *
     * Generated from protobuf enum <code>PacketType_NACK_NotConnected = 80;</code>
     */
    const PacketType_NACK_NotConnected = 80;

    private static $valueToName = [
        self::PacketType_NotSet => 'PacketType_NotSet',
        self::PacketType_Data_QoS1 => 'PacketType_Data_QoS1',
        self::PacketType_Data_QoS0 => 'PacketType_Data_QoS0',
        self::PacketType_Encrypted_QoS1 => 'PacketType_Encrypted_QoS1',
        self::PacketType_Advertisement => 'PacketType_Advertisement',
        self::PacketType_ACK => 'PacketType_ACK',
        self::PacketType_NACK => 'PacketType_NACK',
        self::PacketType_NACK_Busy => 'PacketType_NACK_Busy',
        self::PacketType_NACK_NoRoute => 'PacketType_NACK_NoRoute',
        self::PacketType_NACK_NotConnected => 'PacketType_NACK_NotConnected',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

