]> git.basschouten.com Git - openhab-addons.git/blob
e354a904dda9a582e99fa05a872d9e83e4f826c6
[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.bluetooth.bluegiga.internal.enumeration;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * Class to implement the BlueGiga Enumeration <b>BgApiResponse</b>.
23  * <p>
24  * Response codes
25  * <p>
26  * Note that this code is autogenerated. Manual changes may be overwritten.
27  *
28  * @author Chris Jackson - Initial contribution of Java code generator
29  */
30 @NonNullByDefault
31 public enum BgApiResponse {
32     /**
33      * Default unknown value
34      */
35     UNKNOWN(-1),
36
37     /**
38      * [0] Completed successfully.
39      */
40     SUCCESS(0x0000),
41
42     /**
43      * [257] Invalid GATT connection handle.
44      */
45     INVALID_CONN_HANDLE(0x0101),
46
47     /**
48      * [258] Waiting response from GATT server to previous procedure.
49      */
50     WAITING_RESPONSE(0x0102),
51
52     /**
53      * [384] Command contained invalid parameter
54      */
55     INVALID_PARAM(0x0180),
56
57     /**
58      * [385] Device is in wrong state to receive command
59      */
60     WRONG_STATE(0x0181),
61
62     /**
63      * [386] Device has run out of memory
64      */
65     OUT_OF_MEMORY(0x0182),
66
67     /**
68      * [387] Feature is not implemented
69      */
70     NOT_IMPLEMENTED(0x0183),
71
72     /**
73      * [388] Command was not recognized
74      */
75     INVALID_COMMAND(0x0184),
76
77     /**
78      * [389] Command or Procedure failed due to timeout
79      */
80     TIMEOUT(0x0185),
81
82     /**
83      * [390] Connection handle passed is to command is not a valid handle
84      */
85     NOT_CONNECTED(0x0186),
86
87     /**
88      * [391] Command would cause either underflow or overflow error
89      */
90     FLOW(0x0187),
91
92     /**
93      * [392] User attribute was accessed through API which is not supported
94      */
95     USER_ATTRIBUTE(0x0188),
96
97     /**
98      * [393] No valid license key found
99      */
100     INVALID_LICENSE_KEY(0x0189),
101
102     /**
103      * [394] Command maximum length exceeded
104      */
105     COMMAND_TOO_LONG(0x018A),
106
107     /**
108      * [395] Bonding procedure can't be started because device has no space left for bond.
109      */
110     OUT_OF_BONDS(0x018B),
111
112     /**
113      * [396] Unspecified error
114      */
115     UNSPECIFIED(0x018C),
116
117     /**
118      * [397] Hardware failure
119      */
120     HARDWARE(0x018D),
121
122     /**
123      * [398] Command not accepted, because internal buffers are full
124      */
125     BUFFERS_FULL(0x018E),
126
127     /**
128      * [399] Command or Procedure failed due to disconnection
129      */
130     DISCONNECTED(0x018F),
131
132     /**
133      * [400] Too many Simultaneous Requests
134      */
135     TOO_MANY_REQUESTS(0x0190),
136
137     /**
138      * [401] Feature is not supported in this firmware build
139      */
140     NOT_SUPPORTED(0x0191),
141
142     /**
143      * [402] The bonding does not exist.
144      */
145     NO_BONDING(0x0192),
146
147     /**
148      * [403] Error using crypto functions
149      */
150     CRYPTO(0x0193),
151
152     /**
153      * [514] A command was sent from the Host that should identify a connection, but that connection
154      * does not exist.
155      */
156     UNKNOWN_CONNECTION_IDENTIFIER(0x0202),
157
158     /**
159      * [520] Link supervision timeout has expired.
160      */
161     CONNECTION_TIMEOUT(0x0208),
162
163     /**
164      * [521] Controller is at limit of connections it can support.
165      */
166     CONNECTION_LIMIT_EXCEEDED(0x0209),
167
168     /**
169      * [522]
170      */
171     SYNCHRONOUS_CONNECTIONTION_LIMIT_EXCEEDED(0x020A),
172
173     /**
174      * [523] The ACL Connection Already Exists error code indicates that an attempt to create a new
175      * ACL Connection to a device when there is already a connection to this device.
176      */
177     ACL_CONNECTION_ALREADY_EXISTS(0x020B),
178
179     /**
180      * [524] Command requested cannot be executed because the Controller is in a state where it
181      * cannot process this command at this time.
182      */
183     COMMAND_DISALLOWED(0x020C),
184
185     /**
186      * [525] The Connection Rejected Due To Limited Resources error code indicates that an
187      * incoming connection was rejected due to limited resources.
188      */
189     CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES(0x020D),
190
191     /**
192      * [526] The Connection Rejected Due To Security Reasons error code indicates that a
193      * connection was rejected due to security requirements not being fulfilled, like
194      * authentication or pairing.
195      */
196     CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS(0x020E),
197
198     /**
199      * [527] The Connection was rejected because this device does not accept the BD_ADDR. This may
200      * be because the device will only accept connections from specific BD_ADDRs.
201      */
202     CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR(0x020F),
203
204     /**
205      * [528] The Connection Accept Timeout has been exceeded for this connection attempt.
206      */
207     CONNECTION_ACCEPT_TIMEOUT_EXCEEDED(0x0210),
208
209     /**
210      * [529] A feature or parameter value in the HCI command is not supported.
211      */
212     UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE(0x0211),
213
214     /**
215      * [530] Command contained invalid parameters.
216      */
217     INVALID_COMMAND_PARAMETERS(0x0212),
218
219     /**
220      * [531] User on the remote device terminated the connection.
221      */
222     REMOTE_USER_TERMINATED(0x0213),
223
224     /**
225      * [532] The remote device terminated the connection because of low resources
226      */
227     REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES(0x0214),
228
229     /**
230      * [533] Remote Device Terminated Connection due to Power Off
231      */
232     REMOTE_POWERING_OFF(0x0215),
233
234     /**
235      * [534] Local device terminated the connection.
236      */
237     CONNECTION_TERMINATED_BY_LOCAL_HOST(0x0216),
238
239     /**
240      * [535] The Controller is disallowing an authentication or pairing procedure because too
241      * little time has elapsed since the last authentication or pairing attempt failed.
242      */
243     REPEATED_ATTEMPTS(0x0217),
244
245     /**
246      * [536] The device does not allow pairing. This can be for example, when a device only allows
247      * pairing during a certain time window after some user input allows pairing
248      */
249     PAIRING_NOT_ALLOWED(0x0218),
250
251     /**
252      * [537] The Controller has received an unknown LMP OpCode.
253      */
254     UNKNOWN_LMP_PDU(0x0219),
255
256     /**
257      * [538] The remote device does not support the feature associated with the issued command or
258      * LMP PDU.
259      */
260     UNSUPPORTED_REMOTE_FEATURE(0x021A),
261
262     /**
263      * [560] A parameter value requested is outside the mandatory range of parameters for the given
264      * HCI command or LMP PDU.
265      */
266     PARAMETER_OUT_OF_MANDATORY_RANGE(0x0230),
267
268     /**
269      * [569] The Controller could not calculate an appropriate value for the Channel selection
270      * operation.
271      */
272     CONNECTION_REJECTED_NO_SUITABLE_CHANNEL(0x0239),
273
274     /**
275      * [570] Operation was rejected because the controller is busy and unable to process the
276      * request.
277      */
278     CONTROLLER_BUSY(0x023A),
279
280     /**
281      * [571] Remote device terminated the connection because of an unacceptable connection
282      * interval.
283      */
284     UNACCEPTABLE_CONNECTION_INTERVAL(0x023B),
285
286     /**
287      * [573] Connection was terminated because the Message Integrity Check (MIC) failed on a
288      * received packet.
289      */
290     CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE(0x023D),
291
292     /**
293      * [574] LL initiated a connection but the connection has failed to be established. Controller
294      * did not receive any packets from remote end.
295      */
296     CONNECTION_FAILED_TO_BE_ESTABLISHED(0x023E),
297
298     /**
299      * [575] The MAC of the 802.11 AMP was requested to connect to a peer, but the connection failed.
300      */
301     MAC_CONNECTION_FAILED(0x023F),
302
303     /**
304      * [576] The master, at this time, is unable to make a coarse adjustment to the piconet clock,
305      * using the supplied parameters. Instead the master will attempt to move the clock using clock
306      * dragging.
307      */
308     COARSE_CLOCK_ADJUSTMENT_REJECTED(0x0240),
309
310     /**
311      * [769] The user input of passkey failed, for example, the user cancelled the operation
312      */
313     PASSKEY_ENTRY_FAILED(0x0301),
314
315     /**
316      * [1025] The attribute handle given was not valid on this server
317      */
318     INVALID_HANDLE(0x0401),
319
320     /**
321      * [1026] The attribute cannot be read
322      */
323     READ_NOT_PERMITTED(0x0402),
324
325     /**
326      * [1027] The attribute cannot be written
327      */
328     WRITE_NOT_PERMITTED(0x0403),
329
330     /**
331      * [1028] The attribute PDU was invalid
332      */
333     INVALID_PDU(0x0404),
334
335     /**
336      * [1029] The attribute requires authentication before it can be read or written.
337      */
338     INSUFFICIENT_AUTHENTICATION(0x0405),
339
340     /**
341      * [1030] Attribute Server does not support the request received from the client.
342      */
343     REQUEST_NOT_SUPPORTED(0x0406),
344
345     /**
346      * [1031] Offset specified was past the end of the attribute
347      */
348     INVALID_OFFSET(0x0407),
349
350     /**
351      * [1032] The attribute requires authorization before it can be read or written.
352      */
353     INSUFFICIENT_AUTHORIZATION(0x0408),
354
355     /**
356      * [1033] Too many prepare writes have been queueud
357      */
358     PREPARE_QUEUE_FULL(0x0409),
359
360     /**
361      * [1034] No attribute found within the given attribute handle range.
362      */
363     ATT_NOT_FOUND(0x040A),
364
365     /**
366      * [1035] The attribute cannot be read or written using the Read Blob Request
367      */
368     ATT_NOT_LONG(0x040B),
369
370     /**
371      * [1037] The attribute value length is invalid for the operation
372      */
373     INVALID_ATT_LENGTH(0x040D),
374
375     /**
376      * [1040] The attribute type is not a supported grouping attribute as defined by a higher layer
377      * specification.
378      */
379     UNSUPPORTED_GROUP_TYPE(0x0410),
380
381     /**
382      * [1041] Insufficient Resources to complete the request
383      */
384     INSUFFICIENT_RESOURCES(0x0411),
385
386     /**
387      * [1152] Application error code defined by a higher layer specification.
388      */
389     APPLICATION(0x0480),
390
391     /**
392      * [1537] Service Record not found
393      */
394     RECORD_NOT_FOUND(0x0601),
395
396     /**
397      * [1538] Service Record with this handle already exist
398      */
399     RECORD_ALREADY_EXIST(0x0602),
400
401     /**
402      * [2305] File not found.
403      */
404     FILE_NOT_FOUND(0x0901),
405
406     /**
407      * [2561] File open failed.
408      */
409     FILE_OPEN_FAILED(0x0A01),
410
411     /**
412      * [2562] XML parsing failed.
413      */
414     XML_PARSE_FAILED(0x0A02),
415
416     /**
417      * [2563] Device connection failed.
418      */
419     DEVICE_CONNECTION_FAILED(0x0A03),
420
421     /**
422      * [2817] Device firmware signature verification failed.
423      */
424     IMAGE_SIGNATURE_VERIFICATION_FAILED(0x0B01),
425
426     /**
427      * [2818] File signature verification failed.
428      */
429     FILE_SIGNATURE_VERIFICATION_FAILED(0x0B02),
430
431     /**
432      * [2819] Device firmware checksum is not valid.
433      */
434     IMAGE_CHECKSUM_ERROR(0x0B03);
435
436     /**
437      * A mapping between the integer code and its corresponding type to
438      * facilitate lookup by code.
439      */
440     private static @Nullable Map<Integer, BgApiResponse> codeMapping;
441
442     private int key;
443
444     private BgApiResponse(int key) {
445         this.key = key;
446     }
447
448     /**
449      * Lookup function based on the type code. Returns {@link UNKNOWN} if the code does not exist.
450      *
451      * @param bgApiResponse
452      *            the code to lookup
453      * @return enumeration value.
454      */
455     public static BgApiResponse getBgApiResponse(int bgApiResponse) {
456         Map<Integer, BgApiResponse> localCodeMapping = codeMapping;
457         if (localCodeMapping == null) {
458             localCodeMapping = new HashMap<>();
459             for (BgApiResponse s : values()) {
460                 localCodeMapping.put(s.key, s);
461             }
462             codeMapping = localCodeMapping;
463         }
464
465         return localCodeMapping.getOrDefault(bgApiResponse, UNKNOWN);
466     }
467
468     /**
469      * Returns the BlueGiga protocol defined value for this enum
470      *
471      * @return the BGAPI enumeration key
472      */
473     public int getKey() {
474         return key;
475     }
476 }