• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.hardware.threadnetwork;
18 
19 import android.hardware.threadnetwork.IThreadChipCallback;
20 
21 /**
22  * Controls a Thread radio chip on the device.
23  */
24 
25 @VintfStability
26 interface IThreadChip {
27     /**
28      * The operation failed for the internal error.
29      */
30     const int ERROR_FAILED = 1;
31 
32     /**
33      * Insufficient buffers available to send frames.
34      */
35     const int ERROR_NO_BUFS = 2;
36 
37     /**
38      * Service is busy and could not service the operation.
39      */
40     const int ERROR_BUSY = 3;
41 
42     /**
43      * This method initializes the Thread HAL instance. If open completes
44      * successfully, then the Thread HAL instance is ready to accept spinel
45      * messages through sendSpinelFrame() API.
46      *
47      * @param callback  A IThreadChipCallback callback instance.
48      *
49      * @throws EX_ILLEGAL_ARGUMENT  if the callback handle is invalid (for example, it is null).
50      *
51      * @throws ServiceSpecificException with one of the following values:
52      *     - ERROR_FAILED        The interface cannot be opened due to an internal error.
53      *     - ERROR_BUSY          This interface is in use.
54      */
open(in IThreadChipCallback callback)55     void open(in IThreadChipCallback callback);
56 
57     /**
58      * Close the Thread HAL instance. Must free all resources.
59      */
close()60     void close();
61 
62     /**
63      * This method hardware resets the Thread radio chip via the physical reset pin.
64      * The callback registered by `open()` won’t be reset and the resource allocated
65      * by `open()` won’t be free.
66      *
67      * @throws EX_UNSUPPORTED_OPERATION  if the Thread radio chip doesn't support the hardware reset.
68      *
69      */
hardwareReset()70     void hardwareReset();
71 
72     /**
73      * This method sends a spinel frame to the Thread HAL.
74      *
75      * This method should block until the frame is sent out successfully or
76      * the method throws errors immediately.
77      *
78      * Spinel Protocol:
79      *     https://github.com/openthread/openthread/blob/main/src/lib/spinel/spinel.h
80      *
81      * @param frame  The spinel frame to be sent.
82      *
83      * @throws ServiceSpecificException with one of the following values:
84      *         - ERROR_FAILED The Thread HAL failed to send the frame for an internal reason.
85      *         - ERROR_NO_BUFS Insufficient buffer space to send the frame.
86      *         - ERROR_BUSY The Thread HAL is busy.
87      */
sendSpinelFrame(in byte[] frame)88     void sendSpinelFrame(in byte[] frame);
89 }
90