aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/dsi/ant/server/AntHalDefine.java
blob: fa524781e74ee788653edc692fc28e68f5f8edc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * ANT Stack
 *
 * Copyright 2011 Dynastream Innovations
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.dsi.ant.server;

/**
 * Defines constants to be used by the ANT Radio Service to ANT System Service interface (IAntHal).
 */
public class AntHalDefine
{
    // ANT HAL Results
    /** Operation was successful. */
    public static final int ANT_HAL_RESULT_SUCCESS              = 1;

    /** Operation failed for an unknown reason. */
    public static final int ANT_HAL_RESULT_FAIL_UNKNOWN         = -1;

    /** Operation failed as it is invalid. */
    public static final int ANT_HAL_RESULT_FAIL_INVALID_REQUEST = -2;

    /** Operation failed as ANT is not enabled. */
    public static final int ANT_HAL_RESULT_FAIL_NOT_ENABLED     = -3;

    /** Operation failed as this device does not support ANT. */
    public static final int ANT_HAL_RESULT_FAIL_NOT_SUPPORTED   = -4;

    /** Operation failed as the ANT hardware is in use. */
    public static final int ANT_HAL_RESULT_FAIL_RESOURCE_IN_USE = -5;

    /**
     * Gets the human-readable value of an ANT_HAL_RESULT_X value.
     *
     * @param value the ANT_HAL_RESULT_X value
     * @return the string representation.
     */
    public static String getAntHalResultString(int value)
    {
        String string = null;

        switch(value)
        {
            case ANT_HAL_RESULT_SUCCESS:
                string = "SUCCESS";
                break;
            case ANT_HAL_RESULT_FAIL_UNKNOWN:
                string = "FAIL: UNKNOWN";
                break;
            case ANT_HAL_RESULT_FAIL_INVALID_REQUEST:
                string = "FAIL: INVALID REQUEST";
                break;
            case ANT_HAL_RESULT_FAIL_NOT_ENABLED:
                string = "FAIL: NOT ENABLED";
                break;
            case ANT_HAL_RESULT_FAIL_NOT_SUPPORTED:
                string = "FAIL: NOT SUPPORTED";
                break;
            case ANT_HAL_RESULT_FAIL_RESOURCE_IN_USE:
                string = "FAIL: RESOURCE IN USE";
                break;
        }

        return string;
    }


    // ANT HAL State

    /** State not yet initialised. */
    public static final int ANT_HAL_STATE_UNKNOWN               = 0;

    /** Powering on the ANT hardware and initialising the transport to it. */
    public static final int ANT_HAL_STATE_ENABLING              = 1;

    /** ANT is ON. */
    public static final int ANT_HAL_STATE_ENABLED               = 2;

    /** Closing the transport and powering down the ANT hardware. */
    public static final int ANT_HAL_STATE_DISABLING             = 3;

    /** ANT is OFF. */
    public static final int ANT_HAL_STATE_DISABLED              = 4;

    /** ANT is not supported on this device. */
    public static final int ANT_HAL_STATE_NOT_SUPPORTED         = 5;

    /** ANT system service is not installed. */
    public static final int ANT_HAL_STATE_SERVICE_NOT_INSTALLED = 6;

    /** There is no connection to the ANT system service (not bound). */
    public static final int ANT_HAL_STATE_SERVICE_NOT_CONNECTED = 7;

    /** ANT hardware was reset, low level is in the process of re-enabling. */
    public static final int ANT_HAL_STATE_RESETTING             = 8;

    /** ANT low level has finished re-enabling the hardware. */
    public static final int ANT_HAL_STATE_RESET                 = 9;

    /**
     * Gets the human-readable value of an ANT_HAL_STATE_X value.
     *
     * @param state the ANT_HAL_STATE_X value
     * @return the string representation.
     */
    public static String getAntHalStateString(int state)
    {
        String string = null;

        switch(state)
        {
            case ANT_HAL_STATE_UNKNOWN:
                string = "STATE UNKNOWN";
                break;
            case ANT_HAL_STATE_ENABLING:
                string = "ENABLING";
                break;
            case ANT_HAL_STATE_ENABLED:
                string = "ENABLED";
                break;
            case ANT_HAL_STATE_DISABLING:
                string = "DISABLING";
                break;
            case ANT_HAL_STATE_DISABLED:
                string = "DISABLED";
                break;
            case ANT_HAL_STATE_NOT_SUPPORTED:
                string = "ANT NOT SUPPORTED";
                break;
            case ANT_HAL_STATE_SERVICE_NOT_INSTALLED:
                string = "ANT HAL SERVICE NOT INSTALLED";
                break;
            case ANT_HAL_STATE_SERVICE_NOT_CONNECTED:
                string = "ANT HAL SERVICE NOT CONNECTED";
                break;
            case ANT_HAL_STATE_RESETTING:
                string = "RESETTING";
                break;
            case ANT_HAL_STATE_RESET:
                string = "RESET";
                break;
        }

        return string;
    }
}