├── .gitignore ├── ESPRESSIF_MIT_LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── sign │ └── espblemesh └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── espressif │ │ └── espblemesh │ │ ├── app │ │ ├── BaseActivity.java │ │ └── MeshApp.java │ │ ├── constants │ │ └── Constants.java │ │ ├── eventbus │ │ ├── GattCloseEvent.java │ │ ├── GattConnectionEvent.java │ │ ├── GattNodeServiceEvent.java │ │ └── blemesh │ │ │ ├── CompositionDataEvent.java │ │ │ ├── FastProvAddrEvent.java │ │ │ ├── LightCTLEvent.java │ │ │ ├── LightHSLEvent.java │ │ │ ├── ModelAppEvent.java │ │ │ ├── ModelSubscriptionEvent.java │ │ │ ├── NodeResetEvent.java │ │ │ └── RelayEvent.java │ │ ├── model │ │ ├── BleScanResult.java │ │ ├── BluetoothReceiver.java │ │ ├── FastGroup.java │ │ ├── FastNode.java │ │ └── MeshConnection.java │ │ ├── ota │ │ ├── OTAClient.java │ │ └── OTAUtils.java │ │ ├── ui │ │ ├── MainActivity.java │ │ ├── MainService.java │ │ ├── NetworkAddActivity.java │ │ ├── ServiceActivity.java │ │ ├── Test.java │ │ ├── network │ │ │ ├── NetworkActivity.java │ │ │ ├── NetworkGroupFragment.java │ │ │ ├── NetworkNewGroupActivity.java │ │ │ ├── SimpleMessageCallback.java │ │ │ ├── fastprov │ │ │ │ ├── FastGroupCreateActivity.java │ │ │ │ └── FastProvedActivity.java │ │ │ ├── node │ │ │ │ ├── ModelActivity.java │ │ │ │ ├── ModelBindGroupActivity.java │ │ │ │ ├── NodeActivity.java │ │ │ │ ├── OperationActivity.java │ │ │ │ ├── OperationFragment.java │ │ │ │ ├── OperationLightCTLFragment.java │ │ │ │ └── OperationLightHSLFragment.java │ │ │ └── ota │ │ │ │ ├── NodeOTAActivity.java │ │ │ │ └── OTAPackage.java │ │ ├── provisioning │ │ │ ├── ProvisionScanActivity.java │ │ │ └── ProvisioningActivity.java │ │ └── settings │ │ │ ├── SettingsActivity.java │ │ │ ├── SettingsConstants.java │ │ │ └── SettingsFragment.java │ │ └── utils │ │ └── Utils.java │ └── res │ ├── drawable-hdpi │ ├── fast_switch_bg.png │ ├── fast_switch_off.png │ └── fast_switch_on.png │ ├── drawable-xhdpi │ ├── fast_switch_bg.png │ ├── fast_switch_off.png │ └── fast_switch_on.png │ ├── drawable-xxhdpi │ ├── fast_switch_bg.png │ ├── fast_switch_off.png │ └── fast_switch_on.png │ ├── drawable │ ├── baseline_expand_less_24.xml │ ├── baseline_expand_more_24.xml │ ├── baseline_grain_24.xml │ ├── baseline_unfold_less_24.xml │ ├── baseline_unfold_more_24.xml │ ├── color_button_bg.xml │ ├── fast_switch.xml │ ├── ic_add_24dp.xml │ ├── ic_add_box_24dp.xml │ ├── ic_add_circle_24dp.xml │ ├── ic_add_circle_outline_24dp.xml │ ├── ic_bluetooth_24dp.xml │ ├── ic_bluetooth_connected_24dp.xml │ ├── ic_bluetooth_connecting_24dp.xml │ ├── ic_bluetooth_disabled_24dp.xml │ ├── ic_color_lens_24dp.xml │ ├── ic_delete_24dp.xml │ ├── ic_device_hub_24dp.xml │ ├── ic_edit_24dp.xml │ ├── ic_filter_list_24dp.xml │ ├── ic_launcher_background.xml │ ├── ic_lightbulb_outline_24dp.xml │ ├── ic_more_horiz_24dp.xml │ ├── ic_refresh.xml │ ├── ic_remove_24dp.xml │ ├── ic_remove_circle_24dp.xml │ ├── ic_remove_circle_outline_24dp.xml │ ├── ic_settings_ethernet_24dp.xml │ ├── outline_add_box_24.xml │ ├── outline_info_24.xml │ ├── outline_settings_applications_24.xml │ ├── outline_share_24.xml │ └── side_nav_bar.xml │ ├── layout │ ├── fast_group_create_activity.xml │ ├── fast_group_item.xml │ ├── fast_proved_activity.xml │ ├── fast_proved_content.xml │ ├── fast_proved_item.xml │ ├── main_activity.xml │ ├── main_content.xml │ ├── main_nav_header.xml │ ├── main_network_item.xml │ ├── main_new_network_dialog.xml │ ├── model_activity.xml │ ├── model_bind_group_activity.xml │ ├── model_bind_group_content.xml │ ├── model_bind_group_item.xml │ ├── model_content.xml │ ├── network_activity.xml │ ├── network_add_activity.xml │ ├── network_content.xml │ ├── network_group_item.xml │ ├── network_pager_item_fragment.xml │ ├── new_group_activity.xml │ ├── node_activity.xml │ ├── node_composition_data_form.xml │ ├── node_content.xml │ ├── node_ctl_dialog.xml │ ├── node_element_model_group_item.xml │ ├── node_element_model_item.xml │ ├── node_generic_level_dialog.xml │ ├── node_hsl_dialog.xml │ ├── node_info_dialog.xml │ ├── node_ota_activity.xml │ ├── node_ota_content.xml │ ├── operation_activity.xml │ ├── operation_light_ctl_content.xml │ ├── operation_light_hsl_content.xml │ ├── provision_scan_activity.xml │ ├── provision_scan_filter_dialog.xml │ ├── provisioning_activity.xml │ ├── provisioning_content.xml │ └── settings_activity.xml │ ├── menu │ └── activity_main_drawer.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── values-zh-rCN │ └── strings.xml │ ├── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ ├── styles.xml │ └── values.xml │ └── xml │ └── settings.xml ├── apptools ├── .gitignore ├── build.gradle ├── gradlew.bat ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ ├── com │ │ └── github │ │ │ └── rubensousa │ │ │ └── floatingtoolbar │ │ │ ├── FloatingAnimator.java │ │ │ ├── FloatingAnimatorImpl.java │ │ │ ├── FloatingAnimatorLollipopImpl.java │ │ │ ├── FloatingScrollListener.java │ │ │ ├── FloatingSnackBarManager.java │ │ │ ├── FloatingToolbar.java │ │ │ └── FloatingToolbarMenuBuilder.java │ └── libs │ │ └── espressif │ │ ├── app │ │ ├── AppUtil.java │ │ ├── CrashHandler.java │ │ ├── EspActivity.java │ │ ├── PermissionHelper.java │ │ └── SdkUtil.java │ │ ├── ble │ │ ├── BleAdvData.java │ │ ├── EspBleUtils.java │ │ └── ScanListener.java │ │ ├── collection │ │ └── EspCollections.java │ │ ├── function │ │ └── FilterFunction.java │ │ ├── github │ │ ├── GitHubGetLatestReleaseTask.java │ │ └── GitHubRelease.java │ │ ├── language │ │ └── HanziToPinyin.java │ │ ├── location │ │ └── LocationUtils.java │ │ ├── log │ │ └── EspLog.java │ │ ├── net │ │ ├── EspHttpHeader.java │ │ ├── EspHttpParams.java │ │ ├── EspHttpResponse.java │ │ ├── EspHttpUtils.java │ │ ├── NetUtil.java │ │ └── SSLUtils.java │ │ ├── security │ │ ├── EspAES.java │ │ ├── EspCRC.java │ │ ├── EspDH.java │ │ ├── EspECC.java │ │ ├── EspMD5.java │ │ ├── EspPBKDF2.java │ │ └── EspRSA.java │ │ ├── utils │ │ ├── DataUtil.java │ │ ├── EnumUtil.java │ │ ├── EspColorUtil.java │ │ ├── RandomUtil.java │ │ ├── TextUtils.java │ │ └── TimeUtil.java │ │ └── widget │ │ ├── CircleColorPicker.java │ │ ├── ColorPicker.java │ │ ├── EspFullColorPicker.java │ │ └── LinearColorPicker.java │ └── res │ └── values │ ├── attrs.xml │ └── strings.xml ├── blemesh ├── .gitignore ├── build.gradle ├── objectbox-models │ ├── default.json │ └── default.json.bak ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── espressif │ └── blemesh │ ├── MeshInitialize.java │ ├── client │ ├── IMeshGattClient.java │ ├── IMeshMessager.java │ ├── IMeshProvisioner.java │ ├── MeshGattClient.java │ ├── MeshGattMessager.java │ ├── MeshGattProvisioner.java │ ├── abs │ │ ├── AdvProvisioner.java │ │ ├── MeshCommunicationClient.java │ │ ├── PrivateMeshCallback.java │ │ ├── PrivateMeshGattClientAbs.java │ │ ├── PrivateProvisioner.java │ │ └── PrivateProvisioningCallback.java │ └── callback │ │ ├── MeshGattCallback.java │ │ ├── MessageCallback.java │ │ └── ProvisioningCallback.java │ ├── constants │ └── MeshConstants.java │ ├── db │ ├── .gitignore │ ├── box │ │ └── MeshObjectBox.java │ └── entity │ │ ├── AddressDB.java │ │ ├── AppDB.java │ │ ├── AppNodeDB.java │ │ ├── ElementDB.java │ │ ├── FastGroupDB.java │ │ ├── GroupDB.java │ │ ├── GroupNodeDB.java │ │ ├── ModelDB.java │ │ ├── NetworkDB.java │ │ └── NodeDB.java │ ├── model │ ├── App.java │ ├── Element.java │ ├── Group.java │ ├── Model.java │ ├── Network.java │ ├── Node.java │ └── message │ │ ├── MeshMessage.java │ │ ├── custom │ │ ├── FastGroupBindMessage.java │ │ ├── FastGroupUnbindMessage.java │ │ ├── FastProvInfoSetMessage.java │ │ ├── FastProvNodeAddrGetMessage.java │ │ ├── OtaNBVNMessage.java │ │ └── OtaStartMessage.java │ │ └── standard │ │ ├── AppKeyAddMessage.java │ │ ├── CompositionDataGetMessage.java │ │ ├── GenericLevelGetMessage.java │ │ ├── GenericLevelSetMessage.java │ │ ├── GenericOnOffGetMessage.java │ │ ├── GenericOnOffSetMessage.java │ │ ├── LightCTLGetMessage.java │ │ ├── LightCTLSetMessage.java │ │ ├── LightHSLGetMessage.java │ │ ├── LightHSLSetMessage.java │ │ ├── ModelAppBindMessage.java │ │ ├── ModelSubscriptionAddMessage.java │ │ ├── ModelSubscriptionDeleteAllMessage.java │ │ ├── ModelSubscriptionDeleteMessage.java │ │ ├── ModelSubscriptionOverwriteMessage.java │ │ ├── NodeResetMessage.java │ │ ├── RelaySetMessage.java │ │ └── proxyconfiguration │ │ ├── AddAddressesToFilterMessage.java │ │ ├── ProxyConfigurationMessage.java │ │ └── SetFilterTypeMessage.java │ ├── task │ ├── AppAddTask.java │ ├── AppDeleteTask.java │ ├── GroupAddTask.java │ ├── GroupDeleteTask.java │ ├── MeshTask.java │ ├── NetworkAddTask.java │ ├── NetworkDeleteTask.java │ ├── NodeDeleteTask.java │ └── OTAListBinsTask.java │ ├── user │ ├── MeshUser.java │ └── MeshUserImpl.java │ └── utils │ ├── DBUtils.java │ ├── MeshAlgorithmUtils.java │ └── MeshUtils.java ├── build.gradle ├── doc └── sample.md ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── log └── ChangeLog_en.md └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | /.idea 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /ESPRESSIF_MIT_LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2019 2 | 3 | Permission is hereby granted for use on, for control of and/or for use in conjunction with ESPRESSIF SYSTEMS ESP8266/ESP32 only, in which case, it is free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | 乐鑫 MIT 许可证 10 | 11 | 版权 © 2019 <乐鑫信息科技(上海)股份有限公司> 12 | 13 | 该许可证授权仅限于乐鑫信息科技 ESP8266/ESP32 产品的应用开发或连接。在此情况下,该许可证免费授权任何获得该软件及其相关文档(统称为“软件”)的人无限制地经营该软件,包括无限制 的使用、复制、修改、合并、出版发行、散布、再授权、及贩售软件及软件副本的权利。被授权人在享受这些权利的同时,需服从下面的条件: 14 | 15 | 在软件和软件的所有副本中都必须包含以上的版权声明和授权声明。 16 | 17 | 该软件按本来的样子提供,没有任何明确或暗含的担保,包括但不仅限于关于试销性、适合某一特定用途和非侵权的保证。作者和版权持有人在任何情况下均不就由软件或软件使用引起的以合同形式、民事侵权或其它方式提出的任何索赔、损害或其它责任负责。 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EspBLEMesh 2 | This is a demo app to control the ESP device which run [ble_mesh](https://github.com/espressif/esp-idf/tree/ble_mesh_release/esp-ble-mesh-v0.6.1/examples/bluetooth/ble_mesh) 3 | 4 | 5 | ## ESPRSSIF MIT License 6 | - See [License](ESPRESSIF_MIT_LICENSE) 7 | 8 | ## Features 9 | - Supports provisioning with ESP device 10 | - Supports fast provisioning 11 | - Adding Network Key 12 | - Adding App Key 13 | - Binding added app keys to Models 14 | - Supports Generic OnOff 15 | - Supports Light HSL control 16 | - Subscribing/Unsubscribing to and from group addresses 17 | 18 | ## Sample 19 | - See [sample](doc/sample.md) -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.espressif.espblemesh" 7 | minSdkVersion 21 8 | targetSdkVersion 28 9 | versionCode 11 10 | versionName "v1.1.0" 11 | testInstrumentationRunner "android.support.adv.runner.AndroidJUnitRunner" 12 | externalNativeBuild { 13 | cmake { 14 | cppFlags "" 15 | } 16 | } 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | compileOptions { 25 | sourceCompatibility JavaVersion.VERSION_1_8 26 | targetCompatibility JavaVersion.VERSION_1_8 27 | } 28 | } 29 | 30 | dependencies { 31 | implementation fileTree(include: ['*.jar'], dir: 'libs') 32 | implementation 'com.google.android.material:material:1.1.0-beta01' 33 | implementation 'androidx.appcompat:appcompat:1.1.0' 34 | implementation 'androidx.gridlayout:gridlayout:1.0.0' 35 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 36 | implementation 'io.reactivex.rxjava2:rxjava:2.2.13' 37 | implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' 38 | implementation 'org.greenrobot:eventbus:3.1.1' 39 | implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.2' 40 | implementation project(':apptools') 41 | implementation project(':blemesh') 42 | } 43 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 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 22 | -------------------------------------------------------------------------------- /app/sign/espblemesh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/sign/espblemesh -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/app/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.app; 2 | 3 | import android.view.MenuItem; 4 | 5 | import androidx.appcompat.app.ActionBar; 6 | import androidx.appcompat.app.AppCompatActivity; 7 | 8 | public abstract class BaseActivity extends AppCompatActivity { 9 | protected void setHomeAsUpEnable(boolean enable) { 10 | ActionBar actionBar = getSupportActionBar(); 11 | if (actionBar != null) { 12 | actionBar.setDisplayHomeAsUpEnabled(enable); 13 | } 14 | } 15 | 16 | @Override 17 | public boolean onOptionsItemSelected(MenuItem item) { 18 | if (item.getItemId() == android.R.id.home) { 19 | onBackPressed(); 20 | return true; 21 | } else { 22 | return super.onOptionsItemSelected(item); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/constants/Constants.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.constants; 2 | 3 | import com.espressif.blemesh.constants.MeshConstants; 4 | import com.espressif.blemesh.utils.MeshUtils; 5 | 6 | public class Constants { 7 | public static final String KEY_SCAN_RESULT = "scan_result"; 8 | public static final String KEY_NODE_MAC = "node_mac"; 9 | public static final String KEY_NETWORK_INDEX = "network_index"; 10 | public static final String KEY_GROUP_ADDRESS = "group_address"; 11 | public static final String KEY_FAST_FROV = "fast_prov"; 12 | public static final String KEY_OTA_PACKAGE = "ota_package"; 13 | public static final String KEY_ID = "id"; 14 | public static final String KEY_NAME = "name"; 15 | 16 | public static final String KEY_NODE = "node"; 17 | public static final String KEY_MODEL = "model"; 18 | public static final String KEY_GROUPS = "groups"; 19 | public static final String KEY_BIND_GROUPS = "bind_groups"; 20 | public static final String KEY_OPERATION = "operation"; 21 | public static final String KEY_DST_ADDRESS = "dst_address"; 22 | public static final String KEY_MODEL_ID = "model_id"; 23 | 24 | public static final long APP_ADDRESS_DEFAULT = MeshConstants.APP_ADDRESS_DEFAULT; 25 | public static final long APP_KEY_INDEX_DEFAULT = MeshConstants.APP_KEY_INDEX_DEFAULT; 26 | 27 | public static final long NET_KEY_INDEX_DEFAULT = MeshConstants.NET_KEY_INDEX_DEFAULT; 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/GattCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus; 2 | 3 | public class GattCloseEvent { 4 | } 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/GattConnectionEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus; 2 | 3 | import android.bluetooth.BluetoothGatt; 4 | 5 | public class GattConnectionEvent { 6 | private BluetoothGatt mGatt; 7 | private int mStatus; 8 | private int mState; 9 | 10 | public GattConnectionEvent(BluetoothGatt gatt, int status, int state) { 11 | mGatt = gatt; 12 | mStatus = status; 13 | mState = state; 14 | } 15 | 16 | public BluetoothGatt getGatt() { 17 | return mGatt; 18 | } 19 | 20 | public int getState() { 21 | return mState; 22 | } 23 | 24 | public int getStatus() { 25 | return mStatus; 26 | } 27 | 28 | public boolean isConnected() { 29 | return mStatus == BluetoothGatt.GATT_SUCCESS && mState == BluetoothGatt.STATE_CONNECTED; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/GattNodeServiceEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus; 2 | 3 | import com.espressif.blemesh.client.IMeshMessager; 4 | 5 | public class GattNodeServiceEvent { 6 | private int mCode; 7 | private IMeshMessager mMessager; 8 | 9 | public GattNodeServiceEvent(int code, IMeshMessager messager) { 10 | mCode = code; 11 | mMessager = messager; 12 | } 13 | 14 | public int getCode() { 15 | return mCode; 16 | } 17 | 18 | public IMeshMessager getMessager() { 19 | return mMessager; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/blemesh/CompositionDataEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus.blemesh; 2 | 3 | public class CompositionDataEvent { 4 | private int mStatus; 5 | private int mPage; 6 | 7 | public CompositionDataEvent(int status, int page) { 8 | mStatus = status; 9 | mPage = page; 10 | } 11 | 12 | public int getStatus() { 13 | return mStatus; 14 | } 15 | 16 | public int getPage() { 17 | return mPage; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/blemesh/FastProvAddrEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus.blemesh; 2 | 3 | public class FastProvAddrEvent { 4 | private String mNodeMac; 5 | private long[] mAddrArray; 6 | 7 | public FastProvAddrEvent(String nodeMac, long[] addrArray) { 8 | mNodeMac = nodeMac; 9 | mAddrArray = addrArray; 10 | } 11 | 12 | public String getNodeMac() { 13 | return mNodeMac; 14 | } 15 | 16 | public long[] getAddrArray() { 17 | return mAddrArray; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/blemesh/LightCTLEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus.blemesh; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import java.util.Locale; 6 | 7 | public class LightCTLEvent { 8 | private int mLightness; 9 | private int mTemperature; 10 | private int mDeltaUV; 11 | 12 | public LightCTLEvent(int lightness, int temperature, int deltaUV) { 13 | mLightness = lightness; 14 | mTemperature = temperature; 15 | mDeltaUV = deltaUV; 16 | } 17 | 18 | public int getLightness() { 19 | return mLightness; 20 | } 21 | 22 | public int getTemperature() { 23 | return mTemperature; 24 | } 25 | 26 | public int getDeltaUV() { 27 | return mDeltaUV; 28 | } 29 | 30 | @NonNull 31 | @Override 32 | public String toString() { 33 | return String.format(Locale.ENGLISH, 34 | "LightCTLEvent >> Lightness:%d, Temperature:%d, DeltaUV:%d", 35 | mLightness, mTemperature, mDeltaUV); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/blemesh/LightHSLEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus.blemesh; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import java.util.Locale; 6 | 7 | public class LightHSLEvent { 8 | private float mHue; 9 | private float mSaturation; 10 | private float mLightness; 11 | 12 | public LightHSLEvent(float hue, float saturation, float lightness) { 13 | mHue = hue; 14 | mSaturation = saturation; 15 | mLightness = lightness; 16 | } 17 | 18 | public float getHue() { 19 | return mHue; 20 | } 21 | 22 | public float getSaturation() { 23 | return mSaturation; 24 | } 25 | 26 | public float getLightness() { 27 | return mLightness; 28 | } 29 | 30 | @NonNull 31 | @Override 32 | public String toString() { 33 | return String.format(Locale.ENGLISH, 34 | "LightHSLEvent >> Hue:%f, Saturation:%f, Lightness:%f", 35 | mHue, mSaturation, mLightness); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/blemesh/ModelAppEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus.blemesh; 2 | 3 | public class ModelAppEvent { 4 | private int mStatus; 5 | private long mAppKeyIndex; 6 | private String mNodeMac; 7 | private long mElementAddr; 8 | private String mModeId; 9 | 10 | public ModelAppEvent(int status, long appKeyIndex, String nodeMac, long elementAddr, String modeId) { 11 | mStatus = status; 12 | mAppKeyIndex = appKeyIndex; 13 | mNodeMac = nodeMac; 14 | mElementAddr = elementAddr; 15 | mModeId = modeId; 16 | } 17 | 18 | public int getStatus() { 19 | return mStatus; 20 | } 21 | 22 | public long getAppKeyIndex() { 23 | return mAppKeyIndex; 24 | } 25 | 26 | public String getNodeMac() { 27 | return mNodeMac; 28 | } 29 | 30 | public long getElementAddr() { 31 | return mElementAddr; 32 | } 33 | 34 | public String getModeId() { 35 | return mModeId; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/blemesh/ModelSubscriptionEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus.blemesh; 2 | 3 | public class ModelSubscriptionEvent { 4 | private int mStatus; 5 | private long mGroupAddr; 6 | private String mNodeMac; 7 | private long mElementAddr; 8 | private String mModelId; 9 | 10 | public ModelSubscriptionEvent(int status, long groupAddr, String nodeMac, long elementAddr, String modelId) { 11 | mStatus = status; 12 | mGroupAddr = groupAddr; 13 | mNodeMac = nodeMac; 14 | mElementAddr = elementAddr; 15 | mModelId = modelId; 16 | } 17 | 18 | public int getStatus() { 19 | return mStatus; 20 | } 21 | 22 | public long getGroupAddr() { 23 | return mGroupAddr; 24 | } 25 | 26 | public String getNodeMac() { 27 | return mNodeMac; 28 | } 29 | 30 | public long getElementAddr() { 31 | return mElementAddr; 32 | } 33 | 34 | public String getModelId() { 35 | return mModelId; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/blemesh/NodeResetEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus.blemesh; 2 | 3 | public class NodeResetEvent { 4 | public final long srcAddress; 5 | public final String nodeMac; 6 | 7 | public NodeResetEvent(long srcAddress, String nodeMac) { 8 | this.srcAddress = srcAddress; 9 | this.nodeMac = nodeMac; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/eventbus/blemesh/RelayEvent.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.eventbus.blemesh; 2 | 3 | public class RelayEvent { 4 | private int mState; 5 | private int mCount; 6 | private int mStep; 7 | 8 | public RelayEvent(int state, int count, int step) { 9 | mState = state; 10 | mCount = count; 11 | mStep = step; 12 | } 13 | 14 | public int getState() { 15 | return mState; 16 | } 17 | 18 | public int getCount() { 19 | return mCount; 20 | } 21 | 22 | public int getStep() { 23 | return mStep; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/model/BleScanResult.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.model; 2 | 3 | import android.bluetooth.le.ScanResult; 4 | 5 | public class BleScanResult { 6 | private ScanResult mScanResult; 7 | private long mScanTime; 8 | 9 | public BleScanResult() { 10 | } 11 | 12 | public BleScanResult(ScanResult scanResult, long scanTime) { 13 | mScanResult = scanResult; 14 | mScanTime = scanTime; 15 | } 16 | 17 | public void setScanResult(ScanResult scanResult) { 18 | mScanResult = scanResult; 19 | } 20 | 21 | public ScanResult getScanResult() { 22 | return mScanResult; 23 | } 24 | 25 | public void setScanTime(long scanTime) { 26 | mScanTime = scanTime; 27 | } 28 | 29 | public long getScanTime() { 30 | return mScanTime; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/model/BluetoothReceiver.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.model; 2 | 3 | import android.bluetooth.BluetoothAdapter; 4 | import android.content.BroadcastReceiver; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | 8 | public class BluetoothReceiver extends BroadcastReceiver { 9 | public static final String ACTION_STATE_CHANGED = BluetoothAdapter.ACTION_STATE_CHANGED; 10 | 11 | @Override 12 | public void onReceive(Context context, Intent intent) { 13 | final String action = intent.getAction(); 14 | if (action == null) { 15 | return; 16 | } 17 | 18 | switch (action) { 19 | case ACTION_STATE_CHANGED: { 20 | int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); 21 | switch (state) { 22 | case BluetoothAdapter.STATE_ON: 23 | onStateEnable(true); 24 | break; 25 | default: 26 | onStateEnable(false); 27 | break; 28 | } 29 | break; 30 | } 31 | 32 | } 33 | } 34 | 35 | public void onStateEnable(boolean enable) { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/model/FastGroup.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.HashSet; 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | public class FastGroup { 10 | private long mId; 11 | private String mName; 12 | 13 | private long mAddr; 14 | 15 | private final Set mNodeAddrs = new HashSet<>(); 16 | 17 | public void setId(long id) { 18 | mId = id; 19 | } 20 | 21 | public long getId() { 22 | return mId; 23 | } 24 | 25 | public void setName(String name) { 26 | mName = name; 27 | } 28 | 29 | public String getName() { 30 | return mName; 31 | } 32 | 33 | public void setAddr(long addr) { 34 | mAddr = addr; 35 | } 36 | 37 | public long getAddr() { 38 | return mAddr; 39 | } 40 | 41 | public void setNodeAddrs(Collection nodeAddrs) { 42 | synchronized (mNodeAddrs) { 43 | mNodeAddrs.clear(); 44 | mNodeAddrs.addAll(nodeAddrs); 45 | } 46 | } 47 | 48 | public List getNodeAddrs() { 49 | synchronized (mNodeAddrs) { 50 | return new ArrayList<>(mNodeAddrs); 51 | } 52 | } 53 | 54 | public void addNodeAddrs(Collection nodeAddrs) { 55 | synchronized (mNodeAddrs) { 56 | mNodeAddrs.addAll(nodeAddrs); 57 | } 58 | } 59 | 60 | public void removeNodeAddrs(Collection nodeAddrs) { 61 | synchronized (mNodeAddrs) { 62 | mNodeAddrs.removeAll(nodeAddrs); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/model/FastNode.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.model; 2 | 3 | public class FastNode { 4 | private long mAddr; 5 | private boolean mChecked; 6 | 7 | public void setAddr(long addr) { 8 | mAddr = addr; 9 | } 10 | 11 | public long getAddr() { 12 | return mAddr; 13 | } 14 | 15 | public void setChecked(boolean checked) { 16 | mChecked = checked; 17 | } 18 | 19 | public boolean isChecked() { 20 | return mChecked; 21 | } 22 | 23 | @Override 24 | public int hashCode() { 25 | return ((Long)mAddr).hashCode(); 26 | } 27 | 28 | @Override 29 | public boolean equals(Object obj) { 30 | if (obj instanceof FastNode) { 31 | return mAddr == ((FastNode)obj).getAddr(); 32 | } 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/ota/OTAUtils.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.ota; 2 | 3 | import com.espressif.blemesh.utils.MeshUtils; 4 | 5 | public class OTAUtils { 6 | public static String getSoftApSSID(String ssidInput, long nodeAddr) { 7 | if (ssidInput.getBytes().length != 2) { 8 | throw new IllegalArgumentException("SSID ssidInput bytes length must be 2"); 9 | } 10 | 11 | StringBuilder sb = new StringBuilder(ssidInput); 12 | byte[] addrBytes = MeshUtils.addressLongToBigEndianBytes(nodeAddr); 13 | for (byte b : addrBytes) { 14 | sb.append(getSoftApCharForByte(b)); 15 | } 16 | return sb.toString(); 17 | } 18 | 19 | public static String getSoftApPassword(String passworInput, String ssidInput, long nodeAddr) { 20 | if (passworInput.getBytes().length!= 2) { 21 | throw new IllegalArgumentException("Password input bytes length must be 2"); 22 | } 23 | if (ssidInput.getBytes().length != 2) { 24 | throw new IllegalArgumentException("SSID input bytes length must be 2"); 25 | } 26 | 27 | StringBuilder sb = new StringBuilder(passworInput); 28 | sb.append(ssidInput); 29 | byte[] addrBytes = MeshUtils.addressLongToBigEndianBytes(nodeAddr); 30 | for (byte b : addrBytes) { 31 | sb.append(getSoftApCharForByte(b)); 32 | } 33 | sb.append(passworInput); 34 | 35 | return sb.toString(); 36 | } 37 | 38 | private static char getSoftApCharForByte(byte b) { 39 | int i = b & 0xff; 40 | if (i >= 0x21 && i <= 0x7E) { 41 | return (char) i; 42 | } else { 43 | return (char) (i % 26 + 0x61); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/ui/network/SimpleMessageCallback.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.ui.network; 2 | 3 | import com.espressif.blemesh.client.callback.MessageCallback; 4 | 5 | public abstract class SimpleMessageCallback extends MessageCallback { 6 | public void onGattClosed() { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/ui/network/fastprov/FastGroupCreateActivity.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.ui.network.fastprov; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import androidx.annotation.Nullable; 6 | import androidx.appcompat.widget.Toolbar; 7 | import android.widget.Button; 8 | import android.widget.EditText; 9 | 10 | import com.espressif.blemesh.db.box.MeshObjectBox; 11 | import com.espressif.blemesh.db.entity.FastGroupDB; 12 | import com.espressif.blemesh.utils.MeshUtils; 13 | import com.espressif.espblemesh.R; 14 | import com.espressif.espblemesh.app.BaseActivity; 15 | import com.espressif.espblemesh.constants.Constants; 16 | 17 | import libs.espressif.utils.TextUtils; 18 | 19 | public class FastGroupCreateActivity extends BaseActivity { 20 | 21 | private EditText mGroupNameET; 22 | 23 | @Override 24 | protected void onCreate(@Nullable Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.fast_group_create_activity); 27 | Toolbar toolbar = findViewById(R.id.toolbar); 28 | setSupportActionBar(toolbar); 29 | setHomeAsUpEnable(true); 30 | 31 | mGroupNameET = findViewById(R.id.group_name); 32 | 33 | Button okBtn = findViewById(R.id.ok_btn); 34 | okBtn.setOnClickListener(v -> { 35 | String name = mGroupNameET.getText().toString(); 36 | if (TextUtils.isEmpty(name)) { 37 | mGroupNameET.setError(getString(R.string.group_name_error)); 38 | } else { 39 | mGroupNameET.setError(null); 40 | 41 | long groupAddr = MeshUtils.generateGroupAddress(); 42 | FastGroupDB db = new FastGroupDB(); 43 | db.name = name; 44 | db.addr = groupAddr; 45 | long id = MeshObjectBox.getInstance().addOrUpdateFastGroup(db); 46 | Intent data = new Intent(); 47 | data.putExtra(Constants.KEY_ID, id); 48 | data.putExtra(Constants.KEY_NAME, name); 49 | data.putExtra(Constants.KEY_GROUP_ADDRESS, groupAddr); 50 | setResult(RESULT_OK, data); 51 | finish(); 52 | } 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/ui/network/node/OperationActivity.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.ui.network.node; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | 6 | import androidx.annotation.Nullable; 7 | import androidx.appcompat.widget.Toolbar; 8 | 9 | import com.espressif.blemesh.constants.MeshConstants; 10 | import com.espressif.blemesh.model.Model; 11 | import com.espressif.blemesh.model.Node; 12 | import com.espressif.espblemesh.R; 13 | import com.espressif.espblemesh.app.BaseActivity; 14 | import com.espressif.espblemesh.app.MeshApp; 15 | import com.espressif.espblemesh.constants.Constants; 16 | import com.espressif.espblemesh.eventbus.GattConnectionEvent; 17 | 18 | import org.greenrobot.eventbus.EventBus; 19 | import org.greenrobot.eventbus.Subscribe; 20 | import org.greenrobot.eventbus.ThreadMode; 21 | 22 | public class OperationActivity extends BaseActivity { 23 | 24 | @Override 25 | protected void onCreate(@Nullable Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.operation_activity); 28 | Toolbar toolbar = findViewById(R.id.toolbar); 29 | setSupportActionBar(toolbar); 30 | setHomeAsUpEnable(true); 31 | 32 | Intent intent = getIntent(); 33 | MeshApp app = MeshApp.getInstance(); 34 | Node node = (Node) app.takeCacheForIntentKey(intent, Constants.KEY_NODE); 35 | Long dstAddress = (Long) app.takeCacheForIntentKey(intent, Constants.KEY_DST_ADDRESS); 36 | String modelId = (String) app.takeCacheForIntentKey(intent, Constants.KEY_MODEL_ID); 37 | 38 | OperationFragment fragment; 39 | switch (modelId) { 40 | case MeshConstants.MODEL_ID_HSL: 41 | fragment = new OperationLightHSLFragment(); 42 | break; 43 | case MeshConstants.MODEL_ID_CTL: 44 | fragment = new OperationLightCTLFragment(); 45 | break; 46 | default: 47 | throw new IllegalArgumentException("Unsupported model"); 48 | } 49 | 50 | fragment.setArgs(dstAddress, node); 51 | getSupportFragmentManager().beginTransaction().replace(R.id.fragment_form, fragment).commit(); 52 | 53 | EventBus.getDefault().register(this); 54 | } 55 | 56 | @Override 57 | protected void onDestroy() { 58 | super.onDestroy(); 59 | 60 | EventBus.getDefault().unregister(this); 61 | } 62 | 63 | @Subscribe(threadMode = ThreadMode.MAIN) 64 | public void onGattConnectionEvent(GattConnectionEvent event) { 65 | if (!event.isConnected()) { 66 | finish(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/ui/network/node/OperationFragment.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.ui.network.node; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.Nullable; 6 | import androidx.fragment.app.Fragment; 7 | 8 | import com.espressif.blemesh.model.Model; 9 | import com.espressif.blemesh.model.Node; 10 | import com.espressif.espblemesh.model.MeshConnection; 11 | 12 | public class OperationFragment extends Fragment { 13 | protected Node mNode; 14 | protected long mDstAddress; 15 | 16 | protected MeshConnection mMeshConnection; 17 | 18 | @Override 19 | public void onCreate(@Nullable Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | 22 | mMeshConnection = MeshConnection.Instance; 23 | } 24 | 25 | public void setArgs(long dstAddress, Node node) { 26 | mDstAddress = dstAddress; 27 | mNode = node; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/ui/network/node/OperationLightCTLFragment.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.ui.network.node; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.Button; 8 | import android.widget.EditText; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.annotation.Nullable; 12 | 13 | import com.espressif.espblemesh.R; 14 | 15 | import libs.espressif.utils.TextUtils; 16 | 17 | public class OperationLightCTLFragment extends OperationFragment { 18 | @Nullable 19 | @Override 20 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 21 | View view = inflater.inflate(R.layout.operation_light_ctl_content, container, false); 22 | EditText lightnessET = view.findViewById(R.id.lightness_edit); 23 | EditText temperatureET = view.findViewById(R.id.temperature_edit); 24 | EditText deltaUVET = view.findViewById(R.id.delta_uv_edit); 25 | Button okBtn = view.findViewById(R.id.ok_btn); 26 | okBtn.setOnClickListener(v -> { 27 | String lightnessStr = lightnessET.getText().toString(); 28 | if (TextUtils.isEmpty(lightnessStr)) { 29 | return; 30 | } 31 | String temperatureStr = temperatureET.getText().toString(); 32 | if (TextUtils.isEmpty(temperatureStr)) { 33 | return; 34 | } 35 | String deltaUVStr = deltaUVET.getText().toString(); 36 | if (TextUtils.isEmpty(deltaUVStr)) { 37 | return; 38 | } 39 | 40 | v.setEnabled(false); 41 | int lightness = Integer.parseInt(lightnessStr); 42 | int temperature = Integer.parseInt(temperatureStr); 43 | int deltaUV = Integer.parseInt(deltaUVStr); 44 | mMeshConnection.setLightCTL(lightness, temperature, deltaUV, mNode, mDstAddress); 45 | }); 46 | 47 | return view; 48 | } 49 | 50 | @Override 51 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 52 | super.onActivityCreated(savedInstanceState); 53 | 54 | getActivity().setTitle("Light CTL"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/ui/network/ota/OTAPackage.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.ui.network.ota; 2 | 3 | import android.bluetooth.BluetoothGattCallback; 4 | 5 | import com.espressif.blemesh.client.IMeshMessager; 6 | import com.espressif.blemesh.model.Node; 7 | import com.espressif.espblemesh.ui.network.SimpleMessageCallback; 8 | 9 | public class OTAPackage { 10 | public Node node; 11 | public IMeshMessager messager; 12 | public SimpleMessageCallback messageCB; 13 | public BluetoothGattCallback gattCB; 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/ui/settings/SettingsActivity.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.ui.settings; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.os.Bundle; 6 | import android.preference.PreferenceManager; 7 | 8 | import androidx.annotation.Nullable; 9 | import androidx.appcompat.widget.Toolbar; 10 | 11 | import com.espressif.espblemesh.R; 12 | import com.espressif.espblemesh.app.BaseActivity; 13 | import com.espressif.espblemesh.constants.Constants; 14 | 15 | public class SettingsActivity extends BaseActivity implements SettingsConstants { 16 | @Override 17 | protected void onCreate(@Nullable Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.settings_activity); 20 | Toolbar toolbar = findViewById(R.id.toolbar); 21 | setSupportActionBar(toolbar); 22 | setHomeAsUpEnable(true); 23 | 24 | getFragmentManager().beginTransaction() 25 | .replace(R.id.frame, new SettingsFragment()) 26 | .commit(); 27 | } 28 | 29 | public static long getUsedAppKeyIndex(Context context) { 30 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); 31 | String appKeyIndexDef = String.valueOf(Constants.APP_KEY_INDEX_DEFAULT); 32 | String keyIndexStr = sharedPreferences.getString(KEY_APP_USED, appKeyIndexDef); 33 | if (keyIndexStr == null) { 34 | keyIndexStr = appKeyIndexDef; 35 | } 36 | return Long.parseLong(keyIndexStr); 37 | } 38 | 39 | public static int getMessagePostCount(Context context) { 40 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); 41 | String postCountStr = sharedPreferences.getString(KEY_MESSAGE_POST_COUNT, MESSAGE_POST_COUNT_DEFAULT); 42 | if (postCountStr == null) { 43 | postCountStr = MESSAGE_POST_COUNT_DEFAULT; 44 | } 45 | return Integer.parseInt(postCountStr); 46 | } 47 | 48 | public static long getMessageBackpressure(Context context) { 49 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); 50 | String backpressureStr = sharedPreferences.getString(KEY_MESSAGE_BACKPRESSURE, MESSAGE_BACKPRESSURE_DEFAULT); 51 | if (backpressureStr == null) { 52 | backpressureStr = MESSAGE_BACKPRESSURE_DEFAULT; 53 | } 54 | return Long.parseLong(backpressureStr); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/ui/settings/SettingsConstants.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.ui.settings; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.preference.PreferenceManager; 6 | 7 | import com.espressif.espblemesh.constants.Constants; 8 | 9 | public interface SettingsConstants { 10 | String KEY_VERSION = "settings_version_key"; 11 | String KEY_VERSION_CHECK = "settings_version_check_key"; 12 | 13 | String KEY_APP_NEW = "settings_app_new_key"; 14 | String KEY_APP_DELETE = "settings_app_delete_key"; 15 | String KEY_APP_USED = "settings_app_used_key"; 16 | 17 | String KEY_MESSAGE_POST_COUNT = "settings_message_post_count_key"; 18 | String KEY_MESSAGE_BACKPRESSURE = "settings_message_backpressure_key"; 19 | 20 | String MESSAGE_POST_COUNT_DEFAULT = "3"; 21 | String MESSAGE_BACKPRESSURE_DEFAULT = "300"; 22 | 23 | String GITHUB_ACCOUNT = "EspressifApp"; 24 | String GITHUB_REPOSITORY = "EspBLEMeshForAndroid"; 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/espressif/espblemesh/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package com.espressif.espblemesh.utils; 2 | 3 | import android.bluetooth.le.ScanRecord; 4 | import android.bluetooth.le.ScanResult; 5 | 6 | public class Utils { 7 | public static String getBLEDeviceName(ScanResult sr) { 8 | String name = sr.getDevice().getName();; 9 | if (name == null) { 10 | ScanRecord record = sr.getScanRecord(); 11 | if (record != null) { 12 | name = record.getDeviceName(); 13 | } 14 | } 15 | 16 | return name; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/fast_switch_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/src/main/res/drawable-hdpi/fast_switch_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/fast_switch_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/src/main/res/drawable-hdpi/fast_switch_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/fast_switch_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/src/main/res/drawable-hdpi/fast_switch_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/fast_switch_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/src/main/res/drawable-xhdpi/fast_switch_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/fast_switch_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/src/main/res/drawable-xhdpi/fast_switch_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/fast_switch_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/src/main/res/drawable-xhdpi/fast_switch_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/fast_switch_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/src/main/res/drawable-xxhdpi/fast_switch_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/fast_switch_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/src/main/res/drawable-xxhdpi/fast_switch_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/fast_switch_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EspressifApp/EspBLEMeshForAndroid/e87b18a04dda86bd69844054252d8dbbf9974f8e/app/src/main/res/drawable-xxhdpi/fast_switch_on.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_expand_less_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_expand_more_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_grain_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_unfold_less_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_unfold_more_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/color_button_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/fast_switch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_box_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_circle_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_circle_outline_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_bluetooth_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_bluetooth_connected_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_bluetooth_connecting_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_bluetooth_disabled_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_color_lens_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_delete_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_device_hub_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_edit_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_filter_list_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_lightbulb_outline_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_more_horiz_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_refresh.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_remove_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_remove_circle_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_remove_circle_outline_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_settings_ethernet_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/outline_add_box_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/outline_info_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/outline_settings_applications_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/outline_share_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fast_group_create_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 28 | 29 | 34 | 35 | 41 | 42 |