Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
XuXiangJun committed Feb 8, 2021
1 parent a440b55 commit 84bebf6
Show file tree
Hide file tree
Showing 51 changed files with 2,132 additions and 259 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# EspTouch for Android
This APP is used to configure ESP devices to connect target AP, the devices need run [smart config](https://github.com/espressif/esp-idf/tree/master/examples/wifi/smart_config).
This APP is used to configure ESP devices to connect target AP.
The devices need run smart config: [esp-idf](https://github.com/espressif/esp-idf/tree/master/examples/wifi/smart_config) or [ESP8266_RTOS_SDK](https://github.com/espressif/ESP8266_RTOS_SDK/tree/master/examples/wifi/smart_config)

## Licence
- See [Licence](ESPRESSIF_MIT_LICENSE)
Expand All @@ -9,7 +10,7 @@ This APP is used to configure ESP devices to connect target AP, the devices need

## Modules
- EspTouch: [esptouch](esptouch)
- EspTouchV2: [esptouch2](esptouch2)

## Releases
- See [releases](https://github.com/EspressifApp/EsptouchForAndroid/releases/latest), contain APK and aar
- For programmer, if you don't want use [esptouch](esptouch) module, download the aar into your own project.
- See [releases](https://github.com/EspressifApp/EsptouchForAndroid/releases)
18 changes: 11 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
compileSdkVersion 30

defaultConfig {
applicationId "com.espressif.esptouch.android"
minSdkVersion 21
targetSdkVersion 29
versionCode 23
versionName "v1.1.1"
targetSdkVersion 30
versionCode 26
versionName "v2.0.0"
}

signingConfigs {
Expand All @@ -28,6 +28,9 @@ android {
signingConfig signingConfigs.debug
}
}
buildFeatures {
viewBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -36,8 +39,9 @@ android {

dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(':esptouch')
implementation project(':esptouch-v2')
}
22 changes: 19 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
<application
android:name=".EspTouchApp"
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:icon="@mipmap/app_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
tools:ignore="GoogleAppIndexingWarning,LockedOrientationActivity"
android:fullBackupContent="@xml/backup_descriptor">
<activity
android:name="com.espressif.esptouch.android.v1.EspTouchActivity"
android:name=".main.EspMainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
Expand All @@ -27,6 +28,21 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.espressif.esptouch.android.v1.EspTouchActivity"
android:exported="true"
android:label="@string/esptouch1_title"
android:screenOrientation="portrait" />
<activity
android:name="com.espressif.esptouch.android.v2.EspTouch2Activity"
android:exported="true"
android:label="@string/esptouch2_title"
android:screenOrientation="portrait" />
<activity
android:name="com.espressif.esptouch.android.v2.EspProvisioningActivity"
android:exported="true"
android:label="@string/esptouch2_provisioning_title"
android:screenOrientation="portrait" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.location.LocationManagerCompat;

import com.espressif.iot.esptouch2.provision.TouchNetUtil;

import java.net.InetAddress;

public abstract class EspTouchActivityAbs extends AppCompatActivity {
Expand Down Expand Up @@ -141,31 +143,31 @@ protected StateResult checkWifi() {
StateResult result = new StateResult();
result.wifiConnected = false;
WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
boolean connected = NetUtils.isWifiConnected(mWifiManager);
boolean connected = TouchNetUtil.isWifiConnected(mWifiManager);
if (!connected) {
result.message = getString(R.string.esptouch_message_wifi_connection);
return result;
}

String ssid = NetUtils.getSsidString(wifiInfo);
String ssid = TouchNetUtil.getSsidString(wifiInfo);
int ipValue = wifiInfo.getIpAddress();
if (ipValue != 0) {
result.address = NetUtils.getAddress(wifiInfo.getIpAddress());
result.address = TouchNetUtil.getAddress(wifiInfo.getIpAddress());
} else {
result.address = NetUtils.getIPv4Address();
result.address = TouchNetUtil.getIPv4Address();
if (result.address == null) {
result.address = NetUtils.getIPv6Address();
result.address = TouchNetUtil.getIPv6Address();
}
}

result.wifiConnected = true;
result.message = "";
result.is5G = NetUtils.is5G(wifiInfo.getFrequency());
result.is5G = TouchNetUtil.is5G(wifiInfo.getFrequency());
if (result.is5G) {
result.message = getString(R.string.esptouch_message_wifi_frequency);
}
result.ssid = ssid;
result.ssidBytes = NetUtils.getRawSsidBytesOrElse(wifiInfo, ssid.getBytes());
result.ssidBytes = TouchNetUtil.getRawSsidBytesOrElse(wifiInfo, ssid.getBytes());
result.bssid = wifiInfo.getBSSID();

return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.espressif.esptouch.android.main;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.OrientationHelper;
import androidx.recyclerview.widget.RecyclerView;

import com.espressif.esptouch.android.R;
import com.espressif.esptouch.android.v1.EspTouchActivity;
import com.espressif.esptouch.android.v2.EspTouch2Activity;

public class EspMainActivity extends AppCompatActivity {
private static final String[] ITEMS = {
"EspTouch",
"EspTouch V2"
};

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle(R.string.main_title);

RecyclerView recyclerView = findViewById(R.id.recyclerView);
recyclerView.addItemDecoration(new DividerItemDecoration(this, OrientationHelper.VERTICAL));
recyclerView.setAdapter(new ItemAdapter());
}

private class ItemHolder extends RecyclerView.ViewHolder {
int position;
TextView label;

ItemHolder(@NonNull View itemView) {
super(itemView);

label = itemView.findViewById(R.id.label);

itemView.setOnClickListener(v -> {
switch (position) {
case 0:
startActivity(new Intent(EspMainActivity.this, EspTouchActivity.class));
break;
case 1:
startActivity(new Intent(EspMainActivity.this, EspTouch2Activity.class));
break;
}
});
}
}

private class ItemAdapter extends RecyclerView.Adapter<ItemHolder> {

@NonNull
@Override
public ItemHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = getLayoutInflater().inflate(R.layout.activity_main_item, parent, false);
return new ItemHolder(itemView);
}

@Override
public void onBindViewHolder(@NonNull ItemHolder holder, int position) {
String item = ITEMS[position];
holder.position = position;
holder.label.setText(item);
}

@Override
public int getItemCount() {
return ITEMS.length;
}
}
}
Loading

0 comments on commit 84bebf6

Please sign in to comment.