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