Skip to content

Commit fad1635

Browse files
committed
Added Provisioning Library Module.
Features include : - Search for available BLE devices. - Scan device QR code to provide reference to ESP device. - Create reference of ESPDevice manually. - Data Encryption - Data transmission through BLE and SoftAP. - Scan for available Wi-Fi networks. - Provisioning API. - Support for exchanging custom data.
1 parent b6775b7 commit fad1635

37 files changed

+4088
-2
lines changed

build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.6.1'
11-
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.9'
10+
classpath 'com.android.tools.build:gradle:3.6.3'
1211

1312
// NOTE: Do not place your application dependencies here; they belong
1413
// in the individual module build.gradle files

provision/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

provision/build.gradle

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'com.google.protobuf'
3+
4+
buildscript {
5+
repositories {
6+
jcenter()
7+
mavenCentral()
8+
}
9+
dependencies {
10+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.9'
11+
}
12+
}
13+
14+
allprojects {
15+
repositories {
16+
jcenter()
17+
mavenCentral()
18+
}
19+
}
20+
21+
android {
22+
compileSdkVersion 29
23+
buildToolsVersion "29.0.1"
24+
25+
defaultConfig {
26+
minSdkVersion 24
27+
targetSdkVersion 29
28+
versionCode 1
29+
versionName "1.0"
30+
31+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
32+
consumerProguardFiles 'consumer-rules.pro'
33+
}
34+
35+
buildTypes {
36+
release {
37+
minifyEnabled false
38+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
39+
}
40+
}
41+
}
42+
43+
protobuf {
44+
protoc {
45+
artifact = 'com.google.protobuf:protoc:3.5.1'
46+
}
47+
plugins {
48+
javalite {
49+
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
50+
}
51+
}
52+
generateProtoTasks {
53+
all().each { task ->
54+
task.builtins {
55+
remove java
56+
}
57+
task.plugins {
58+
javalite {}
59+
}
60+
}
61+
}
62+
}
63+
64+
dependencies {
65+
implementation fileTree(dir: 'libs', include: ['*.jar'])
66+
67+
implementation 'androidx.appcompat:appcompat:1.1.0'
68+
implementation 'org.greenrobot:eventbus:3.1.1'
69+
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
70+
implementation 'com.google.crypto.tink:tink-android:1.1.0'
71+
implementation 'com.google.android.gms:play-services-vision:20.0.0'
72+
implementation 'androidx.preference:preference:1.1.1'
73+
74+
testImplementation 'junit:junit:4.12'
75+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
76+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
77+
}

provision/consumer-rules.pro

Whitespace-only changes.

provision/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.espressif.provision;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
25+
assertEquals("com.espressif.provision.test", appContext.getPackageName());
26+
}
27+
}
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.espressif.provision" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.espressif.provision;
16+
17+
import android.os.Bundle;
18+
19+
/**
20+
* Event class to send device connection / disconnection events to app.
21+
*/
22+
public class DeviceConnectionEvent {
23+
24+
private short eventType;
25+
private Bundle data;
26+
27+
public DeviceConnectionEvent(short type) {
28+
eventType = type;
29+
}
30+
31+
public short getEventType() {
32+
return eventType;
33+
}
34+
35+
public Bundle getData() {
36+
return data;
37+
}
38+
39+
public void setData(Bundle data) {
40+
this.data = data;
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.espressif.provision;
16+
17+
/**
18+
* This class has constants and enums used in library.
19+
*/
20+
public class ESPConstants {
21+
22+
public static final String DEFAULT_WIFI_BASE_URL = "192.168.4.1:80";
23+
24+
public enum TransportType {
25+
TRANSPORT_BLE,
26+
TRANSPORT_SOFTAP
27+
}
28+
29+
public enum SecurityType {
30+
SECURITY_0,
31+
SECURITY_1
32+
}
33+
34+
public enum ProvisionFailureReason {
35+
AUTH_FAILED,
36+
NETWORK_NOT_FOUND,
37+
DEVICE_DISCONNECTED,
38+
UNKNOWN
39+
}
40+
41+
// End point names
42+
public static final String HANDLER_PROV_SCAN = "prov-scan";
43+
public static final String HANDLER_PROTO_VER = "proto-ver";
44+
public static final String HANDLER_PROV_SESSION = "prov-session";
45+
public static final String HANDLER_PROV_CONFIG = "prov-config";
46+
47+
// Event types
48+
public static final short EVENT_DEVICE_CONNECTED = 1;
49+
public static final short EVENT_DEVICE_CONNECTION_FAILED = 2;
50+
public static final short EVENT_DEVICE_DISCONNECTED = 3;
51+
52+
// Constants for WiFi Security values (As per proto files)
53+
public static final short WIFI_OPEN = 0;
54+
public static final short WIFI_WEP = 1;
55+
public static final short WIFI_WPA_PSK = 2;
56+
public static final short WIFI_WPA2_PSK = 3;
57+
public static final short WIFI_WPA_WPA2_PSK = 4;
58+
public static final short WIFI_WPA2_ENTERPRISE = 5;
59+
}

0 commit comments

Comments
 (0)