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 
17 package android.net.lowpan;
18 
19 import android.net.IpPrefix;
20 import android.net.lowpan.ILowpanEnergyScanCallback;
21 import android.net.lowpan.ILowpanInterfaceListener;
22 import android.net.lowpan.ILowpanNetScanCallback;
23 import android.net.lowpan.LowpanBeaconInfo;
24 import android.net.lowpan.LowpanChannelInfo;
25 import android.net.lowpan.LowpanCredential;
26 import android.net.lowpan.LowpanIdentity;
27 import android.net.lowpan.LowpanProvision;
28 
29 /** {@hide} */
30 interface 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 
getName()100     @utf8InCpp String getName();
101 
getNcpVersion()102     @utf8InCpp String getNcpVersion();
getDriverVersion()103     @utf8InCpp String getDriverVersion();
getSupportedChannels()104     LowpanChannelInfo[] getSupportedChannels();
getSupportedNetworkTypes()105     @utf8InCpp String[] getSupportedNetworkTypes();
getMacAddress()106     byte[] getMacAddress();
107 
isEnabled()108     boolean isEnabled();
setEnabled(boolean enabled)109     void setEnabled(boolean enabled);
110 
isUp()111     boolean isUp();
isCommissioned()112     boolean isCommissioned();
isConnected()113     boolean isConnected();
getState()114     @utf8InCpp String getState();
115 
getRole()116     @utf8InCpp String getRole();
getPartitionId()117     @utf8InCpp String getPartitionId();
getExtendedAddress()118     byte[] getExtendedAddress();
119 
getLowpanIdentity()120     LowpanIdentity getLowpanIdentity();
getLowpanCredential()121     LowpanCredential getLowpanCredential();
122 
getLinkAddresses()123     @utf8InCpp String[] getLinkAddresses();
getLinkNetworks()124     IpPrefix[] getLinkNetworks();
125 
join(in LowpanProvision provision)126     void join(in LowpanProvision provision);
form(in LowpanProvision provision)127     void form(in LowpanProvision provision);
attach(in LowpanProvision provision)128     void attach(in LowpanProvision provision);
leave()129     void leave();
reset()130     void reset();
131 
startCommissioningSession(in LowpanBeaconInfo beaconInfo)132     void startCommissioningSession(in LowpanBeaconInfo beaconInfo);
closeCommissioningSession()133     void closeCommissioningSession();
sendToCommissioner(in byte[] packet)134     oneway void sendToCommissioner(in byte[] packet);
135 
beginLowPower()136     void beginLowPower();
pollForData()137     oneway void pollForData();
138 
onHostWake()139     oneway void onHostWake();
140 
addListener(ILowpanInterfaceListener listener)141     void addListener(ILowpanInterfaceListener listener);
removeListener(ILowpanInterfaceListener listener)142     oneway void removeListener(ILowpanInterfaceListener listener);
143 
startNetScan(in Map properties, ILowpanNetScanCallback listener)144     void startNetScan(in Map properties, ILowpanNetScanCallback listener);
stopNetScan()145     oneway void stopNetScan();
146 
startEnergyScan(in Map properties, ILowpanEnergyScanCallback listener)147     void startEnergyScan(in Map properties, ILowpanEnergyScanCallback listener);
stopEnergyScan()148     oneway void stopEnergyScan();
149 
addOnMeshPrefix(in IpPrefix prefix, int flags)150     void addOnMeshPrefix(in IpPrefix prefix, int flags);
removeOnMeshPrefix(in IpPrefix prefix)151     oneway void removeOnMeshPrefix(in IpPrefix prefix);
152 
addExternalRoute(in IpPrefix prefix, int flags)153     void addExternalRoute(in IpPrefix prefix, int flags);
removeExternalRoute(in IpPrefix prefix)154     oneway void removeExternalRoute(in IpPrefix prefix);
155 }
156