1/*
2 * Copyright (C) 2017 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
17package android.net.lowpan;
18
19import android.net.IpPrefix;
20import android.net.lowpan.ILowpanEnergyScanCallback;
21import android.net.lowpan.ILowpanInterfaceListener;
22import android.net.lowpan.ILowpanNetScanCallback;
23import android.net.lowpan.LowpanBeaconInfo;
24import android.net.lowpan.LowpanChannelInfo;
25import android.net.lowpan.LowpanCredential;
26import android.net.lowpan.LowpanIdentity;
27import android.net.lowpan.LowpanProvision;
28
29/** {@hide} */
30interface ILowpanInterface {
31
32    // These are here for the sake of C++ interface implementations.
33
34    const String PERM_ACCESS_LOWPAN_STATE    = "android.permission.ACCESS_LOWPAN_STATE";
35    const String PERM_CHANGE_LOWPAN_STATE    = "android.permission.CHANGE_LOWPAN_STATE";
36    const String PERM_READ_LOWPAN_CREDENTIAL = "android.permission.READ_LOWPAN_CREDENTIAL";
37
38    /**
39     * Channel mask key.
40     * Used for setting a channel mask when starting a scan.
41     * Type: int[]
42     * */
43    const String KEY_CHANNEL_MASK       = "android.net.lowpan.property.CHANNEL_MASK";
44
45    /**
46     * Max Transmit Power Key.
47     * Used for setting the maximum transmit power when starting a network scan.
48     * Type: Integer
49     * */
50    const String KEY_MAX_TX_POWER       = "android.net.lowpan.property.MAX_TX_POWER";
51
52    // Interface States
53
54    const String STATE_OFFLINE = "offline";
55    const String STATE_COMMISSIONING = "commissioning";
56    const String STATE_ATTACHING = "attaching";
57    const String STATE_ATTACHED = "attached";
58    const String STATE_FAULT = "fault";
59
60    // Device Roles
61
62    const String ROLE_END_DEVICE = "end-device";
63    const String ROLE_ROUTER = "router";
64    const String ROLE_SLEEPY_END_DEVICE = "sleepy-end-device";
65    const String ROLE_SLEEPY_ROUTER = "sleepy-router";
66    const String ROLE_LEADER = "leader";
67    const String ROLE_COORDINATOR = "coordinator";
68    const String ROLE_DETACHED = "detached";
69
70    const String NETWORK_TYPE_UNKNOWN = "unknown";
71
72    /**
73     * Network type for Thread 1.x networks.
74     *
75     * @see android.net.lowpan.LowpanIdentity#getType
76     * @see #getLowpanIdentity
77     */
78    const String NETWORK_TYPE_THREAD_V1 = "org.threadgroup.thread.v1";
79
80    // Service-Specific Error Code Constants
81
82    const int ERROR_UNSPECIFIED = 1;
83    const int ERROR_INVALID_ARGUMENT = 2;
84    const int ERROR_DISABLED = 3;
85    const int ERROR_WRONG_STATE = 4;
86    const int ERROR_TIMEOUT = 5;
87    const int ERROR_IO_FAILURE = 6;
88    const int ERROR_NCP_PROBLEM = 7;
89    const int ERROR_BUSY = 8;
90    const int ERROR_ALREADY = 9;
91    const int ERROR_CANCELED = 10;
92    const int ERROR_FEATURE_NOT_SUPPORTED = 11;
93    const int ERROR_JOIN_FAILED_UNKNOWN = 12;
94    const int ERROR_JOIN_FAILED_AT_SCAN = 13;
95    const int ERROR_JOIN_FAILED_AT_AUTH = 14;
96    const int ERROR_FORM_FAILED_AT_SCAN = 15;
97
98    // Methods
99
100    @utf8InCpp String getName();
101
102    @utf8InCpp String getNcpVersion();
103    @utf8InCpp String getDriverVersion();
104    LowpanChannelInfo[] getSupportedChannels();
105    @utf8InCpp String[] getSupportedNetworkTypes();
106    byte[] getMacAddress();
107
108    boolean isEnabled();
109    void setEnabled(boolean enabled);
110
111    boolean isUp();
112    boolean isCommissioned();
113    boolean isConnected();
114    @utf8InCpp String getState();
115
116    @utf8InCpp String getRole();
117    @utf8InCpp String getPartitionId();
118    byte[] getExtendedAddress();
119
120    LowpanIdentity getLowpanIdentity();
121    LowpanCredential getLowpanCredential();
122
123    @utf8InCpp String[] getLinkAddresses();
124    IpPrefix[] getLinkNetworks();
125
126    void join(in LowpanProvision provision);
127    void form(in LowpanProvision provision);
128    void attach(in LowpanProvision provision);
129    void leave();
130    void reset();
131
132    void startCommissioningSession(in LowpanBeaconInfo beaconInfo);
133    void closeCommissioningSession();
134    oneway void sendToCommissioner(in byte[] packet);
135
136    void beginLowPower();
137    oneway void pollForData();
138
139    oneway void onHostWake();
140
141    void addListener(ILowpanInterfaceListener listener);
142    oneway void removeListener(ILowpanInterfaceListener listener);
143
144    void startNetScan(in Map properties, ILowpanNetScanCallback listener);
145    oneway void stopNetScan();
146
147    void startEnergyScan(in Map properties, ILowpanEnergyScanCallback listener);
148    oneway void stopEnergyScan();
149
150    void addOnMeshPrefix(in IpPrefix prefix, int flags);
151    oneway void removeOnMeshPrefix(in IpPrefix prefix);
152
153    void addExternalRoute(in IpPrefix prefix, int flags);
154    oneway void removeExternalRoute(in IpPrefix prefix);
155}
156