-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathEspMeshApis.java
209 lines (182 loc) · 6.73 KB
/
EspMeshApis.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package iot.espressif.esp32.api;
import android.bluetooth.BluetoothDevice;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.File;
import java.util.Collection;
import java.util.List;
import iot.espressif.esp32.model.callback.DeviceScanCallback;
import iot.espressif.esp32.model.device.IEspDevice;
import iot.espressif.esp32.model.device.ble.MeshBlufiCallback;
import iot.espressif.esp32.model.device.ble.MeshBlufiClient;
import iot.espressif.esp32.model.device.ble.MeshConfigureParams;
import iot.espressif.esp32.model.device.ble.MeshScanListener;
import iot.espressif.esp32.model.device.ota.EspOTAClient;
import iot.espressif.esp32.model.device.properties.EspDeviceCharacteristic;
import meshblufi.espressif.BlufiClient;
import meshblufi.espressif.response.BlufiStatusResponse;
public abstract class EspMeshApis {
private static final Object sLock = new Object();
private static EspMeshApis sInstance;
EspMeshApis() {
}
/**
* Get single instance
*
* @return implemented API instance
*/
public static EspMeshApis getImplInstance() {
if (sInstance == null) {
synchronized (sLock) {
if (sInstance == null) {
sInstance = new EspMeshApisImpl();
}
}
}
return sInstance;
}
/**
* Starts a scan for Mesh BLE devices.
*
* @param listener the callback Mesh BLE device scan results are delivered.
*/
abstract public void startScanMeshBleDevice(@NonNull MeshScanListener listener);
/**
* Stops an ongoing Mesh BLE device scan.
*
* @param listener used to identify which scan to stop
* must be the same handle used to start the scan
*/
abstract public void stopScanMeshBleDevice(@NonNull MeshScanListener listener);
/**
* Configure the device to connect the specific AP.
* If the device connect the specific AP successfully, {@link MeshBlufiCallback#onWifiStateResponse(BlufiClient, BlufiStatusResponse)}
* will be invoked.
*
* @param device Mesh BLE device
* @param meshVersion the version from MDF manufacturer data
* @param params AP info and mesh options
* @param blufiCallback Blufi callback
* @return MeshBlufiClient
*/
abstract public MeshBlufiClient startConfigureNetwork(@NonNull BluetoothDevice device, int meshVersion,
@NonNull MeshConfigureParams params,
@NonNull MeshBlufiCallback blufiCallback);
/**
* Stop the configuring process
*
* @param client ongoing client
*/
abstract public void stopConfigureNetwork(@NonNull MeshBlufiClient client);
/**
* Scan all station devices in LAN
*
* @return station devices list
*/
abstract public List<IEspDevice> scanStations();
/**
* Scan all station devices in LAN
*
* @param callback the callback station device scan results are delivered
* @return station device list
*/
abstract public List<IEspDevice> scanStations(@Nullable DeviceScanCallback callback);
/**
* Start upgrade device rom version. The App will post the bin data to devices.
*
* @param bin bin file
* @param devices the devices need upgrade
* @param callback the callback ota progress is updated
* @return EspOTAClient
*/
abstract public EspOTAClient startOTA(@NonNull File bin, @NonNull Collection<IEspDevice> devices,
@Nullable EspOTAClient.OTACallback callback);
/**
* Start upgrade device rom version. The devices will download bin data from the specific URL.
* The OTA task will running in an async thread.
*
* @param url bin url
* @param devices the devices need upgrade
* @param callback the callback ota progress is updated
* @return EspOTAClient
*/
abstract public EspOTAClient startOTA(@NonNull String url, @NonNull Collection<IEspDevice> devices,
@Nullable EspOTAClient.OTACallback callback);
/**
* Stop OTA process.
*
* @param client ongoing client
*/
abstract public void stopOTA(@NonNull EspOTAClient client);
/**
* Update device info.
*
* @param device MDF device
* @return true if get device info successfully
*/
abstract public boolean getDeviceInfo(@NonNull IEspDevice device);
/**
* Update devices info.
*
* @param devices MDF devices
*/
abstract public void getDevicesInfo(@NonNull Collection<IEspDevice> devices);
/**
* Change the device status
*
* @param device MDF device
* @param characteristics the EspDeviceCharacteristic items require to set cid and value
* @return true if post request successfully
*/
abstract public boolean setDeviceStatus(@NonNull IEspDevice device,
@NonNull Collection<EspDeviceCharacteristic> characteristics);
/**
* Change the devices status
*
* @param devices MDF devices
* @param characteristics the EspDeviceCharacteristic items require to set cid and value
*/
abstract public void setDevicesStatus(@NonNull Collection<IEspDevice> devices,
@NonNull Collection<EspDeviceCharacteristic> characteristics);
/**
* Update specific status
*
* @param device MDF device
* @param cids the EspDeviceCharacteristic need to update
* @return true if update successfully
*/
abstract public boolean getDeviceStatus(@NonNull IEspDevice device, int... cids);
/**
* Update specific status
*
* @param devices MDF devices
* @param cids the EspDeviceCharacteristic need to update
*/
abstract public void getDevicesStatus(@NonNull Collection<IEspDevice> devices, int... cids);
/**
* Post a request to reboot the device
*
* @param device MDF devices
* @return true if post the request successfully
*/
abstract public boolean reboot(@NonNull IEspDevice device);
/**
* Post a request to reboot the devices
*
* @param devices MDF devices
*/
abstract public void reboot(@NonNull Collection<IEspDevice> devices);
/**
* Post a request to reset the device
*
* @param device MDF device
* @return true if post the request successfully
*/
abstract public boolean reset(@NonNull IEspDevice device);
/**
* Post a request to reset the devices
*
* @param devices MDF devices
*/
abstract public void reset(@NonNull Collection<IEspDevice> devices);
}