JLChen
2021-03-16 3617e6eecac94965554487afc50d39b0584324fb
2021-03-16 1.备份
91个文件已添加
1个文件已修改
7033 ■■■■■ 已修改文件
.gitignore 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/misc.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.project 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.settings/org.eclipse.buildship.core.prefs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/.classpath 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/.project 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/.settings/org.eclipse.buildship.core.prefs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/build.gradle 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/AndroidManifest.xml 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/.idea/.name 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/.idea/compiler.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/.idea/copyright/profiles_settings.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/.idea/encodings.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/.idea/misc.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/.idea/modules.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/.idea/scopes/scope_settings.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/.idea/workspace.xml 233 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/SerialPort.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/SerialPortFinder.java 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/Application.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/ConsoleActivity.java 694 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/Fragment_BUS.java 500 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/Fragment_KNX.java 333 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/Fragment_Update.java 521 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/Global.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/Inductor.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/KNX.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/KNX_ReceiveAndSend.java 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/KNX_Serialport.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/MainActivity.java 244 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/MyFragmentAdapter.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/MyService.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/NavigationDrawerFragment.java 174 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/ReceiveAndSend.java 400 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/SPDataSet.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/android/serialport/api/sample/SerialPortPreferences.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/sendData/CRC.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/sendData/Commands.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/sendData/SendDatas.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/jni/Android.mk 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/jni/android_serialport_api_SerialPort.c 244 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/jni/android_serialport_api_SerialPort.h 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/jni/android_serialport_api_sample_KNX.c 244 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/jni/android_serialport_api_sample_KNX.h 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/jni/sun8iw6p_display.h 429 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/libs/android-support-v4.jar 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/libs/armeabi/libserial_port.so 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-hdpi/ic_launcher.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-hdpi/off.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-hdpi/on.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-hdpi/poweroff.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-hdpi/poweron.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-hdpi/selected.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-hdpi/unselected.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-ldpi/ic_launcher.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-ldpi/setting.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable-mdpi/ic_launcher.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/btn_rounded.xml 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/gray_thumb.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/gray_track.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/green_thumb.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/green_track.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/light.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/light_def.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/line.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/line_white.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/my_seekbar_normal.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/my_seekbar_pressed.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/my_seekbar_thumb_normal.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/my_seekbar_thumb_pressed.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/seekbar_color_style.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/thumb.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/track.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_main.xml 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/console.xml 403 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/dialog_pro.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/fragment_knx.xml 395 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/fragment_navigation.xml 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/fragment_upgrade.xml 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/tab.xml 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/values/baudrates.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/values/colors.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/values/strings.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/values/styles.xml 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/xml/serial_port_preferences.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
build.gradle 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
gradle/wrapper/gradle-wrapper.jar 补丁 | 查看 | 原始文档 | blame | 历史
gradle/wrapper/gradle-wrapper.properties 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
gradlew 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
gradlew.bat 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
import-summary.txt 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
settings.gradle 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -1,8 +1,14 @@
# Created by https://www.gitignore.io/api/android
# Edit at https://www.gitignore.io/?templates=android
### Android ###
# Built application files
*.apk
*.ap_
*.aab
# Files for the Dalvik VM
# Files for the ART/Dalvik VM
*.dex
# Java class files
@@ -11,6 +17,8 @@
# Generated files
bin/
gen/
out/
release/
# Gradle files
.gradle/
@@ -22,5 +30,64 @@
# Proguard folder generated by Eclipse
proguard/
#Log Files
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
### Android Patch ###
gen-external-apklibs
output.json
# End of https://www.gitignore.io/api/android
.idea/misc.xml
New file
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
    <output url="file://$PROJECT_DIR$/build/classes" />
  </component>
  <component name="ProjectType">
    <option name="id" value="Android" />
  </component>
</project>
.project
New file
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>TTL</name>
    <comment>Project TTL created by Buildship.</comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
    </natures>
</projectDescription>
.settings/org.eclipse.buildship.core.prefs
New file
@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1
app/.classpath
New file
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
    <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
    <classpathentry kind="output" path="bin/default"/>
</classpath>
app/.project
New file
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>app</name>
    <comment>Project app created by Buildship.</comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
    </natures>
</projectDescription>
app/.settings/org.eclipse.buildship.core.prefs
New file
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
app/build.gradle
New file
@@ -0,0 +1,39 @@
apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "android.serialport.api.sample"
        minSdkVersion 17
        targetSdkVersion 27
        ndk {
            moduleName "serial_port"
            abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        sourceSets{
            main {
//                jni.srcDirs = []
                jni.srcDirs = []
                jniLibs.srcDirs = ['src/main/jniLibs']
                jniLibs.srcDirs = ['libs']
            }
        }
    }
}
dependencies {
    implementation fileTree(include: ['*.jar','*.so'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
}
app/src/main/AndroidManifest.xml
New file
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="android.serialport.api.sample"
    android:versionCode="4"
    android:versionName="18.2.5" >
    <supports-screens android:anyDensity="true" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <application
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="android.serialport.api.sample.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="landscape"
            android:windowSoftInputMode="stateHidden" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="SerialPortPreferences" />
        <activity android:name="SendingActivity" />
        <service android:name="android.serialport.api.sample.MyService" />
    </application>
</manifest>
app/src/main/assets/.idea/.name
New file
@@ -0,0 +1 @@
assets
app/src/main/assets/.idea/compiler.xml
New file
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="CompilerConfiguration">
    <option name="DEFAULT_COMPILER" value="Javac" />
    <resourceExtensions />
    <wildcardResourcePatterns>
      <entry name="!?*.java" />
      <entry name="!?*.form" />
      <entry name="!?*.class" />
      <entry name="!?*.groovy" />
      <entry name="!?*.scala" />
      <entry name="!?*.flex" />
      <entry name="!?*.kt" />
      <entry name="!?*.clj" />
    </wildcardResourcePatterns>
    <annotationProcessing>
      <profile default="true" name="Default" enabled="false">
        <processorPath useClasspath="true" />
      </profile>
    </annotationProcessing>
  </component>
</project>
app/src/main/assets/.idea/copyright/profiles_settings.xml
New file
@@ -0,0 +1,3 @@
<component name="CopyrightManager">
  <settings default="" />
</component>
app/src/main/assets/.idea/encodings.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
app/src/main/assets/.idea/misc.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" />
</project>
app/src/main/assets/.idea/modules.xml
New file
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectModuleManager">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/.idea/assets.iml" filepath="$PROJECT_DIR$/.idea/assets.iml" />
    </modules>
  </component>
</project>
app/src/main/assets/.idea/scopes/scope_settings.xml
New file
@@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
  <state>
    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
  </state>
</component>
app/src/main/assets/.idea/workspace.xml
New file
@@ -0,0 +1,233 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ChangeListManager">
    <list default="true" id="adeba4c9-7cf4-4d05-a43f-f46103178e18" name="Default" comment="" />
    <ignored path="assets.iws" />
    <ignored path=".idea/workspace.xml" />
    <option name="TRACKING_ENABLED" value="true" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
  <component name="CreatePatchCommitExecutor">
    <option name="PATCH_PATH" value="" />
  </component>
  <component name="DaemonCodeAnalyzer">
    <disable_hints />
  </component>
  <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
  <component name="FavoritesManager">
    <favorites_list name="assets" />
  </component>
  <component name="ProjectFrameBounds">
    <option name="x" value="188" />
    <option name="y" value="77" />
    <option name="width" value="1260" />
    <option name="height" value="760" />
  </component>
  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
    <OptionsSetting value="true" id="Add" />
    <OptionsSetting value="true" id="Remove" />
    <OptionsSetting value="true" id="Checkout" />
    <OptionsSetting value="true" id="Update" />
    <OptionsSetting value="true" id="Status" />
    <OptionsSetting value="true" id="Edit" />
    <ConfirmationsSetting value="0" id="Add" />
    <ConfirmationsSetting value="0" id="Remove" />
  </component>
  <component name="ProjectReloadState">
    <option name="STATE" value="0" />
  </component>
  <component name="ProjectView">
    <navigator currentView="ProjectPane" proportions="" version="1">
      <flattenPackages />
      <showMembers />
      <showModules />
      <showLibraryContents />
      <hideEmptyPackages />
      <abbreviatePackageNames />
      <autoscrollToSource />
      <autoscrollFromSource />
      <sortByType />
    </navigator>
    <panes>
      <pane id="PackagesPane" />
      <pane id="Scope" />
      <pane id="AndroidView">
        <subPane />
      </pane>
      <pane id="ProjectPane">
        <subPane>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="assets" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
          </PATH>
        </subPane>
      </pane>
    </panes>
  </component>
  <component name="PropertiesComponent">
    <property name="GoToClass.includeLibraries" value="false" />
    <property name="GoToClass.toSaveIncludeLibraries" value="false" />
    <property name="GoToFile.includeJavaFiles" value="false" />
    <property name="MemberChooser.sorted" value="false" />
    <property name="MemberChooser.showClasses" value="true" />
    <property name="MemberChooser.copyJavadoc" value="false" />
    <property name="options.lastSelected" value="copyright" />
    <property name="options.splitter.main.proportions" value="0.3" />
    <property name="options.splitter.details.proportions" value="0.2" />
    <property name="options.searchVisible" value="true" />
    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
  </component>
  <component name="RunManager">
    <configuration default="true" type="Remote" factoryName="Remote">
      <option name="USE_SOCKET_TRANSPORT" value="true" />
      <option name="SERVER_MODE" value="false" />
      <option name="SHMEM_ADDRESS" value="javadebug" />
      <option name="HOST" value="localhost" />
      <option name="PORT" value="5005" />
      <method />
    </configuration>
    <configuration default="true" type="TestNG" factoryName="TestNG">
      <module name="" />
      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
      <option name="ALTERNATIVE_JRE_PATH" />
      <option name="SUITE_NAME" />
      <option name="PACKAGE_NAME" />
      <option name="MAIN_CLASS_NAME" />
      <option name="METHOD_NAME" />
      <option name="GROUP_NAME" />
      <option name="TEST_OBJECT" value="CLASS" />
      <option name="VM_PARAMETERS" value="-ea" />
      <option name="PARAMETERS" />
      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
      <option name="OUTPUT_DIRECTORY" />
      <option name="ANNOTATION_TYPE" />
      <option name="ENV_VARIABLES" />
      <option name="PASS_PARENT_ENVS" value="true" />
      <option name="TEST_SEARCH_SCOPE">
        <value defaultName="moduleWithDependencies" />
      </option>
      <option name="USE_DEFAULT_REPORTERS" value="false" />
      <option name="PROPERTIES_FILE" />
      <envs />
      <properties />
      <listeners />
      <method />
    </configuration>
    <configuration default="true" type="Application" factoryName="Application">
      <option name="MAIN_CLASS_NAME" />
      <option name="VM_PARAMETERS" />
      <option name="PROGRAM_PARAMETERS" />
      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
      <option name="ALTERNATIVE_JRE_PATH" />
      <option name="ENABLE_SWING_INSPECTOR" value="false" />
      <option name="ENV_VARIABLES" />
      <option name="PASS_PARENT_ENVS" value="true" />
      <module name="" />
      <envs />
      <method />
    </configuration>
    <configuration default="true" type="JUnit" factoryName="JUnit">
      <module name="" />
      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
      <option name="ALTERNATIVE_JRE_PATH" />
      <option name="PACKAGE_NAME" />
      <option name="MAIN_CLASS_NAME" />
      <option name="METHOD_NAME" />
      <option name="TEST_OBJECT" value="class" />
      <option name="VM_PARAMETERS" value="-ea" />
      <option name="PARAMETERS" />
      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
      <option name="ENV_VARIABLES" />
      <option name="PASS_PARENT_ENVS" value="true" />
      <option name="TEST_SEARCH_SCOPE">
        <value defaultName="moduleWithDependencies" />
      </option>
      <envs />
      <patterns />
      <method />
    </configuration>
    <list size="0" />
    <configuration name="&lt;template&gt;" type="Applet" default="true" selected="false">
      <option name="MAIN_CLASS_NAME" />
      <option name="HTML_FILE_NAME" />
      <option name="HTML_USED" value="false" />
      <option name="WIDTH" value="400" />
      <option name="HEIGHT" value="300" />
      <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
      <option name="VM_PARAMETERS" />
    </configuration>
    <configuration name="&lt;template&gt;" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" default="true" selected="false">
      <option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
    </configuration>
    <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
      <Host>localhost</Host>
      <Port>5050</Port>
    </configuration>
  </component>
  <component name="ShelveChangesManager" show_recycled="false" />
  <component name="TaskManager">
    <task active="true" id="Default" summary="Default task">
      <changelist id="adeba4c9-7cf4-4d05-a43f-f46103178e18" name="Default" comment="" />
      <created>1447815009584</created>
      <updated>1447815009584</updated>
    </task>
    <servers />
  </component>
  <component name="ToolWindowManager">
    <frame x="188" y="77" width="1260" height="760" extended-state="0" />
    <editor active="false" />
    <layout>
      <window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Gradle Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.24958949" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24958949" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Memory Monitor" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
    </layout>
  </component>
  <component name="Vcs.Log.UiProperties">
    <option name="RECENTLY_FILTERED_USER_GROUPS">
      <collection />
    </option>
    <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
      <collection />
    </option>
  </component>
  <component name="VcsContentAnnotationSettings">
    <option name="myLimit" value="2678400000" />
  </component>
  <component name="VcsManagerConfiguration">
    <option name="myTodoPanelSettings">
      <TodoPanelSettings />
    </option>
  </component>
  <component name="XDebuggerManager">
    <breakpoint-manager />
  </component>
</project>
app/src/main/java/android/serialport/api/SerialPort.java
New file
@@ -0,0 +1,90 @@
/*
 * Copyright 2009 Cedric Priscal
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.serialport.api;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.util.Log;
public class SerialPort {
    private static final String TAG = "SerialPort";
    /*
     * Do not remove or rename the field mFd: it is used by native method
     * close();
     */
    private FileDescriptor mFd;
    private FileInputStream mFileInputStream;
    private FileOutputStream mFileOutputStream;
    public SerialPort(File device, int baudrate, int flags) throws SecurityException, IOException {
        /* Check access permission */
        if (!device.canRead() || !device.canWrite()) {
            try {
                /* Missing read/write permission, trying to chmod the file */
                Process su;
                su = Runtime.getRuntime().exec("/system/bin/su");
                String cmd = "chmod 666 " + device.getAbsolutePath() + "\n" + "exit\n";
                su.getOutputStream().write(cmd.getBytes());
                if ((su.waitFor() != 0) || !device.canRead() || !device.canWrite()) {
                    throw new SecurityException();
                }
            } catch (Exception e) {
                e.printStackTrace();
                throw new SecurityException();
            }
        }
        mFd = open(device.getAbsolutePath(), baudrate, flags);
        if (mFd == null) {
            Log.e(TAG, "native open returns null");
            throw new IOException();
        }
        mFileInputStream = new FileInputStream(mFd);
        mFileOutputStream = new FileOutputStream(mFd);
    }
    // Getters and setters
    public InputStream getInputStream() {
        return mFileInputStream;
    }
    public OutputStream getOutputStream() {
        return mFileOutputStream;
    }
    // JNI
    private native static FileDescriptor open(String path, int baudrate, int flags);
    public native void close();
    public static native int BackLight_ON();
    public static native int BackLight_OFF();
    static {
        System.loadLibrary("serial_port");
    }
}
app/src/main/java/android/serialport/api/SerialPortFinder.java
New file
@@ -0,0 +1,127 @@
/*
 * Copyright 2009 Cedric Priscal
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.serialport.api;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
import java.util.Iterator;
import java.util.Vector;
import android.util.Log;
public class SerialPortFinder {
    public class Driver {
        public Driver(String name, String root) {
            mDriverName = name;
            mDeviceRoot = root;
        }
        private String mDriverName;
        private String mDeviceRoot;
        Vector<File> mDevices = null;
        public Vector<File> getDevices() {
            if (mDevices == null) {
                mDevices = new Vector<File>();
                File dev = new File("/dev");
                File[] files = dev.listFiles();
                int i;
                for (i = 0; i < files.length; i++) {
                    if (files[i].getAbsolutePath().startsWith(mDeviceRoot)) {
                        Log.d(TAG, "Found new device: " + files[i]);
                        mDevices.add(files[i]);
                    }
                }
            }
            return mDevices;
        }
        public String getName() {
            return mDriverName;
        }
    }
    private static final String TAG = "SerialPort";
    private Vector<Driver> mDrivers = null;
    Vector<Driver> getDrivers() throws IOException {
        if (mDrivers == null) {
            mDrivers = new Vector<Driver>();
            LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
            String l;
            while ((l = r.readLine()) != null) {
                // Issue 3:
                // Since driver name may contain spaces, we do not extract
                // driver name with split()
                String drivername = l.substring(0, 0x15).trim();
                String[] w = l.split(" +");
                if ((w.length >= 5) && (w[w.length - 1].equals("serial"))) {
                    Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length - 4]);
                    // mDrivers.add(new Driver(drivername, w[w.length-4]));
                    mDrivers.add(new Driver(drivername, w[w.length - 4]));
                }
            }
            r.close();
        }
        return mDrivers;
    }
    public String[] getAllDevices() {
        Vector<String> devices = new Vector<String>();
        // Parse each driver
        Iterator<Driver> itdriv;
        try {
            itdriv = getDrivers().iterator();
            while (itdriv.hasNext()) {
                Driver driver = itdriv.next();
                Iterator<File> itdev = driver.getDevices().iterator();
                while (itdev.hasNext()) {
                    String device = itdev.next().getName();
                    String value = String.format("%s (%s)", device, driver.getName());
                    devices.add(value);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return devices.toArray(new String[devices.size()]);
    }
    public String[] getAllDevicesPath() {
        Vector<String> devices = new Vector<String>();
        // Parse each driver
        Iterator<Driver> itdriv;
        try {
            itdriv = getDrivers().iterator();
            while (itdriv.hasNext()) {
                Driver driver = itdriv.next();
                Iterator<File> itdev = driver.getDevices().iterator();
                while (itdev.hasNext()) {
                    String device = itdev.next().getAbsolutePath();
                    devices.add(device);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return devices.toArray(new String[devices.size()]);
    }
}
app/src/main/java/android/serialport/api/sample/Application.java
New file
@@ -0,0 +1,46 @@
/*
 * Copyright 2009 Cedric Priscal
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.serialport.api.sample;
import java.io.File;
import java.io.IOException;
import java.security.InvalidParameterException;
import android.serialport.api.SerialPort;
import android.serialport.api.SerialPortFinder;
public class Application {
    public SerialPortFinder mSerialPortFinder = new SerialPortFinder();
    private SerialPort mSerialPort = null;
    public SerialPort getSerialPort() throws SecurityException, IOException, InvalidParameterException {
        if (mSerialPort == null) {
            mSerialPort = new SerialPort(new File("/dev/ttyS1"), 115200, 0);
        }
        return mSerialPort;
    }
    public void closeSerialPort() {
        if (mSerialPort != null) {
            mSerialPort.close();
            mSerialPort = null;
        }
    }
}
app/src/main/java/android/serialport/api/sample/ConsoleActivity.java
New file
@@ -0,0 +1,694 @@
/*
 * Copyright 2009 Cedric Priscal
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.serialport.api.sample;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import sendData.Commands;
import sendData.SendDatas;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnClickListener;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.serialport.api.SerialPort;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import android.serialport.api.sample.R;
import android.util.Log;
import android.widget.Switch;
public class ConsoleActivity extends Activity {
    public static final int INDUCTOR_LEAVE = 1;
    private List<byte[]> SendDatasList = new ArrayList<byte[]>();
    private TextView Seekbar_value;
    private EditText T_TextView;
    private EditText key_state;
    private EditText c_value;
    private Switch loop1Button;
    private Switch loop2Button;
    private Switch loop3Button;
    private Switch loop4Button;
    private Switch powerButton;
    private Switch openBackLight;
    private RadioButton radioButton1;
    private RadioButton radioButton2;
    private RadioButton radioButton3;
    private RadioButton radioButton4;
    private RadioButton radioButton5;
    private RadioButton radioButton6;
    private SeekBar SSeekbar;
    private static Button Btn_state;
    private Button C_Btn;
    protected Application mApplication;
    protected SerialPort mSerialPort;
    protected OutputStream mOutputStream;
    private InputStream mInputStream;
    private ReadThread mReadThread;
    int id = -1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.console);
        iniView();
        iniData();
    }
    private void iniView() {
        c_value = (EditText) findViewById(R.id.c_value);
        T_TextView = (EditText) findViewById(R.id.Temperature);
        key_state = (EditText) findViewById(R.id.key_status);
        Seekbar_value = (TextView) findViewById(R.id.seekbar_value);
        loop1Button = (Switch) findViewById(R.id.loopId1);
        loop1Button.setTag("0");
        loop1Button.setOnClickListener(onClick);
        loop2Button = (Switch) findViewById(R.id.loopId2);
        loop2Button.setTag("0");
        loop2Button.setOnClickListener(onClick);
        loop3Button = (Switch) findViewById(R.id.loopId3);
        loop3Button.setTag("0");
        loop3Button.setOnClickListener(onClick);
        loop4Button = (Switch) findViewById(R.id.loopId4);
        loop4Button.setTag("0");
        loop4Button.setOnClickListener(onClick);
        powerButton = (Switch) findViewById(R.id.powerButton);
        powerButton.setTag("Off");
        powerButton.setOnClickListener(powerOnClick);
        radioButton1 = (RadioButton) findViewById(R.id.radioButton1);
        radioButton2 = (RadioButton) findViewById(R.id.radioButton2);
        radioButton3 = (RadioButton) findViewById(R.id.radioButton3);
        radioButton4 = (RadioButton) findViewById(R.id.radioButton4);
        radioButton5 = (RadioButton) findViewById(R.id.radioButton5);
        radioButton6 = (RadioButton) findViewById(R.id.radioButton6);
        openBackLight = (Switch) findViewById(R.id.openbacklight);
        openBackLight.setTag("1");
        openBackLight.setChecked(true);
        openBackLight.setOnClickListener(backLightOnClick);
        Btn_state = (Button) findViewById(R.id.btn_state);
        Btn_state.setTag(new Inductor());
        Btn_state.setBackground(null);
        C_Btn = (Button) findViewById(R.id.c_btn);
        C_Btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 设置补偿值
                try {
                    int _value = Integer.parseInt(c_value.getText().toString());
                    byte[] sendBytes = SendDatas.AddSendData(Commands.SET_TEMP_COMPENSATE_VALUE.getCommand(), 250, 250,
                            new byte[] { (byte) 1, (byte) 0, (byte) (_value + 10) });
                    SendDatasList.add(sendBytes);
                    SharedPreferences SP = ConsoleActivity.this.getSharedPreferences("Serialport",
                            ConsoleActivity.this.MODE_PRIVATE);
                    SharedPreferences.Editor editor = SP.edit();
                    editor.putInt("c_value", _value);
                    editor.commit();
                    editor.apply();
                    InputMethodManager imm = (InputMethodManager) getSystemService(
                            ConsoleActivity.this.INPUT_METHOD_SERVICE);
                    // 得到InputMethodManager的实例
                    if (imm.isActive()) {
                        // 如果开启
                        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
                        // 关闭软键盘,开启方法相同,这个方法是切换开启与关闭状态的
                    }
                } catch (Exception e) {
                }
            }
        });
        SSeekbar = (SeekBar) findViewById(R.id.set_sensitivity);
        SSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // 写
                int _value = seekBar.getProgress();
                byte[] sendBytes = SendDatas.AddSendData(Commands.Sensor.getCommand(), 250, 250,
                        new byte[] { 1, (byte) _value });
                SendDatasList.add(sendBytes);
            }
            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                Seekbar_value.setText(progress + "");
            }
        });
    }
    private int getC_value() {
        SharedPreferences SP = this.getSharedPreferences("Serialport", this.MODE_PRIVATE);
        int _value = SP.getInt("c_value", 0);
        return _value;
    }
    private void iniData() {
        getSerialPort();
        SendDatasList.clear();
        // 读取温度 1秒钟读取一次
        new SendThread().start();
        new SendDatasThread().start();
        ReadSensitivity();
        c_value.setText(getC_value() + "");
    }
    private void ReadSensitivity() {
        byte[] sendBytes = SendDatas.AddSendData(Commands.Sensor.getCommand(), 250, 250, new byte[] { 0 });
        SendDatasList.add(sendBytes);
    }
    private android.view.View.OnClickListener onClick = new android.view.View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Switch view = (Switch) v;
            if (mOutputStream == null) {
                Toast.makeText(ConsoleActivity.this, "Please Open Serial Port", android.widget.Toast.LENGTH_SHORT)
                        .show();
                view.setChecked(false);
                return;
            }
            int tag = Integer.parseInt(view.getTag().toString());
            if (tag == 0) {
                view.setTag("100");
                view.setChecked(true);
            } else {
                view.setTag("0");
                view.setChecked(false);
            }
            tag = Integer.parseInt(view.getTag().toString());
            if (view.equals(loop1Button)) {
                setData(1, tag);
            } else if (view.equals(loop2Button)) {
                setData(2, tag);
            } else if (view.equals(loop3Button)) {
                setData(3, tag);
            } else if (view.equals(loop4Button)) {
                setData(4, tag);
            }
        }
    };
    private android.view.View.OnClickListener powerOnClick = new android.view.View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (view.getTag().toString().equals("On")) {
                view.setTag("Off");
                mApplication.closeSerialPort();
                try {
                    mOutputStream.close();
                    mOutputStream = null;
                } catch (Exception e) {
                    e.printStackTrace();
                    return;
                }
                powerButton.setChecked(false);
            } else if (view.getTag().toString().equals("Off")) {
                getSerialPort();
            }
        }
    };
    private android.view.View.OnClickListener backLightOnClick = new android.view.View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Switch view = (Switch) v;
            if (view.isChecked()) {
                // sendBackLight(1);
                if (0 < SerialPort.BackLight_ON()) {
                    Toast.makeText(ConsoleActivity.this, "-1", Toast.LENGTH_SHORT).show();
                }
            } else {
                // sendBackLight(0);
                if (0 < SerialPort.BackLight_OFF()) {
                    Toast.makeText(ConsoleActivity.this, "-1", Toast.LENGTH_SHORT).show();
                }
            }
        }
    };
    private android.view.View.OnTouchListener onTouch = new android.view.View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (MotionEvent.ACTION_DOWN == event.getAction()) {
                v.setBackgroundResource(R.drawable.selected);
                if (mOutputStream == null) {
                    Toast.makeText(ConsoleActivity.this, "Please Open Serial Port", android.widget.Toast.LENGTH_SHORT)
                            .show();
                } else {
                    setBuzzerData();
                }
            } else if (MotionEvent.ACTION_UP == event.getAction()) {
                v.setBackgroundResource(R.drawable.unselected);
            }
            return false;
        }
    };
    /**
     * Open the serial port, input and output streams
     */
    private void getSerialPort() {
        mApplication = new Application();
        try {
            mSerialPort = mApplication.getSerialPort();
            mOutputStream = mSerialPort.getOutputStream();
            mInputStream = mSerialPort.getInputStream();
            mReadThread = new ReadThread();
            mReadThread.start();
            if (powerButton != null) {
                powerButton.setChecked(true);
                powerButton.setTag("On");
            }
        } catch (SecurityException e) {
            if (powerButton != null) {
                powerButton.setChecked(false);
                powerButton.setTag("Off");
            }
            DisplayError(R.string.error_security);
        } catch (IOException e) {
            if (powerButton != null) {
                powerButton.setChecked(false);
                powerButton.setTag("Off");
            }
            DisplayError(R.string.error_unknown);
        } catch (InvalidParameterException e) {
            if (powerButton != null) {
                powerButton.setChecked(false);
                powerButton.setTag("Off");
            }
            DisplayError(R.string.error_configuration);
        }
    }
    /**
     * send buzzer
     */
    private void setBuzzerData() {
        byte[] sendBytes = SendDatas.AddSendData(Commands.buzzer.getCommand(), 250, 250,
                new byte[] { (byte) 2, (byte) 5, (byte) 1 });
        this.SendDatasList.add(sendBytes);
        /**
         * 2017.12.17 try { mOutputStream.flush();
         * mOutputStream.write(sendBytes);
         *
         * } catch (IOException e) { e.printStackTrace(); }
         */
    }
    private void readDateTime() {
        byte[] sendBytes = SendDatas.AddSendData(Commands.ReadTime.getCommand(), 250, 250, new byte[] {});
        this.SendDatasList.add(sendBytes);
    }
    private byte[] sendData(int loopId, int linght) {
        byte[] sendBytes = SendDatas.AddSendData(Commands.regulationControl.getCommand(), 250, 250,
                new byte[] { (byte) loopId, (byte) linght });
        return sendBytes;
    }
    private void setData(int loopId, int linght) {
        byte[] sendBytes = sendData(loopId, linght);
        this.SendDatasList.add(sendBytes);
    }
    /**
     * 2015.12.10 读取温度
     */
    private class SendThread extends Thread {
        @Override
        public void run() {
            super.run();
            while (true) {
                try {
                    byte[] sendBytes = SendDatas.AddSendData(Commands.READ_TEMP_WITH_DRY1.getCommand(), 250, 250,
                            new byte[] {});
                    mOutputStream.flush();
                    mOutputStream.write(sendBytes);
                    sleep(1000);
                } catch (Exception e) {
                    //
                    continue;
                }
            }
        }
    }
    private class SendDatasThread extends Thread {
        @Override
        public void run() {
            super.run();
            while (true) {
                try {
                    Thread.sleep(10);
                } catch (Exception e) {
                    e.getMessage();
                }
                for (int i = 0; i < SendDatasList.size(); i++) {
                    try {
                        byte[] sendBytes = SendDatasList.get(i);
                        try {
                            mOutputStream.flush();
                            mOutputStream.write(sendBytes);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        SendDatasList.remove(i);
                        i--;
                    } catch (Exception ex) {
                        ex.getMessage();
                    }
                }
            }
        }
    }
    /**
     * Read data thread
     *
     * @author 2017年12月19日
     */
    private class ReadThread extends Thread {
        @Override
        public void run() {
            super.run();
            while (!isInterrupted()) {
                int size = 0;
                try {
                    byte[] buffer = new byte[64];
                    if (mInputStream == null) {
                        return;
                    }
                    size = mInputStream.read(buffer);
                    for (int i = 0; i < size - 1; i++) {
                        if (i != 0) {
                            if ((buffer[i] & 0xFF) == 0xAA && (buffer[i + 1] & 0xFF) == 0xAA) {
                                //
                                byte[] _bf = new byte[i];
                                System.arraycopy(buffer, 0, _bf, 0, i);
                                if (_bf.length >= 13) {
                                    int command = (buffer[7] & 0xFF) * 256 + (buffer[8] & 0xFF);
                                    if (command == Commands.ReadTimeFeedback.getCommand()
                                            || command == Commands.DryContactInitiativeToSend.getCommand()
                                            || command == Commands.READ_TEMP_WITH_DRY1_ACK.getCommand()
                                            || command == Commands.InductorState.getCommand()
                                            || command == Commands.SensorBack.getCommand()
                                            || command == Commands.ClickState.getCommand()) {
                                        onDataReceived(buffer, size);
                                    }
                                }
                                byte[] _bf2 = new byte[size - i];
                                System.arraycopy(buffer, i, _bf2, 0, size - i);
                                if (_bf2.length >= 13) {
                                    int command = (buffer[7] & 0xFF) * 256 + (buffer[8] & 0xFF);
                                    if (command == Commands.ReadTimeFeedback.getCommand()
                                            || command == Commands.DryContactInitiativeToSend.getCommand()
                                            || command == Commands.READ_TEMP_WITH_DRY1_ACK.getCommand()
                                            || command == Commands.InductorState.getCommand()
                                            || command == Commands.SensorBack.getCommand()
                                            || command == Commands.ClickState.getCommand()) {
                                        onDataReceived(buffer, size);
                                    }
                                }
                            }
                        } else {
                            if (size >= 13) {
                                int command = (buffer[7] & 0xFF) * 256 + (buffer[8] & 0xFF);
                                if (command == Commands.ReadTimeFeedback.getCommand()
                                        || command == Commands.DryContactInitiativeToSend.getCommand()
                                        || command == Commands.READ_TEMP_WITH_DRY1_ACK.getCommand()
                                        || command == Commands.InductorState.getCommand()
                                        || command == Commands.SensorBack.getCommand()
                                        || command == Commands.ClickState.getCommand()) {
                                    onDataReceived(buffer, size);
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    return;
                }
            }
        }
    }
    protected void onDataReceived(final byte[] buffer, final int size) {
        runOnUiThread(new Runnable() {
            public void run() {
                int command = (buffer[7] & 0xFF) * 256 + (buffer[8] & 0xFF);
                if (command == Commands.ReadTimeFeedback.getCommand()) {
                    // ReadDateTimeTextView.setText(
                    // (buffer[12] & 0xFF) + "\\" + (buffer[13] & 0xFF) + "\\20"
                    // + (buffer[11] & 0xFF) + " "
                    // + (buffer[14] & 0xFF) + ":" + (buffer[15] & 0xFF) + ":" +
                    // (buffer[16] & 0xFF));
                } else if (command == Commands.DryContactInitiativeToSend.getCommand()) {
                    try {
                        mOutputStream
                                .write(SendDatas.AddSendData(Commands.DryContactInitiativeToSendFeedback.getCommand(),
                                        250, 250, new byte[] { (byte) 0xf8 }));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    if ((buffer[11] & 0xFF) == 1)
                        radioButton1.setChecked(true);
                    else
                        radioButton1.setChecked(false);
                    if ((buffer[12] & 0xFF) == 1)
                        radioButton2.setChecked(true);
                    else
                        radioButton2.setChecked(false);
                    if ((buffer[13] & 0xFF) == 1)
                        radioButton3.setChecked(true);
                    else
                        radioButton3.setChecked(false);
                    if ((buffer[14] & 0xFF) == 1)
                        radioButton4.setChecked(true);
                    else
                        radioButton4.setChecked(false);
                    if ((buffer[15] & 0xFF) == 1)
                        radioButton5.setChecked(true);
                    else
                        radioButton5.setChecked(false);
                    if ((buffer[16] & 0xFF) == 1)
                        radioButton6.setChecked(true);
                    else
                        radioButton6.setChecked(false);
                } else if (command == Commands.READ_TEMP_WITH_DRY1_ACK.getCommand()) {// 读取温度
                    if ((buffer[13] & 0xFF) == 0) {
                        // 单位摄氏度
                        T_TextView.setText((buffer[11] & 0xFF) + "℃");
                    } else {
                        // 华氏度
                        T_TextView.setText((buffer[11] & 0xFF) + "℉");
                    }
                } else if (command == Commands.SensorBack.getCommand()) {
                    // 传感器灵敏度
                    SSeekbar.setProgress(buffer[12] & 0xFF);
                    Seekbar_value.setText((buffer[12] & 0xFF) + "");
                } else if (command == Commands.InductorState.getCommand()) {
                    try {
                        Btn_state.setBackgroundColor(Color.RED);
                        ((Inductor) Btn_state.getTag()).LastTime = Calendar.getInstance();
                    } catch (Exception e) {
                    }
                } else if (command == Commands.ClickState.getCommand()) {
                    int key = buffer[12] & 0xFF;
                    switch (key) {
                    case 0:// 弹起
                        key_state.setText("KEY_UP");
                        Log.i("adf", "KEY_UP");
                        break;
                    case 1:// 按下
                        key_state.setText("KEY_DOWN");
                        Log.i("adf", "KEY_DOWN");
                        break;
                    case 2:// 长按
                        key_state.setText("KEY_LONGPRESS");
                        Log.i("adf", "KEY_LONGPRESS");
                        break;
                    }
                } else if (command == Commands.SET_TEMP_COMPENSATE_VALUE_ACK.getCommand()) {
                    if ((buffer[11] & 0xFF) == 0xF5) {
                        Toast.makeText(ConsoleActivity.this, "set compensate value failed", Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });
    }
    /**
     * Error message
     *
     * @param resourceId
     */
    private void DisplayError(int resourceId) {
        AlertDialog.Builder b = new AlertDialog.Builder(this);
        b.setTitle("Error");
        b.setMessage(resourceId);
        b.setPositiveButton("OK", new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // ConsoleActivity.this.finish();
            }
        });
        b.show();
    }
    @Override
    protected void onDestroy() {
        if (mReadThread != null)
            mReadThread.interrupt();
        mApplication.closeSerialPort();
        mSerialPort = null;
        super.onDestroy();
    }
    private android.view.View.OnTouchListener ReadTimeButtonOnTouch = new android.view.View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (MotionEvent.ACTION_DOWN == event.getAction()) {
                v.setBackgroundResource(R.drawable.selected);
                if (mOutputStream == null) {
                    Toast.makeText(ConsoleActivity.this, "Please Open Serial Port", android.widget.Toast.LENGTH_SHORT)
                            .show();
                } else {
                    readDateTime();
                }
            } else if (MotionEvent.ACTION_UP == event.getAction()) {
                v.setBackgroundResource(R.drawable.unselected);
            }
            return false;
        }
    };
    public static Handler MainHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
            case INDUCTOR_LEAVE:
                Btn_state.setBackground(null);
                break;
            default:
                break;
            }
        }
    };
}
app/src/main/java/android/serialport/api/sample/Fragment_BUS.java
New file
@@ -0,0 +1,500 @@
package android.serialport.api.sample;
import java.util.Calendar;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.serialport.api.SerialPort;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.SeekBar;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.SeekBar.OnSeekBarChangeListener;
import sendData.Commands;
import sendData.SendDatas;
public class Fragment_BUS extends Fragment {
    private static Context mContext;
    private View mView;
    public static final int INDUCTOR_LEAVE = 1;
    private static TextView Seekbar_value;
    private static EditText T_TextView;
    private static EditText key_state;
    private static EditText c_value;
    private static Switch loop1Button;
    private static Switch loop2Button;
    private static Switch loop3Button;
    private static Switch loop4Button;
    private static Switch powerButton;
    public static Switch openBackLight;
    private static RadioButton radioButton1;
    private static RadioButton radioButton2;
    private static RadioButton radioButton3;
    private static RadioButton radioButton4;
    private static RadioButton radioButton5;
    private static RadioButton radioButton6;
    private static SeekBar SSeekbar;
    private static Button Btn_state;
    private static Button C_Btn;
    int id = -1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.console, container, false);
        iniView();
        iniData();
        return mView;
    }
    @Override
    public void onStart() {
        super.onStart();
    }
    @Override
    public void onStop() {
        super.onStop();
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
    }
    private void iniView() {
        c_value = (EditText) mView.findViewById(R.id.c_value);
        T_TextView = (EditText) mView.findViewById(R.id.Temperature);
        key_state = (EditText) mView.findViewById(R.id.key_status);
        Seekbar_value = (TextView) mView.findViewById(R.id.seekbar_value);
        loop1Button = (Switch) mView.findViewById(R.id.loopId1);
        loop1Button.setTag("0");
        loop1Button.setOnClickListener(onClick);
        loop2Button = (Switch) mView.findViewById(R.id.loopId2);
        loop2Button.setTag("0");
        loop2Button.setOnClickListener(onClick);
        loop3Button = (Switch) mView.findViewById(R.id.loopId3);
        loop3Button.setTag("0");
        loop3Button.setOnClickListener(onClick);
        loop4Button = (Switch) mView.findViewById(R.id.loopId4);
        loop4Button.setTag("0");
        loop4Button.setOnClickListener(onClick);
        powerButton = (Switch) mView.findViewById(R.id.powerButton);
        powerButton.setTag("Off");
        powerButton.setOnClickListener(powerOnClick);
        radioButton1 = (RadioButton) mView.findViewById(R.id.radioButton1);
        radioButton2 = (RadioButton) mView.findViewById(R.id.radioButton2);
        radioButton3 = (RadioButton) mView.findViewById(R.id.radioButton3);
        radioButton4 = (RadioButton) mView.findViewById(R.id.radioButton4);
        radioButton5 = (RadioButton) mView.findViewById(R.id.radioButton5);
        radioButton6 = (RadioButton) mView.findViewById(R.id.radioButton6);
        openBackLight = (Switch) mView.findViewById(R.id.openbacklight);
        openBackLight.setTag("1");
        openBackLight.setChecked(true);
        openBackLight.setOnClickListener(backLightOnClick);
        Btn_state = (Button) mView.findViewById(R.id.btn_state);
        Btn_state.setTag(new Inductor());
        Btn_state.setBackground(null);
        C_Btn = (Button) mView.findViewById(R.id.c_btn);
        C_Btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 设置补偿值
                try {
                    int _value = Integer.parseInt(c_value.getText().toString());
                    byte[] sendBytes = SendDatas.AddSendData(Commands.SET_TEMP_COMPENSATE_VALUE.getCommand(),
                            Global.SubNet_Id, Global.Device_Id,
                            new byte[] { (byte) 1, (byte) 0, (byte) (_value + 10) });
                    ReceiveAndSend.SendDatasList.add(sendBytes);
                    SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences("Serialport",
                            MainActivity.CuttentActivity.MODE_PRIVATE);
                    SharedPreferences.Editor editor = SP.edit();
                    editor.putInt("c_value", _value);
                    editor.commit();
                    editor.apply();
                    InputMethodManager imm = (InputMethodManager) MainActivity.CuttentActivity
                            .getSystemService(MainActivity.CuttentActivity.INPUT_METHOD_SERVICE);
                    // 得到InputMethodManager的实例
                    if (imm.isActive()) {
                        // 如果开启
                        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
                        // 关闭软键盘,开启方法相同,这个方法是切换开启与关闭状态的
                    }
                } catch (Exception e) {
                }
            }
        });
        SSeekbar = (SeekBar) mView.findViewById(R.id.set_sensitivity);
        SSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // 写
                int _value = seekBar.getProgress();
                byte[] sendBytes = SendDatas.AddSendData(Commands.Sensor.getCommand(), Global.SubNet_Id,
                        Global.Device_Id, new byte[] { 1, (byte) _value });
                ReceiveAndSend.SendDatasList.add(sendBytes);
            }
            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                Seekbar_value.setText(progress + "");
            }
        });
    }
    private int getC_value() {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences("Serialport",
                MainActivity.CuttentActivity.MODE_PRIVATE);
        int _value = SP.getInt("c_value", 0);
        return _value;
    }
    private void iniData() {
        mContext = getContext();
        ReceiveAndSend.SendDatasList.clear();
        ReadSensitivity();
        c_value.setText(getC_value() + "");
    }
    private void ReadSensitivity() {
        byte[] sendBytes = SendDatas.AddSendData(Commands.Sensor.getCommand(), Global.SubNet_Id, Global.Device_Id,
                new byte[] { 0 });
        ReceiveAndSend.SendDatasList.add(sendBytes);
    }
    public static Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            Global.BUS bus;
            try {
                bus = (Global.BUS) msg.obj;
            } catch (Exception e) {
                bus = null;
            }
            if (bus == null)
                return;
            switch (bus.index) {
            case -1:
                Toast.makeText(mContext, bus.str, Toast.LENGTH_LONG).show();
                break;
            case 1: {
                if (bus.contact1 == 0) {
                    radioButton1.setChecked(true);
                } else {
                    radioButton1.setChecked(false);
                }
                if (bus.contact2 == 0) {
                    radioButton2.setChecked(true);
                } else {
                    radioButton2.setChecked(false);
                }
                if (bus.contact3 == 0) {
                    radioButton3.setChecked(true);
                } else {
                    radioButton3.setChecked(false);
                }
                if (bus.contact4 == 0) {
                    radioButton4.setChecked(true);
                } else {
                    radioButton4.setChecked(false);
                }
                if (bus.contact5 == 0) {
                    radioButton5.setChecked(true);
                } else {
                    radioButton5.setChecked(false);
                }
                if (bus.contact6 == 0) {
                    radioButton6.setChecked(true);
                } else {
                    radioButton6.setChecked(false);
                }
            }
                break;
            case 2: {
            }
                break;
            case 3: {
            }
                break;
            case 4: {
            }
                break;
            case 5: {
            }
                break;
            case 6: {
            }
                break;
            case 7: {
                // 温度
                if (bus.value == 0)// 摄氏度
                    T_TextView.setText(bus.value2 + "℃");
                else
                    T_TextView.setText(bus.value2 + "℉");
            }
                break;
            case 8: {
                // 传感器灵敏度
                SSeekbar.setProgress(bus.value);
                Seekbar_value.setText(bus.value + "");
            }
                break;
            case 9: {// 传感器探测
                Btn_state.setBackgroundColor(Color.RED);
                ((Inductor) Btn_state.getTag()).LastTime = Calendar.getInstance();
            }
                break;
            case 10: {// 按键检测
                if (bus.value == 0) {
                    key_state.setText("KEY_UP");
                } else if (bus.value == 1) {
                    key_state.setText("KEY_DOWN");
                } else if (bus.value == 2) {
                    key_state.setText("KEY_LONGPRESS");
                }
            }
                break;
            case 11:
                try {
                    if (bus.value == 1) {
                        powerButton.setChecked(true);
                        powerButton.setTag("On");
                    } else {
                        powerButton.setChecked(false);
                        powerButton.setTag("Off");
                    }
                } catch (Exception e) {
                    e.getMessage();
                }
                break;
            case 12:
                break;
            case 13:
                break;
            case 14:
                break;
            case 15:
                break;
            case 16:
                break;
            case 17:
                break;
            case 18:
                break;
            case 19:
                break;
            }
        }
    };
    public static Handler MainHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
            case INDUCTOR_LEAVE:
                Btn_state.setBackground(null);
                break;
            default:
                break;
            }
        }
    };
    private android.view.View.OnClickListener onClick = new android.view.View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Switch view = (Switch) v;
            if (Global.mOutputStream == null) {
                Toast.makeText(getActivity(), "Please Open Serial Port", android.widget.Toast.LENGTH_SHORT).show();
                view.setChecked(false);
                return;
            }
            int tag = Integer.parseInt(view.getTag().toString());
            if (tag == 0) {
                view.setTag("100");
                view.setChecked(true);
            } else {
                view.setTag("0");
                view.setChecked(false);
            }
            tag = Integer.parseInt(view.getTag().toString());
            if (view.equals(loop1Button)) {
                setData(1, tag);
            } else if (view.equals(loop2Button)) {
                setData(2, tag);
            } else if (view.equals(loop3Button)) {
                setData(3, tag);
            } else if (view.equals(loop4Button)) {
                setData(4, tag);
            }
        }
    };
    private android.view.View.OnClickListener powerOnClick = new android.view.View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (view.getTag().toString().equals("On")) {
                view.setTag("Off");
                Global.mApplication.closeSerialPort();
                try {
                    Global.mOutputStream.close();
                    Global.mOutputStream = null;
                } catch (Exception e) {
                    e.printStackTrace();
                    return;
                }
                powerButton.setChecked(false);
            } else if (view.getTag().toString().equals("Off")) {
                ReceiveAndSend.getSerialPort();
            }
        }
    };
    private android.view.View.OnClickListener backLightOnClick = new android.view.View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Switch view = (Switch) v;
            if (view.isChecked()) {
                // sendBackLight(1);
                if (0 < SerialPort.BackLight_ON()) {
                    Toast.makeText(getActivity(), "-1", Toast.LENGTH_SHORT).show();
                }
            } else {
                // sendBackLight(0);
                if (0 < SerialPort.BackLight_OFF()) {
                    Toast.makeText(getActivity(), "-1", Toast.LENGTH_SHORT).show();
                }
            }
        }
    };
    private android.view.View.OnTouchListener onTouch = new android.view.View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (MotionEvent.ACTION_DOWN == event.getAction()) {
                v.setBackgroundResource(R.drawable.selected);
                if (Global.mOutputStream == null) {
                    Toast.makeText(getActivity(), "Please Open Serial Port", android.widget.Toast.LENGTH_SHORT).show();
                } else {
                    setBuzzerData();
                }
            } else if (MotionEvent.ACTION_UP == event.getAction()) {
                v.setBackgroundResource(R.drawable.unselected);
            }
            return false;
        }
    };
    /** send buzzer */
    private void setBuzzerData() {
        byte[] sendBytes = SendDatas.AddSendData(Commands.buzzer.getCommand(), Global.SubNet_Id, Global.Device_Id,
                new byte[] { (byte) 2, (byte) 5, (byte) 1 });
        ReceiveAndSend.SendDatasList.add(sendBytes);
    }
    private void readDateTime() {
        byte[] sendBytes = SendDatas.AddSendData(Commands.ReadTime.getCommand(), Global.SubNet_Id, Global.Device_Id,
                new byte[] {});
        ReceiveAndSend.SendDatasList.add(sendBytes);
    }
    private byte[] sendData(int loopId, int linght) {
        byte[] sendBytes = SendDatas.AddSendData(Commands.regulationControl.getCommand(), Global.SubNet_Id,
                Global.Device_Id, new byte[] { (byte) loopId, (byte) linght });
        return sendBytes;
    }
    private void setData(int loopId, int linght) {
        byte[] sendBytes = sendData(loopId, linght);
        ReceiveAndSend.SendDatasList.add(sendBytes);
    }
}
app/src/main/java/android/serialport/api/sample/Fragment_KNX.java
New file
@@ -0,0 +1,333 @@
package android.serialport.api.sample;
import java.io.InputStream;
import java.io.OutputStream;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.serialport.api.SerialPort;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Fragment_KNX extends Fragment {
    private static Activity CurentActivity;
    private OutputStream mOutputStream;
    private InputStream mInputStream;
    private KNX_Serialport mKNX_SerialPort;
    private SerialPort mSerialPort;
    private View mView;
    private static Button mSwitchButton_1;
    private static Button mLight_1;
    private static EditText mObjectEditText1_1;
    private static EditText mObjectEditText1_2;
    private static Button mSwitchButton_2;
    private static Button mLight_2;
    private static EditText mObjectEditText2_1;
    private static EditText mObjectEditText2_2;
    private static Button mSwitchButton_3;
    private static Button mLight_3;
    private static EditText mObjectEditText3_1;
    private static EditText mObjectEditText3_2;
    private static Button mSwitchButton_4;
    private static Button mLight_4;
    private static EditText mObjectEditText4_1;
    private static EditText mObjectEditText4_2;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_knx, container, false);
        iniView();
        iniData();
        return mView;
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
    }
    @Override
    public void onStart() {
        super.onStart();
    }
    @Override
    public void onStop() {
        super.onStop();
    }
    private void iniView() {
        mSwitchButton_1 = (Button) mView.findViewById(R.id.switch_btn1);
        mLight_1 = (Button) mView.findViewById(R.id.light1_1);
        mSwitchButton_1.setOnClickListener(OnClick);
        mLight_1.setOnClickListener(OnClickLight);
        mLight_1.setTag((int) 0);
        mLight_1.setBackground(getResources().getDrawable(R.drawable.light_def));
        mSwitchButton_2 = (Button) mView.findViewById(R.id.switch_btn2);
        mLight_2 = (Button) mView.findViewById(R.id.light_2);
        mSwitchButton_2.setOnClickListener(OnClick);
        mLight_2.setOnClickListener(OnClickLight);
        mLight_2.setTag((int) 0);
        mLight_2.setBackground(getResources().getDrawable(R.drawable.light_def));
        mSwitchButton_3 = (Button) mView.findViewById(R.id.switch_btn3);
        mLight_3 = (Button) mView.findViewById(R.id.light_3);
        mSwitchButton_3.setOnClickListener(OnClick);
        mLight_3.setOnClickListener(OnClickLight);
        mLight_3.setTag((int) 0);
        mLight_3.setBackground(getResources().getDrawable(R.drawable.light_def));
        mSwitchButton_4 = (Button) mView.findViewById(R.id.switch_btn4);
        mLight_4 = (Button) mView.findViewById(R.id.light_4);
        mSwitchButton_4.setOnClickListener(OnClick);
        mLight_4.setOnClickListener(OnClickLight);
        mLight_4.setTag((int) 0);
        mLight_4.setBackground(getResources().getDrawable(R.drawable.light_def));
        mObjectEditText1_1 = (EditText) mView.findViewById(R.id.edit_obj1_1);
        mObjectEditText1_2 = (EditText) mView.findViewById(R.id.edit_obj1_2);
        mObjectEditText1_2.setTag("");
        mObjectEditText2_1 = (EditText) mView.findViewById(R.id.edit_obj2_1);
        mObjectEditText2_2 = (EditText) mView.findViewById(R.id.edit_obj2_2);
        mObjectEditText2_2.setTag("");
        mObjectEditText3_1 = (EditText) mView.findViewById(R.id.edit_obj3_1);
        mObjectEditText3_2 = (EditText) mView.findViewById(R.id.edit_obj3_2);
        mObjectEditText3_2.setTag("");
        mObjectEditText4_1 = (EditText) mView.findViewById(R.id.edit_obj4_1);
        mObjectEditText4_2 = (EditText) mView.findViewById(R.id.edit_obj4_2);
        mObjectEditText4_2.setTag("");
    }
    private void iniData() {
        CurentActivity = getActivity();
        SetControlData(mObjectEditText1_2, mObjectEditText1_2.getText().toString());
        SetControlData(mObjectEditText2_2, mObjectEditText2_2.getText().toString());
        //
        SetControlData(mObjectEditText3_2, mObjectEditText3_2.getText().toString());
        //
        SetControlData(mObjectEditText4_2, mObjectEditText4_2.getText().toString());
        getSerialPort();
        KNX_ReceiveAndSend.Start(mKNX_SerialPort, mOutputStream, mInputStream);
    }
    /**
     * Open the serial port, input and output streams
     */
    private void getSerialPort() {
        mKNX_SerialPort = new KNX_Serialport();
        try {
            mSerialPort = mKNX_SerialPort.getSerialPort();
            mOutputStream = mSerialPort.getOutputStream();
            mInputStream = mSerialPort.getInputStream();
        } catch (Exception e) {
            e.getMessage();
        }
    }
    private static void SetLightState(Button btn, int _state) {
        if (_state == 0) {
            btn.setBackground(CurentActivity.getResources().getDrawable(R.drawable.light_def));
            btn.setTag(0);
        } else {
            btn.setBackground(CurentActivity.getResources().getDrawable(R.drawable.light));
            btn.setTag(1);
        }
    }
    private static void SetControlData(View v, String str) {
        if (str.equals(""))
            return;
        try {
            int obj1 = Integer.parseInt(str.split("/")[0].trim());
            int obj2 = Integer.parseInt(str.split("/")[1].trim());
            int obj3 = Integer.parseInt(str.split("/")[2].trim());
            v.setTag(KNX.set_Group_addr(obj1, obj2, obj3));
        } catch (Exception e) {
            e.getMessage();
        }
    }
    public static Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            String str = Integer.toString(msg.arg1);
            if (str.equals(mObjectEditText1_2.getTag().toString())) {
                SetLightState(mLight_1, msg.arg2);
            } else if (str.equals(mObjectEditText2_2.getTag().toString())) {
                SetLightState(mLight_2, msg.arg2);
            } else if (str.equals(mObjectEditText3_2.getTag().toString())) {
                SetLightState(mLight_3, msg.arg2);
            } else if (str.equals(mObjectEditText4_2.getTag().toString())) {
                SetLightState(mLight_4, msg.arg2);
            }
        }
    };
    private android.view.View.OnClickListener OnClickLight = new android.view.View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mObjectEditText1_1.getText().toString() == "" || mObjectEditText2_1.getText().toString() == ""
                    || mObjectEditText3_1.getText().toString() == "" || mObjectEditText4_1.getText().toString() == ""
                    || mObjectEditText2_2.getText().toString() == "" || mObjectEditText2_2.getText().toString() == ""
                    || mObjectEditText3_2.getText().toString() == "" || mObjectEditText4_2.getText().toString() == "") {
                Toast.makeText(CurentActivity, "Group_addr can not be empty", Toast.LENGTH_SHORT).show();
                return;
            }
            if (v.equals(mLight_1)) {
                try {
                    String str = mObjectEditText1_1.getText().toString();
                    int obj1 = Integer.parseInt(str.split("/")[0].trim());
                    int obj2 = Integer.parseInt(str.split("/")[1].trim());
                    int obj3 = Integer.parseInt(str.split("/")[2].trim());
                    int state = Integer.parseInt(mLight_1.getTag().toString());
                    state = state == 0 ? 1 : 0;
                    byte[] sendBytes = KNX.get_SendBuffer(12345, obj1, obj2, obj3, state);
                    String[] tmp = new String[sendBytes.length];
                    for (int i = 0; i < sendBytes.length; i++) {
                        tmp[i] = Integer.toHexString(sendBytes[i] & 0xFF);
                    }
                    mOutputStream.write(sendBytes, 0, sendBytes[1] & 0xFF);
                    // 根据长度截取数据发送
                    mOutputStream.flush();
                } catch (Exception e) {
                    e.getMessage();
                }
            } else if (v.equals(mLight_2)) {
                try {
                    String str = mObjectEditText2_1.getText().toString();
                    int obj1 = Integer.parseInt(str.split("/")[0].trim());
                    int obj2 = Integer.parseInt(str.split("/")[1].trim());
                    int obj3 = Integer.parseInt(str.split("/")[2].trim());
                    int state = Integer.parseInt(mLight_2.getTag().toString());
                    state = state == 0 ? 1 : 0;
                    byte[] sendBytes = KNX.get_SendBuffer(12345, obj1, obj2, obj3, state);
                    String[] tmp = new String[sendBytes.length];
                    for (int i = 0; i < sendBytes.length; i++) {
                        tmp[i] = Integer.toHexString(sendBytes[i] & 0xFF);
                    }
                    mOutputStream.write(sendBytes, 0, sendBytes[1] & 0xFF);
                    // 根据长度截取数据发送
                    mOutputStream.flush();
                } catch (Exception e) {
                    e.getMessage();
                }
            } else if (v.equals(mLight_3)) {
                try {
                    String str = mObjectEditText3_1.getText().toString();
                    int obj1 = Integer.parseInt(str.split("/")[0].trim());
                    int obj2 = Integer.parseInt(str.split("/")[1].trim());
                    int obj3 = Integer.parseInt(str.split("/")[2].trim());
                    int state = Integer.parseInt(mLight_3.getTag().toString());
                    state = state == 0 ? 1 : 0;
                    byte[] sendBytes = KNX.get_SendBuffer(12345, obj1, obj2, obj3, state);
                    String[] tmp = new String[sendBytes.length];
                    for (int i = 0; i < sendBytes.length; i++) {
                        tmp[i] = Integer.toHexString(sendBytes[i] & 0xFF);
                    }
                    mOutputStream.write(sendBytes, 0, sendBytes[1] & 0xFF);
                    // 根据长度截取数据发送
                    mOutputStream.flush();
                } catch (Exception e) {
                    e.getMessage();
                }
            } else if (v.equals(mLight_4)) {
                try {
                    String str = mObjectEditText4_1.getText().toString();
                    int obj1 = Integer.parseInt(str.split("/")[0].trim());
                    int obj2 = Integer.parseInt(str.split("/")[1].trim());
                    int obj3 = Integer.parseInt(str.split("/")[2].trim());
                    int state = Integer.parseInt(mLight_4.getTag().toString());
                    state = state == 0 ? 1 : 0;
                    byte[] sendBytes = KNX.get_SendBuffer(12345, obj1, obj2, obj3, state);
                    String[] tmp = new String[sendBytes.length];
                    for (int i = 0; i < sendBytes.length; i++) {
                        tmp[i] = Integer.toHexString(sendBytes[i] & 0xFF);
                    }
                    mOutputStream.write(sendBytes, 0, sendBytes[1] & 0xFF);
                    // 根据长度截取数据发送
                    mOutputStream.flush();
                } catch (Exception e) {
                    e.getMessage();
                }
            }
        }
    };
    private android.view.View.OnClickListener OnClick = new android.view.View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (v.equals(mSwitchButton_1)) {
                SetControlData(mObjectEditText1_2, mObjectEditText1_2.getText().toString());
            } else if (v.equals(mSwitchButton_2)) {
                //
                SetControlData(mObjectEditText2_2, mObjectEditText2_2.getText().toString());
            } else if (v.equals(mSwitchButton_3)) {
                //
                SetControlData(mObjectEditText3_2, mObjectEditText3_2.getText().toString());
            } else if (v.equals(mSwitchButton_4)) {
                //
                SetControlData(mObjectEditText4_2, mObjectEditText4_2.getText().toString());
            }
        }
    };
}
app/src/main/java/android/serialport/api/sample/Fragment_Update.java
New file
@@ -0,0 +1,521 @@
package android.serialport.api.sample;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import sendData.Commands;
import sendData.SendDatas;
public class Fragment_Update extends Fragment implements OnClickListener {
    public static Fragment_Update mFragment_Update;
    private byte[] mBuffer;
    private UpgradeThread mThread;
    private static boolean mFlag = false;
    private View mView;
    private Button Btn_Path;
    private Button Btn_Upgrade;
    private EditText EditText_Path;
    private AlertDialog ProDialog;
    private ProgressBar Pro;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_upgrade, container, false);
        iniView();
        iniData();
        return mView;
    }
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        String mPath = "";
        if (resultCode == Activity.RESULT_OK) {
            Uri uri = data.getData();
            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
                // 大于 android 4.4
                mPath = getPath(getActivity(), uri);
            } else {
                // 小于 android 4.4
                mPath = getRealPathFromURI(uri);
            }
        }
        EditText_Path.setText(mPath + "");
    }
    private String getRealPathFromURI(Uri contentUri) {
        String res = null;
        String[] proj = { MediaStore.Images.Media.DATA };
        Cursor cursor = getActivity().getContentResolver().query(contentUri, proj, null, null, null);
        if (null != cursor && cursor.moveToFirst()) {
            ;
            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            res = cursor.getString(column_index);
            cursor.close();
        }
        return res;
    }
    /**
     * 专为Android4.4设计的从Uri获取文件绝对路径,以前的方法已不好使
     */
    @SuppressLint("NewApi")
    private String getPath(final Context context, final Uri uri) {
        final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
        // DocumentProvider
        if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
            // ExternalStorageProvider
            if (isExternalStorageDocument(uri)) {
                final String docId = DocumentsContract.getDocumentId(uri);
                final String[] split = docId.split(":");
                final String type = split[0];
                if ("primary".equalsIgnoreCase(type)) {
                    return Environment.getExternalStorageDirectory() + "/" + split[1];
                }
            }
            // DownloadsProvider
            else if (isDownloadsDocument(uri)) {
                final String id = DocumentsContract.getDocumentId(uri);
                final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
                        Long.valueOf(id));
                return getDataColumn(context, contentUri, null, null);
            }
            // MediaProvider
            else if (isMediaDocument(uri)) {
                final String docId = DocumentsContract.getDocumentId(uri);
                final String[] split = docId.split(":");
                final String type = split[0];
                Uri contentUri = null;
                if ("image".equals(type)) {
                    contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
                } else if ("video".equals(type)) {
                    contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
                } else if ("audio".equals(type)) {
                    contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
                }
                final String selection = "_id=?";
                final String[] selectionArgs = new String[] { split[1] };
                return getDataColumn(context, contentUri, selection, selectionArgs);
            }
        }
        // MediaStore (and general)
        else if ("content".equalsIgnoreCase(uri.getScheme())) {
            return getDataColumn(context, uri, null, null);
        }
        // File
        else if ("file".equalsIgnoreCase(uri.getScheme())) {
            return uri.getPath();
        }
        return null;
    }
    /**
     * Get the value of the data column for this Uri. This is useful for
     * MediaStore Uris, and other file-based ContentProviders.
     *
     * @param context
     *            The context.
     * @param uri
     *            The Uri to query.
     * @param selection
     *            (Optional) Filter used in the query.
     * @param selectionArgs
     *            (Optional) Selection arguments used in the query.
     * @return The value of the _data column, which is typically a file path.
     */
    private String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
        Cursor cursor = null;
        final String column = "_data";
        final String[] projection = { column };
        try {
            cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
            if (cursor != null && cursor.moveToFirst()) {
                final int column_index = cursor.getColumnIndexOrThrow(column);
                return cursor.getString(column_index);
            }
        } finally {
            if (cursor != null)
                cursor.close();
        }
        return null;
    }
    /**
     * @param uri
     *            The Uri to check.
     * @return Whether the Uri authority is ExternalStorageProvider.
     */
    private boolean isExternalStorageDocument(Uri uri) {
        return "com.android.externalstorage.documents".equals(uri.getAuthority());
    }
    /**
     * @param uri
     *            The Uri to check.
     * @return Whether the Uri authority is DownloadsProvider.
     */
    private boolean isDownloadsDocument(Uri uri) {
        return "com.android.providers.downloads.documents".equals(uri.getAuthority());
    }
    /**
     * @param uri
     *            The Uri to check.
     * @return Whether the Uri authority is MediaProvider.
     */
    private boolean isMediaDocument(Uri uri) {
        return "com.android.providers.media.documents".equals(uri.getAuthority());
    }
    private void iniView() {
        //
        Btn_Path = (Button) mView.findViewById(R.id.Btn_path);
        Btn_Path.setOnClickListener(this);
        Btn_Upgrade = (Button) mView.findViewById(R.id.Btn_Upgrade);
        Btn_Upgrade.setOnClickListener(this);
        EditText_Path = (EditText) mView.findViewById(R.id.EditText_Path);
        ProDialog = new AlertDialog.Builder(getActivity(), R.style.Theme_Transparent).create();
        LayoutInflater inflater = LayoutInflater.from(getActivity());
        final View tmpickerview = inflater.inflate(R.layout.dialog_pro, null);
        ProDialog.setView(tmpickerview);
        Pro = (ProgressBar) tmpickerview.findViewById(R.id.pro);
    }
    private void iniData() {
        mFlag = false;
        mFragment_Update = this;
    }
    private void showPro() {
        Pro.setProgress(0);
        ProDialog.show();
        ProDialog.setTitle("upgrading, please do not operate it.");
        WindowManager.LayoutParams lp = ProDialog.getWindow().getAttributes();
        lp.width = 700;
        lp.height = 80;
        ProDialog.getWindow().setAttributes(lp);
    }
    private void hidePro() {
        ProDialog.dismiss();
    }
    private void NoticeDialog(String str) {
        //
        new AlertDialog.Builder(getActivity(), R.style.Theme_Transparent_NoTitle).setMessage(str)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).create().show();
    }
    private byte[] getBytes(int index) {
        // try {
        int count = mBuffer.length / 64;
        int b = mBuffer.length % 64;
        if (b != 0) {
            count = count + 1;
        }
        //
        // int count = (mBuffer.length / 64) + (mBuffer.length % 64 == 0 ? 0
        // : 1);
        byte[] _bytes;
        if (index > count) {
            // 当index大于count的时候,代表升级成功
            mFragment_Update.mUpdataHandler.sendEmptyMessage(2);
            return null;
        }
        if (index == count) {
            // 最后一条
            _bytes = new byte[(mBuffer.length - (index - 1) * 64) + 2];
        } else {
            _bytes = new byte[64 + 2];
        }
        _bytes[0] = (byte) (index / 256);
        _bytes[1] = (byte) (index % 256);
        System.arraycopy(mBuffer, (index - 1) * 64, _bytes, 2, _bytes.length - 2);
        Message msg = new Message();
        msg.arg1 = (index * 100) / count;
        msg.what = 0;
        mFragment_Update.mUpdataHandler.sendMessage(msg);
        return _bytes;
        // } catch (Exception e) {
        // mFragment_Update.mUpdataHandler.sendEmptyMessage(1);
        // Log.e("asdf", e.getMessage().toString());
        // return null;
        // }
    }
    private void SendUpgradeData(final int index) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    byte[] _bytes = getBytes(index);
                    if (_bytes == null) {
                        //
                        return;
                    }
                    byte[] sendBytes = SendDatas.AddSendData(Commands.DataRequest_ACK.getCommand(), Global.SubNet_Id,
                            Global.Device_Id, _bytes);
                    ReceiveAndSend.SendDatasList.add(sendBytes);
                    Log.i("asd", "发送第" + index + "条数据包" + _bytes.length);
                } catch (Exception e) {
                    mFragment_Update.mUpdataHandler.sendEmptyMessage(1);
                    e.getMessage();
                }
            }
        }).start();
    }
    private void SendUpgradeDataLength() {
        try {
            int count = (mBuffer.length / 64) + (mBuffer.length % 64 == 0 ? 0 : 1);
            byte[] _byte = new byte[4];
            _byte[0] = 0;
            _byte[1] = 0;
            _byte[2] = (byte) (count / 256);
            _byte[3] = (byte) (count % 256);
            byte[] sendBytes = SendDatas.AddSendData(Commands.DataRequest_ACK.getCommand(), Global.SubNet_Id,
                    Global.Device_Id, _byte);
            Global.mOutputStream.flush();
            Global.mOutputStream.write(sendBytes);
        } catch (Exception e) {
            e.getMessage();
        }
    }
    @Override
    public void onClick(View v) {
        if (v.equals(Btn_Path)) {
            // 查找文件路径
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("*/*");
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(intent, 1);
        } else if (v.equals(Btn_Upgrade)) {
            // 升级
            if (EditText_Path.getText().toString().equals("")) {
                NoticeDialog("The path cannot be empty.");
                return;
            }
            File file = new File(EditText_Path.getText().toString());
            String name = file.getName();
            String prefix = name.substring(name.lastIndexOf(".") + 1).toUpperCase();
            if (!prefix.equals("BIN")) {
                new AlertDialog.Builder(getActivity()).setMessage("File type error !").create().show();
                return;
            }
            // 读取文件
            try {
                FileInputStream fis = new FileInputStream(file);
                int length = fis.available();
                mBuffer = new byte[length];
                fis.read(mBuffer);
                if (mBuffer.length > 256 * 1024) {
                    new AlertDialog.Builder(getActivity()).setMessage("File Error !").create().show();
                    return;
                }
                mFlag = true;
                mThread = new UpgradeThread();
                mThread.start();
                showPro();
            } catch (IOException e) {
                mFlag = false;
                e.printStackTrace();
            }
        }
    }
    public Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (mBuffer == null)
                return;
            if (msg.what == 0) {
                // 接收到的是备注,回复数据包长度
                Log.i("asd", "接收到的是备注,回复数据包长度");
                SendUpgradeDataLength();
            } else {
                // 发送对应的数据
                Log.i("asd", "发送对应的数据");
                SendUpgradeData(msg.what);
            }
        }
    };
    private Handler mUpdataHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case 0:
                Pro.setProgress(msg.arg1);
                break;
            case 1:
                hidePro();
                NoticeDialog("Upgrade Failed !");
                break;
            case 2:
                hidePro();
                NoticeDialog("Upgrade Succeed !");
                break;
            default:
                break;
            }
        }
    };
    @Override
    public void onStart() {
        super.onStart();
    }
    @Override
    public void onStop() {
        super.onStop();
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
    }
    private class UpgradeThread extends Thread {
        @Override
        public void run() {
            super.run();
            int i = 0;
            while (mFlag) {
                try {
                    if (i > 20) {
                        // 发送20次没有成功就直接退出了
                        mFlag = false;
                        Log.i("asdf", "发送wan了读取备注命令");
                        return;
                    }
                    i++;
                    byte[] sendBytes = SendDatas.AddSendData(Commands.readRemark.getCommand(), Global.SubNet_Id,
                            Global.Device_Id, new byte[] {});
                    Global.mOutputStream.flush();
                    Global.mOutputStream.write(sendBytes);
                    Log.i("asdf", "发送了读取备注命令");
                    sleep(30);
                } catch (Exception e) {
                    e.getMessage();
                    continue;
                }
            }
        }
    }
}
app/src/main/java/android/serialport/api/sample/Global.java
New file
@@ -0,0 +1,35 @@
package android.serialport.api.sample;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import android.serialport.api.SerialPort;
public class Global {
    public static class BUS {
        public int index;
        public int value;
        public int value2;
        public String str;
        public byte[] bytes;
        public long length;
        public int contact1;
        public int contact2;
        public int contact3;
        public int contact4;
        public int contact5;
        public int contact6;
    }
    public static int SubNet_Id;
    public static int Device_Id;
    public static Application mApplication;
    public static SerialPort mSerialPort;
    public static OutputStream mOutputStream;
    public static InputStream mInputStream;
}
app/src/main/java/android/serialport/api/sample/Inductor.java
New file
@@ -0,0 +1,42 @@
package android.serialport.api.sample;
import java.util.Calendar;
import android.os.Handler;
import android.os.Message;
public class Inductor {
    public Calendar LastTime = null;
    public Inductor() {
        new thread().start();
    }
    class thread extends Thread {
        @Override
        public void run() {
            super.run();
            while (true) {
                try {
                    Thread.sleep(50);
                    if (LastTime == null)
                        continue;
                    if (Calendar.getInstance().getTimeInMillis() - LastTime.getTimeInMillis() > 10 * 1000) {
                        // 发送handler通知
                        Message msg = new Message();
                        msg.what = ConsoleActivity.INDUCTOR_LEAVE;
                        Fragment_BUS.MainHandler.handleMessage(msg);
                        LastTime = null;
                    }
                } catch (Exception e) {
                    //
                }
            }
        }
    }
}
app/src/main/java/android/serialport/api/sample/KNX.java
New file
@@ -0,0 +1,25 @@
package android.serialport.api.sample;
public class KNX {
    static {
        System.loadLibrary("serial_port");
    }
    /**
     *
     * */
    public static native byte[] get_SendBuffer(int _individual_addr, int obj1, int obj2n, int obj3, int on_off);
    public static native boolean UART_Receive(byte[] bytes);
    public static native boolean Parity_Data(byte[] buffer);
    public static native int get_Individual_addr();
    public static native int get_Group_addr();
    public static native int set_Group_addr(int obj1,int boj2,int obj3);
    public static native int get_State();
}
app/src/main/java/android/serialport/api/sample/KNX_ReceiveAndSend.java
New file
@@ -0,0 +1,124 @@
package android.serialport.api.sample;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import android.os.Message;
public class KNX_ReceiveAndSend {
    public static List<byte[]> SendDatasList = new ArrayList<byte[]>();
    private static KNX_Serialport mKNX_SerialPort;
    private static OutputStream mOutputStream;
    private static InputStream mInputStream;
    public static void Start(KNX_Serialport _KNX_SerialPort, OutputStream _OutputStream, InputStream _InputStream) {
        mInputStream = _InputStream;
        mKNX_SerialPort = _KNX_SerialPort;
        mOutputStream = _OutputStream;
        // 发送数据线程
        // new SendThread().start();
        new ReceiveThread().start();
    }
    private static class SendThread extends Thread {
        @Override
        public void run() {
            super.run();
            while (true) {
                try {
                    Thread.sleep(100);
                    for (int i = 0; i < SendDatasList.size(); i++) {
                        try {
                            Thread.sleep(100);
                        } catch (Exception e) {
                        }
                        try {
                            byte[] sendBytes = SendDatasList.get(i);
                            try {
                                mOutputStream.flush();
                                mOutputStream.write(sendBytes);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            SendDatasList.remove(i);
                            i--;
                        } catch (Exception ex) {
                            ex.getMessage();
                        }
                    }
                } catch (Exception e) {
                    e.getMessage();
                }
            }
        }
    }
    private static class ReceiveThread extends Thread {
        @Override
        public void run() {
            super.run();
            while (!isInterrupted()) {
                int size = 0;
                try {
                    byte[] buffer = new byte[64];
                    if (mInputStream == null) {
                        return;
                    }
                    size = mInputStream.read(buffer);
                    for (int i = 0; i < size - 1; i++) {
                        if ((buffer[i] & 0xFF) == 0xAA) {
                            byte bytes[] = new byte[(int) buffer[i + 1]];
                            System.arraycopy(buffer, i, bytes, 0, bytes.length);
                            // String str = "";
                            // for (int j = 0; j < bytes.length; j++) {
                            // str += Integer.toHexString(bytes[j] & 0xFF)+".";
                            // }
                            if (KNX.UART_Receive(bytes)) {
                                // 物理地址不处理
                                // int individual_addr =
                                // KNX.get_Individual_addr();
                                Message msg = new Message();
                                msg.arg1 = KNX.get_Group_addr();
                                msg.arg2 = KNX.get_State();
                                Fragment_KNX.mHandler.sendMessage(msg);
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
app/src/main/java/android/serialport/api/sample/KNX_Serialport.java
New file
@@ -0,0 +1,30 @@
package android.serialport.api.sample;
import java.io.File;
import java.io.IOException;
import java.security.InvalidParameterException;
import android.serialport.api.SerialPort;
import android.serialport.api.SerialPortFinder;
public class KNX_Serialport {
    public SerialPortFinder mSerialPortFinder = new SerialPortFinder();
    private SerialPort mSerialPort = null;
    public SerialPort getSerialPort() throws SecurityException, IOException, InvalidParameterException {
        if (mSerialPort == null) {
            mSerialPort = new SerialPort(new File("/dev/ttyS2"), 19200, 0);
        }
        return mSerialPort;
    }
    public void closeSerialPort() {
        if (mSerialPort != null) {
            mSerialPort.close();
            mSerialPort = null;
        }
    }
}
app/src/main/java/android/serialport/api/sample/MainActivity.java
New file
@@ -0,0 +1,244 @@
package android.serialport.api.sample;
import java.util.ArrayList;
import java.util.List;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.serialport.api.SerialPort;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.TextView;
public class MainActivity extends FragmentActivity implements OnClickListener, OnPageChangeListener {
    public static MainActivity CuttentActivity;
    public Fragment_BUS mFragment_BUS;
    public Fragment_KNX mFragment_KNX;
    public Fragment_Update mFragment_Update;
    private ViewPager mViewPager;
    private TextView TabTextView_BUS, TabTextView_KNX, TabTextView_Upgrade;
    private ImageView Tab_Line;
    private List<Fragment> mFragmentList;
    private int moveOne = 0;
    private boolean isScrolling = false;// 手指是否在移动
    /** 手指离开后的回弹 */
    private boolean isBackScrolling = false;// 手指离开后的回弹
    private long startTime = 0;
    private long currentTime = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CuttentActivity = this;
        setContentView(R.layout.activity_main);
        iniView();
        iniData();
        SetImageLineWidth();
    }
    @Override
    protected void onStart() {
        super.onStart();
        Intent intent = new Intent(this, MyService.class);
        startService(intent);
    }
    @Override
    protected void onResume() {
        super.onResume();
    }
    @Override
    protected void onStop() {
        super.onStop();
        Intent intent = new Intent(this, MyService.class);
        stopService(intent);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        android.os.Process.killProcess(android.os.Process.myPid());
    }
    private void iniView() {
        mFragmentList = new ArrayList<Fragment>();
        mFragment_BUS = new Fragment_BUS();
        mFragment_KNX = new Fragment_KNX();
        mFragment_Update = new Fragment_Update();
        mFragmentList.add(mFragment_BUS);
        mFragmentList.add(mFragment_KNX);
        mFragmentList.add(mFragment_Update);
        TabTextView_BUS = (TextView) findViewById(R.id.textView_bus);
        TabTextView_BUS.setTextColor(Color.RED);
        TabTextView_KNX = (TextView) findViewById(R.id.textView_knx);
        TabTextView_Upgrade = (TextView) findViewById(R.id.textView_upgrade);
        TabTextView_BUS.setOnClickListener(this);
        TabTextView_KNX.setOnClickListener(this);
        TabTextView_Upgrade.setOnClickListener(this);
        mViewPager = (ViewPager) findViewById(R.id.mViewPager);
        mViewPager.setAdapter(new MyFragmentAdapter(getSupportFragmentManager(), mFragmentList));
        mViewPager.setCurrentItem(0);
        mViewPager.addOnPageChangeListener(this);
        Tab_Line = (ImageView) findViewById(R.id.tab_image);
    }
    private void iniData() {
        CuttentActivity = this;
        SerialPort.BackLight_ON();
    }
    // 下划线跟随手指的滑动而滑动
    private void movePositionX(int toPosition, float positionOffsetPixels) {
        float curTranslationX = Tab_Line.getTranslationX();
        float toPositionX = moveOne * toPosition + positionOffsetPixels;
        ObjectAnimator animator = ObjectAnimator.ofFloat(Tab_Line, "TranslationX", curTranslationX, toPositionX);
        animator.setDuration(1000);
        animator.start();
    }
    // 下划线滑动到新的选项中
    private void movePositionX(int toPosition) {
        movePositionX(toPosition, 0);
    }
    /** 设置线条的宽度 */
    private void SetImageLineWidth() {
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        int screew = dm.widthPixels;// 获取屏幕的宽
        // 重新设置划线宽
        LayoutParams lp = Tab_Line.getLayoutParams();
        lp.width = screew / 3;
        Tab_Line.setLayoutParams(lp);
        moveOne = lp.width;// 记录距离
    }
    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        currentTime = System.currentTimeMillis();
        if (isScrolling && (currentTime - startTime > 200)) {
            movePositionX(position, moveOne * positionOffset);
            startTime = currentTime;
        }
        if (isBackScrolling) {
            movePositionX(position);
        }
    }
    @Override
    public void onPageSelected(int position) {
        switch (position) {
        case 0:
            TabTextView_BUS.setTextColor(Color.RED);
            TabTextView_KNX.setTextColor(Color.BLACK);
            TabTextView_Upgrade.setTextColor(Color.BLACK);
            break;
        case 1:
            TabTextView_BUS.setTextColor(Color.BLACK);
            TabTextView_KNX.setTextColor(Color.RED);
            TabTextView_Upgrade.setTextColor(Color.BLACK);
            break;
        case 2:
            TabTextView_BUS.setTextColor(Color.BLACK);
            TabTextView_KNX.setTextColor(Color.BLACK);
            TabTextView_Upgrade.setTextColor(Color.RED);
            break;
        default:
            break;
        }
    }
    @Override
    public void onPageScrollStateChanged(int state) {
        switch (state) {
        case 1:// 手指拖动
            isScrolling = true;
            isBackScrolling = false;
            break;
        case 2:// 手指弹起
            isScrolling = false;
            isBackScrolling = true;
            break;
        default:// 0 动作完成
            isScrolling = false;
            isBackScrolling = false;
            break;
        }
    }
    @Override
    public void onClick(View v) {
        if (v.equals(TabTextView_BUS)) {
            //
            mViewPager.setCurrentItem(0);
            // ReadViewLocation(v);
        } else if (v.equals(TabTextView_KNX)) {
            //
            mViewPager.setCurrentItem(1);
            // ReadViewLocation(v);
        } else if (v.equals(TabTextView_Upgrade)) {
            //
            mViewPager.setCurrentItem(2);
            // ReadViewLocation(v);
        } else {
            //
        }
    }
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        try {
            if (Fragment_BUS.openBackLight != null) {
                if (!Fragment_BUS.openBackLight.isChecked()) {
                    SerialPort.BackLight_ON();
                    Fragment_BUS.openBackLight.setChecked(true);
                }
            }
        } catch (Exception e) {
            //
        }
        return super.dispatchTouchEvent(ev);
    }
}
app/src/main/java/android/serialport/api/sample/MyFragmentAdapter.java
New file
@@ -0,0 +1,28 @@
package android.serialport.api.sample;
import java.util.List;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class MyFragmentAdapter extends FragmentPagerAdapter {
    private List<Fragment> fragmentList;
    public MyFragmentAdapter(FragmentManager fm, List<Fragment> fragmentList) {
        super(fm);
        this.fragmentList = fragmentList;
    }
    @Override
    public Fragment getItem(int arg) {
        return fragmentList.get(arg);
    }
    @Override
    public int getCount() {
        return fragmentList.size();
    }
}
app/src/main/java/android/serialport/api/sample/MyService.java
New file
@@ -0,0 +1,40 @@
package android.serialport.api.sample;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
public class MyService extends Service {
    @Override
    public void onCreate() {
        super.onCreate();
        new Thread() {
            @Override
            public void run() {
                ReceiveAndSend.Start();
                super.run();
            }
        }.start();
    }
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return super.onStartCommand(intent, flags, startId);
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
    }
    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub
        return null;
    }
}
app/src/main/java/android/serialport/api/sample/NavigationDrawerFragment.java
New file
@@ -0,0 +1,174 @@
package android.serialport.api.sample;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import sendData.Commands;
import sendData.SendDatas;
public class NavigationDrawerFragment extends Fragment implements OnClickListener {
    public static NavigationDrawerFragment mNavigationDrawerFragment;
    private View mView;
    private static Button SaveBtn;
    private static EditText mSubNetEditText;
    private static EditText mDeviceEditText;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Log.i("asf", " onCreateView()");
        mView = (View) inflater.inflate(R.layout.fragment_navigation, container, false);
        iniView();
        iniData();
        return mView;
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i("asf", " onDestroy()");
    }
    @Override
    public void onStart() {
        super.onStart();
        Log.i("asf", " onStart()");
    }
    @Override
    public void onStop() {
        super.onStop();
        Log.i("asf", " onStop()");
    }
    private void iniView() {
        mSubNetEditText = (EditText) mView.findViewById(R.id.editText_SubNet);
        mDeviceEditText = (EditText) mView.findViewById(R.id.editText_Device);
        SaveBtn = (Button) mView.findViewById(R.id.save_btn);
        SaveBtn.setOnClickListener(this);
    }
    private void iniData() {
        mNavigationDrawerFragment = this;
        mSubNetEditText.setText(ReadSubNetID() + "");
        mDeviceEditText.setText(ReadDeviceID() + "");
        Global.SubNet_Id = ReadSubNetID();
        Global.Device_Id = ReadDeviceID();
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1500);
                } catch (Exception e) {
                }
                ReadLocation();// 读取子网号 设备号
            }
        }).start();
    }
    private void ReadLocation() {
        byte[] sendBytes = SendDatas.AddSendData(Commands.ReadID.getCommand(), 255, 255, new byte[] {});
        ReceiveAndSend.SendDatasList.add(sendBytes);
    }
    private void WriteLocation(int subnet_id, int device_id) {
        byte[] sendBytes = SendDatas.AddSendData(Commands.WriteID.getCommand(), (byte) Global.SubNet_Id,
                (byte) Global.Device_Id, new byte[] { (byte) subnet_id, (byte) device_id });
        ReceiveAndSend.SendDatasList.add(sendBytes);
    }
    @Override
    public void onClick(View v) {
        if (v.equals(SaveBtn)) {
            // 设置子网号设备号
            WriteLocation(Integer.parseInt(mSubNetEditText.getText().toString()),
                    Integer.parseInt(mDeviceEditText.getText().toString()));
        }
    }
    private void SaveID(int subNet_id, int device_id) {
        //
        SPDataSet.SaveSPData("DevicesID", "SubNetID", subNet_id);
        SPDataSet.SaveSPData("DevicesID", "DeviceID", device_id);
    }
    private int ReadSubNetID() {
        return SPDataSet.ReadSPData_Int("DevicesID", "SubNetID");
    }
    private int ReadDeviceID() {
        return SPDataSet.ReadSPData_Int("DevicesID", "DeviceID");
    }
    public Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case 0:
                Toast.makeText(getActivity(), "failed!", Toast.LENGTH_SHORT).show();
                break;
            case 1:
                Toast.makeText(getActivity(), "succeed!", Toast.LENGTH_SHORT).show();
                ReadLocation();
                break;
            default:
                break;
            }
        }
    };
    public Handler mHandler_Data = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            Global.BUS data = (Global.BUS) msg.obj;
            if (data == null)
                return;
            Global.SubNet_Id = data.value;
            Global.Device_Id = data.value2;
            mSubNetEditText.setText(data.value + "");
            mDeviceEditText.setText(data.value2 + "");
            SaveID(data.value, data.value2);
        }
    };
}
app/src/main/java/android/serialport/api/sample/ReceiveAndSend.java
New file
@@ -0,0 +1,400 @@
package android.serialport.api.sample;
import java.util.List;
import java.io.IOException;
import java.util.ArrayList;
import android.os.Message;
import android.widget.Toast;
import sendData.Commands;
import sendData.SendDatas;
import java.security.InvalidParameterException;
public class ReceiveAndSend {
    public static List<byte[]> SendDatasList = new ArrayList<byte[]>();
    public static void Start() {
        getSerialPort();
        new SendThread().start();
        new SendDatasThread().start();
        new ReadThread().start();
    }
    /**
     * Open the serial port, input and output streams
     */
    public static void getSerialPort() {
        Global.mApplication = new Application();
        try {
            Global.mSerialPort = Global.mApplication.getSerialPort();
            Global.mOutputStream = Global.mSerialPort.getOutputStream();
            Global.mInputStream = Global.mSerialPort.getInputStream();
            if (MainActivity.CuttentActivity.mFragment_BUS != null) {
                Global.BUS bus = new Global.BUS();
                Message msg = new Message();
                msg.obj = bus;
                bus.index = 11;
                bus.value = 1;
                bus.value2 = 1;
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
            }
        } catch (SecurityException e) {
            if (MainActivity.CuttentActivity.mFragment_BUS != null) {
                Global.BUS bus = new Global.BUS();
                Message msg = new Message();
                msg.obj = bus;
                bus.index = 11;
                bus.value = 0;
                bus.value2 = 0;
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
                msg = new Message();
                bus.index = -1;
                bus.str = "You do not have read/write permission to the serial port.";
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
            }
        } catch (IOException e) {
            if (MainActivity.CuttentActivity.mFragment_BUS != null) {
                Global.BUS bus = new Global.BUS();
                Message msg = new Message();
                msg.obj = bus;
                bus.index = 11;
                bus.value = 0;
                bus.value2 = 0;
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
                msg = new Message();
                bus.index = -1;
                bus.str = "The serial port can not be opened for an unknown reason.";
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
            }
        } catch (InvalidParameterException e) {
            if (MainActivity.CuttentActivity.mFragment_BUS != null) {
                Global.BUS bus = new Global.BUS();
                Message msg = new Message();
                msg.obj = bus;
                bus.index = 11;
                bus.value = 0;
                bus.value2 = 0;
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
                msg = new Message();
                bus.index = -1;
                bus.str = "error_configuration";
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
            }
        }
    }
    /**
     * Read data thread
     *
     * @author 2017年12月19日
     */
    private static class ReadThread extends Thread {
        @Override
        public void run() {
            super.run();
            while (!isInterrupted()) {
                int size = 0;
                try {
                    byte[] buffer = new byte[64];
                    if (Global.mInputStream == null) {
                        return;
                    }
                    size = Global.mInputStream.read(buffer);
                    // Log.i("asdfg", Integer.toHexString(((buffer[7] & 0xFF) *
                    // 256) + (buffer[8] & 0xFF)) + "");
                    for (int i = 0; i < size - 1; i++) {
                        if (i != 0) {
                            if ((buffer[i] & 0xFF) == 0xAA && (buffer[i + 1] & 0xFF) == 0xAA) {
                                //
                                byte[] _bf = new byte[i];
                                System.arraycopy(buffer, 0, _bf, 0, i);
                                if (_bf.length >= 13) {
                                    int command = (buffer[7] & 0xFF) * 256 + (buffer[8] & 0xFF);
                                    if (command == Commands.ReadTimeFeedback.getCommand()
                                            || command == Commands.DryContactInitiativeToSend.getCommand()
                                            || command == Commands.READ_TEMP_WITH_DRY1_ACK.getCommand()
                                            || command == Commands.InductorState.getCommand()
                                            || command == Commands.SensorBack.getCommand()
                                            || command == Commands.ClickState.getCommand()
                                            || command == Commands.ReadID_ACK.getCommand()
                                            || command == Commands.WriteID_ACK.getCommand()
                                            || command == Commands.DataRequest.getCommand()
                                            || command == Commands.readRemark_ACK.getCommand()) {
                                        onDataReceived(buffer, size);
                                    }
                                }
                                byte[] _bf2 = new byte[size - i];
                                System.arraycopy(buffer, i, _bf2, 0, size - i);
                                if (_bf2.length >= 13) {
                                    int command = (buffer[7] & 0xFF) * 256 + (buffer[8] & 0xFF);
                                    if (command == Commands.ReadTimeFeedback.getCommand()
                                            || command == Commands.DryContactInitiativeToSend.getCommand()
                                            || command == Commands.READ_TEMP_WITH_DRY1_ACK.getCommand()
                                            || command == Commands.InductorState.getCommand()
                                            || command == Commands.SensorBack.getCommand()
                                            || command == Commands.ClickState.getCommand()
                                            || command == Commands.ReadID_ACK.getCommand()
                                            || command == Commands.WriteID_ACK.getCommand()
                                            || command == Commands.DataRequest.getCommand()
                                            || command == Commands.readRemark_ACK.getCommand()) {
                                        onDataReceived(buffer, size);
                                    }
                                }
                            }
                        } else {
                            if (size >= 13) {
                                int command = (buffer[7] & 0xFF) * 256 + (buffer[8] & 0xFF);
                                if (command == Commands.ReadTimeFeedback.getCommand()
                                        || command == Commands.DryContactInitiativeToSend.getCommand()
                                        || command == Commands.READ_TEMP_WITH_DRY1_ACK.getCommand()
                                        || command == Commands.InductorState.getCommand()
                                        || command == Commands.SensorBack.getCommand()
                                        || command == Commands.ClickState.getCommand()
                                        || command == Commands.ReadID_ACK.getCommand()
                                        || command == Commands.WriteID_ACK.getCommand()
                                        || command == Commands.DataRequest.getCommand()
                                        || command == Commands.readRemark_ACK.getCommand()) {
                                    onDataReceived(buffer, size);
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    return;
                }
            }
        }
    }
    private static void onDataReceived(final byte[] buffer, final int size) {
        if (MainActivity.CuttentActivity.mFragment_BUS == null)
            return;
        Global.BUS bus = new Global.BUS();
        Message msg = new Message();
        try {
            int command = (buffer[7] & 0xFF) * 256 + (buffer[8] & 0xFF);
            if (command == Commands.ReadTimeFeedback.getCommand()) {
                //
            } else if (command == Commands.DryContactInitiativeToSend.getCommand()) {
                try {
                    Global.mOutputStream
                            .write(SendDatas.AddSendData(Commands.DryContactInitiativeToSendFeedback.getCommand(),
                                    Global.SubNet_Id, Global.Device_Id, new byte[] { (byte) 0xf8 }));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                bus.index = 1;
                bus.contact1 = buffer[11] & 0xFF;
                bus.contact2 = buffer[12] & 0xFF;
                bus.contact3 = buffer[13] & 0xFF;
                bus.contact4 = buffer[14] & 0xFF;
                bus.contact5 = buffer[15] & 0xFF;
                bus.contact6 = buffer[16] & 0xFF;
                msg.obj = bus;
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
            } else if (command == Commands.READ_TEMP_WITH_DRY1_ACK.getCommand()) {// 读取温度
                int value = (int) (buffer[11] & 0xFF);
                if ((buffer[13] & 0xFF) == 0) {
                    // 单位摄氏度
                    bus.index = 7;
                    bus.value = 0;
                    bus.value2 = value;
                    msg.obj = bus;
                    MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
                } else {
                    // 华氏度
                    bus.index = 7;
                    bus.value = 1;
                    bus.value2 = value;
                    msg.obj = bus;
                    MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
                }
            } else if (command == Commands.SensorBack.getCommand()) {
                // 传感器灵敏度
                bus.index = 8;
                bus.value = (int) (buffer[12] & 0xFF);
                bus.value2 = (int) (buffer[12] & 0xFF);
                msg.obj = bus;
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
            } else if (command == Commands.InductorState.getCommand()) {
                bus.index = 9;
                bus.value = 0;
                bus.value2 = 0;
                msg.obj = bus;
                MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
            } else if (command == Commands.ClickState.getCommand()) {
                int key = buffer[12] & 0xFF;
                switch (key) {
                case 0:// 弹起
                    bus.index = 109;
                    bus.value = 0;
                    bus.value2 = 0;
                    msg.obj = bus;
                    MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
                    break;
                case 1:// 按下
                    bus.index = 10;
                    bus.value = 1;
                    bus.value2 = 0;
                    msg.obj = bus;
                    MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
                    break;
                case 2:// 长按
                    bus.index = 10;
                    bus.value = 2;
                    bus.value2 = 0;
                    msg.obj = bus;
                    MainActivity.CuttentActivity.mFragment_BUS.mHandler.sendMessage(msg);
                    break;
                }
            } else if (command == Commands.SET_TEMP_COMPENSATE_VALUE_ACK.getCommand()) {
                if ((buffer[11] & 0xFF) == 0xF5) {
                    Toast.makeText(MainActivity.CuttentActivity, "set compensate value failed", Toast.LENGTH_SHORT)
                            .show();
                }
            } else if (command == Commands.WriteID_ACK.getCommand()) {
                // 写入ID返回
                if ((buffer[11] & 0xFF) == 0xF5) {
                    NavigationDrawerFragment.mNavigationDrawerFragment.mHandler.sendEmptyMessage(0);
                } else if ((buffer[11] & 0xFF) == 0xF8) {
                    NavigationDrawerFragment.mNavigationDrawerFragment.mHandler.sendEmptyMessage(1);
                }
            } else if (command == Commands.ReadID_ACK.getCommand()) {
                // 读取返回
                bus.value = buffer[11] & 0xFF;
                bus.value2 = buffer[12] & 0xFF;
                msg.obj = bus;
                NavigationDrawerFragment.mNavigationDrawerFragment.mHandler_Data.sendMessage(msg);
            } else if (command == Commands.DataRequest.getCommand()) {
                // 读取备注返回 / 设备升级 0x15FE buffer[11] buffer[12] 都为0的话,就是备注
                // Log.i("asdfg", "设备升级 0x15FE");
                int index = (buffer[11] & 0xFF) * 256 + (buffer[12] & 0xFF);// 请求的是第几条包
                Fragment_Update.mFragment_Update.mHandler.sendEmptyMessage(index);
            }
        } catch (Exception e) {
            e.getMessage();
        }
    }
    /**
     * 2015.12.10 读取温度
     */
    private static class SendThread extends Thread {
        @Override
        public void run() {
            super.run();
            while (true) {
                try {
                    byte[] sendBytes = SendDatas.AddSendData(Commands.READ_TEMP_WITH_DRY1.getCommand(),
                            Global.SubNet_Id, Global.Device_Id, new byte[] {});
                    Global.mOutputStream.flush();
                    Global.mOutputStream.write(sendBytes);
                    sleep(1000);
                } catch (Exception e) {
                    //
                    continue;
                }
            }
        }
    }
    private static class SendDatasThread extends Thread {
        @Override
        public void run() {
            super.run();
            while (true) {
                try {
                    Thread.sleep(100);
                } catch (Exception e) {
                    e.getMessage();
                }
                for (int i = 0; i < SendDatasList.size(); i++) {
                    try {
                        Thread.sleep(100);
                    } catch (Exception e) {
                    }
                    try {
                        byte[] sendBytes = SendDatasList.get(i);
                        try {
                            Global.mOutputStream.flush();
                            Global.mOutputStream.write(sendBytes);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        SendDatasList.remove(i);
                        i--;
                    } catch (Exception ex) {
                        ex.getMessage();
                    }
                }
            }
        }
    }
}
app/src/main/java/android/serialport/api/sample/SPDataSet.java
New file
@@ -0,0 +1,89 @@
package android.serialport.api.sample;
import java.util.Map;
import android.content.SharedPreferences;
public class SPDataSet {
    public static void SaveSPData(String fileName, String key, boolean value) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        SharedPreferences.Editor editor = SP.edit();
        editor.putBoolean(key, value);
        editor.commit();
        editor.apply();
    }
    public static void SaveSPData(String fileName, String key, String value) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        SharedPreferences.Editor editor = SP.edit();
        editor.putString(key, value);
        editor.commit();
        editor.apply();
    }
    public static void SaveSPData(String fileName, String key, int value) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        SharedPreferences.Editor editor = SP.edit();
        editor.putInt(key, value);
        editor.commit();
        editor.apply();
    }
    public static void SaveSPData(String fileName, String key, long value) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        SharedPreferences.Editor editor = SP.edit();
        editor.putLong(key, value);
        editor.commit();
        editor.apply();
    }
    public static String ReadSPData_String(String fileName, String key) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        return SP.getString(key, "");
    }
    public static boolean ReadSPData_boolean(String fileName, String key) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        return SP.getBoolean(key, false);
    }
    public static int ReadSPData_Int(String fileName, String key) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        return SP.getInt(key, 0);
    }
    public static long ReadSPData_Long(String fileName, String key) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        return SP.getLong(key, 0);
    }
    public static Map<String, ?> ReadAll(String fileName) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        return (Map<String, ?>) SP.getAll();
    }
    public static void DelItem(String fileName, String key) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        SharedPreferences.Editor editor = SP.edit();
        editor.remove(key);
        editor.commit();
    }
    public static void Clear(String fileName) {
        SharedPreferences SP = MainActivity.CuttentActivity.getSharedPreferences(fileName,
                MainActivity.CuttentActivity.MODE_PRIVATE);
        SharedPreferences.Editor editor = SP.edit();
        editor.clear();
        editor.commit();
    }
}
app/src/main/java/android/serialport/api/sample/SerialPortPreferences.java
New file
@@ -0,0 +1,66 @@
/*
 * Copyright 2009 Cedric Priscal
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.serialport.api.sample;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.serialport.api.SerialPortFinder;
import android.serialport.api.sample.R;
import android.preference.PreferenceActivity;
public class SerialPortPreferences extends PreferenceActivity {
    private Application mApplication;
    private SerialPortFinder mSerialPortFinder;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //mApplication = (Application) getApplication();
        mApplication = new Application();
        mSerialPortFinder = mApplication.mSerialPortFinder;
        addPreferencesFromResource(R.xml.serial_port_preferences);
        // Devices
        final ListPreference devices = (ListPreference)findPreference("DEVICE");
        String[] entries = mSerialPortFinder.getAllDevices();
        String[] entryValues = mSerialPortFinder.getAllDevicesPath();
        devices.setEntries(entries);
        devices.setEntryValues(entryValues);
        devices.setSummary(devices.getValue());
        devices.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                preference.setSummary((String)newValue);
                return true;
            }
        });
        // Baud rates
        final ListPreference baudrates = (ListPreference)findPreference("BAUDRATE");
        baudrates.setSummary(baudrates.getValue());
        baudrates.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                preference.setSummary((String)newValue);
                return true;
            }
        });
    }
}
app/src/main/java/sendData/CRC.java
New file
@@ -0,0 +1,95 @@
package sendData;
/// <summary>
/// CRC ��ժҪ˵����
/// </summary>
public class CRC
{
    public CRC()
    {
        //
        // TODO: 锟节此达拷锟斤拷庸锟斤拷旌拷锟斤拷呒锟?
        //
    }
    private static int[] crctab = new int[]
    {
        0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
        0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
        0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
        0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
        0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
        0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
        0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
        0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
        0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
        0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
        0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
        0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
        0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
        0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
        0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
        0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
        0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
        0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
        0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
        0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
        0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
        0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
        0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
        0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
        0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
        0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
        0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
        0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
        0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
        0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
        0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
        0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
    };
    private static int xcrc(int crc, byte cp)
    {
        int t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0;
        t1 = (int)(crc >> 8);
        t2 = (int)(t1 & 0xff);
        t3 = (int)(cp & 0xff);
        t4 = (int)(crc << 8);
        t5 = (int)(t2 ^ t3);
        t6 = (int)(crctab[t5] ^ t4);
        return t6;
    }
    public static void ConCRC(byte[] bufin, int n)
    {
        int crc16 = 0;
        byte i;
        //n����ݵ�CRCУ��
        for (i = 0; i < n; i++)
        {
            crc16 = xcrc(crc16, bufin[i]);
        }
        bufin[i] = (byte)(crc16 >> 8);
        bufin[i + 1] = (byte)(crc16 & 0xff);
    }
    public static boolean DataCRC( byte[] bufout, int count)
    {
        int crc16 = 0;
        byte i;
        for (i = 0; i < (count - 2); i++)
            crc16 = xcrc(crc16, bufout[i]);
        if ((bufout[count - 2] == (byte)(crc16 >> 8)) && (bufout[count - 1] == (byte)(crc16 & 0xff)))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}
app/src/main/java/sendData/Commands.java
New file
@@ -0,0 +1,34 @@
package sendData;
public enum Commands {
    /** 微波传感器设参数配置 1标记(0:读 1:写+值(0-10)0表示禁用1-10个等级 1最低 10最高) */
    Sensor(0xEF22), SensorBack(0xEF23), InductorState(0xEF24), ClickState(0xEF25),
    regulationControl(0x0031), ReadID(0XEF32), ReadID_ACK(0XEF33),
    buzzer(0XEF08), WriteID(0XEF34), WriteID_ACK(0XEF35), DataRequest(0x15FE),DataRequest_ACK(0x15FF),
    ReadTime(0xEF04), ReadTimeFeedback(0xEF05), readRemark(0xF81A), readRemark_ACK(0xF81B),
    DryContactInitiativeToSend(0xEF00), DryContactInitiativeToSendFeedback(0xEF01),
    WriteTime(0xEF06), WriteTimeFeedback(0xEF07),
    BackLight(0xEF10), BackLightback(0xEF11),
    /** 附加一字节的温度 +摄氏度0、华氏度1 + 温度补尝 5-15 默认10 */
    READ_TEMP_WITH_DRY1(0xEF12), READ_TEMP_WITH_DRY1_ACK(0XEF13),
    SET_TEMP_COMPENSATE_VALUE(0XEF14), SET_TEMP_COMPENSATE_VALUE_ACK(0XEF15);
    private int command;
    private Commands(int value) {
        this.command = value;
    }
    public int getCommand() {
        return command;
    }
}
app/src/main/java/sendData/SendDatas.java
New file
@@ -0,0 +1,80 @@
package sendData;
public class SendDatas {
    //SubnetID
    public int DesSubnetID;
    //DeviceID
    public int DesDeviceID;
    //Send additional data
    public byte[] AddBytes =new byte[]{};
    //Source subnet addresses 0-254
    public static int LocalSubnetID = 250;
    //source device address 0-254
    public static int LocalDeviceID = 251;
    // Device type
    public static int DeviceType = 424;
    //opcode
    public int Command;
    public byte []GetSendBytes(){
        //Data and to compute the CRC of CRC two bytes
        byte []crcBytes = new byte[9+this.AddBytes.length+2];
        //Send out the data
        byte []sendBytes = new byte[2+crcBytes.length];
        //Boot code
        sendBytes[0]=(byte)0xAA;
        sendBytes[1]=(byte)0xAA;
        //16    The length of the packet   11-78
        crcBytes[0]=(byte)crcBytes.length;
        //17    Source subnet addresses  0-254
        crcBytes[1]=(byte)LocalSubnetID;
        //18    source device address   0-254
        crcBytes[2]=(byte)LocalDeviceID;
        //19    High source device type
        crcBytes[3]=(byte)(DeviceType/256);
        //20    The source device type low
        crcBytes[4]=(byte)(DeviceType%256);
        //21    Opcode high
        crcBytes[5]=(byte)(this.Command/256);
        //22    Opcode low
        crcBytes[6]=(byte)(this.Command%256);
        //23    The target subnet addresses  0-254
        crcBytes[7]=(byte)this.DesSubnetID;
        //24    The destination address  0-254
        crcBytes[8]=(byte)this.DesDeviceID;
        //25~n  Additional data
        System.arraycopy(this.AddBytes, 0, crcBytes, 9, this.AddBytes.length);
        //Check CRC
        CRC.ConCRC(crcBytes, crcBytes.length-2);
        //Copy the CRC data to send data
        System.arraycopy(crcBytes, 0,sendBytes, 2, crcBytes.length);
        return sendBytes;
    }
    //send data
    public static byte []AddSendData(int command,int desSubnetID,int desDeviceID,byte []addBytes){
        SendDatas sendDatas = new SendDatas();
        sendDatas.Command=command;
        sendDatas.DesSubnetID=desSubnetID;
        sendDatas.DesDeviceID=desDeviceID;
        sendDatas.AddBytes=addBytes;
        byte []sendBytes = sendDatas.GetSendBytes();
        return sendBytes;
    }
}
app/src/main/jni/Android.mk
New file
@@ -0,0 +1,13 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := serial_port
LOCAL_SRC_FILES := \
android_serialport_api_SerialPort.c\
android_serialport_api_sample_KNX.c\
LOCAL_LDLIBS    := -llog
include $(BUILD_SHARED_LIBRARY)
app/src/main/jni/android_serialport_api_SerialPort.c
New file
@@ -0,0 +1,244 @@
/*
 * Copyright 2009-2011 Cedric Priscal
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <err.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <linux/input.h>
#include "sun8iw6p_display.h"
#include <errno.h>
#include <termios.h>
#include <string.h>
#include "android/log.h"
#define POWER_KEY_PATH           "/dev/input/event2"
#define DEVICE_DISP_PATH           "/dev/disp"
static const char *TAG = "serial_port";
unsigned long args[3];
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO,  TAG, fmt, ##args)
#define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, TAG, fmt, ##args)
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##args)
static speed_t getBaudrate(jint baudrate) {
    switch (baudrate) {
    case 0:
        return B0;
    case 50:
        return B50;
    case 75:
        return B75;
    case 110:
        return B110;
    case 134:
        return B134;
    case 150:
        return B150;
    case 200:
        return B200;
    case 300:
        return B300;
    case 600:
        return B600;
    case 1200:
        return B1200;
    case 1800:
        return B1800;
    case 2400:
        return B2400;
    case 4800:
        return B4800;
    case 9600:
        return B9600;
    case 19200:
        return B19200;
    case 38400:
        return B38400;
    case 57600:
        return B57600;
    case 115200:
        return B115200;
    case 230400:
        return B230400;
    case 460800:
        return B460800;
    case 500000:
        return B500000;
    case 576000:
        return B576000;
    case 921600:
        return B921600;
    case 1000000:
        return B1000000;
    case 1152000:
        return B1152000;
    case 1500000:
        return B1500000;
    case 2000000:
        return B2000000;
    case 2500000:
        return B2500000;
    case 3000000:
        return B3000000;
    case 3500000:
        return B3500000;
    case 4000000:
        return B4000000;
    default:
        return -1;
    }
}
/*
 * Class:     android_serialport_api_SerialPort
 * Method:    BackLight_ON
 * Signature: ()V
 */JNIEXPORT jint JNICALL Java_android_serialport_api_SerialPort_BackLight_1ON(
        JNIEnv *evn, jobject obj) {
    int blanklight_id = open(DEVICE_DISP_PATH, O_RDWR);
    if (blanklight_id < 0) {
        return -1;
    }
    args[0] = 0;
    args[1] = 0;
    LOGI("Open");
    return (jint) ioctl(blanklight_id, DISP_BLANK, args);
}
/*
 * Class:     android_serialport_api_SerialPort
 * Method:    BackLight_OFF
 * Signature: ()V
 */JNIEXPORT jint JNICALL Java_android_serialport_api_SerialPort_BackLight_1OFF(
        JNIEnv *evn, jobject obj) {
    int blanklight_id = open(DEVICE_DISP_PATH, O_RDWR);
    if (blanklight_id < 0) {
        return -1;
    }
    args[0] = 0;
    args[1] = 1;
    LOGI("Close");
    return (jint) ioctl(blanklight_id, DISP_BLANK, args);
}
/*
 * Class:     android_serialport_SerialPort
 * Method:    open
 * Signature: (Ljava/lang/String;II)Ljava/io/FileDescriptor;
 */JNIEXPORT jobject JNICALL Java_android_serialport_api_SerialPort_open(
        JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags) {
    int fd;
    speed_t speed;
    jobject mFileDescriptor;
    /* Check arguments */
    {
        speed = getBaudrate(baudrate);
        if (speed == -1) {
            /* TODO: throw an exception */
            LOGE("Invalid baudrate");
            return NULL;
        }
    }
    /* Opening device */
    {
        jboolean iscopy;
        const char *path_utf = (*env)->GetStringUTFChars(env, path, &iscopy);
        LOGD("Opening serial port %s with flags 0x%x",
                path_utf, O_RDWR | flags);
        fd = open(path_utf, O_RDWR | flags);
        LOGD("open() fd = %d", fd);
        (*env)->ReleaseStringUTFChars(env, path, path_utf);
        if (fd == -1) {
            /* Throw an exception */
            LOGE("Cannot open port");
            return NULL;
        }
    }
    /* Configure device */
    {
        struct termios cfg;
        LOGD("Configuring serial port");
        if (tcgetattr(fd, &cfg)) {
            LOGE("tcgetattr() failed");
            close(fd);
            return NULL;
        }
        cfmakeraw(&cfg);
        cfsetispeed(&cfg, speed);
        cfsetospeed(&cfg, speed);
        if (tcsetattr(fd, TCSANOW, &cfg)) {
            LOGE("tcsetattr() failed");
            close(fd);
            return NULL;
        }
    }
    /* Create a corresponding file descriptor */
    {
        jclass cFileDescriptor = (*env)->FindClass(env, "java/io/FileDescriptor");
        jmethodID iFileDescriptor = (*env)->GetMethodID(env, cFileDescriptor, "<init>", "()V");
        jfieldID descriptorID = (*env)->GetFieldID(env, cFileDescriptor, "descriptor", "I");
        mFileDescriptor = (*env)->NewObject(env, cFileDescriptor, iFileDescriptor);
        (*env)->SetIntField(env, mFileDescriptor, descriptorID, (jint) fd);
    }
    return mFileDescriptor;
}
/*
 * Class:     cedric_serial_SerialPort
 * Method:    close
 * Signature: ()V
 */JNIEXPORT void JNICALL Java_android_serialport_api_SerialPort_close(
        JNIEnv *env, jobject thiz) {
    jclass SerialPortClass = (*env)->GetObjectClass(env, thiz);
    jclass FileDescriptorClass = (*env)->FindClass(env,
            "java/io/FileDescriptor");
    jfieldID mFdID = (*env)->GetFieldID(env, SerialPortClass, "mFd",
            "Ljava/io/FileDescriptor;");
    jfieldID descriptorID = (*env)->GetFieldID(env, FileDescriptorClass,
            "descriptor", "I");
    jobject mFd = (*env)->GetObjectField(env, thiz, mFdID);
    jint descriptor = (*env)->GetIntField(env, mFd, descriptorID);
    LOGD("close(fd = %d)", descriptor);
    close(descriptor);
}
app/src/main/jni/android_serialport_api_SerialPort.h
New file
@@ -0,0 +1,41 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class android_serialport_api_SerialPort */
#ifndef _Included_android_serialport_api_SerialPort
#define _Included_android_serialport_api_SerialPort
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     android_serialport_api_SerialPort
 * Method:    open
 * Signature: (Ljava/lang/String;II)Ljava/io/FileDescriptor;
 */
JNIEXPORT jobject JNICALL Java_android_serialport_api_SerialPort_open(JNIEnv *, jclass, jstring, jint, jint);
/*
 * Class:     android_serialport_api_SerialPort
 * Method:    close
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_android_serialport_api_SerialPort_close(JNIEnv *, jobject);
/*
 * Class:     android_serialport_api_SerialPort
 * Method:    BackLight_ON
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_android_serialport_api_SerialPort_BackLight_1ON(JNIEnv *, jobject);
/*
 * Class:     android_serialport_api_SerialPort
 * Method:    BackLight_OFF
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_android_serialport_api_SerialPort_BackLight_1OFF(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
app/src/main/jni/android_serialport_api_sample_KNX.c
New file
@@ -0,0 +1,244 @@
#include <jni.h>
#include "android/log.h"
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO,  TAG, fmt, ##args)
#define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, TAG, fmt, ##args)
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##args)
#define unchar unsigned char
#define unint  unsigned short
#define A_Preamble_OFFSET                  0
#define A_Size_OFFSET                      1
#define A_Service_ID_OFFSET                2
#define A_Service_Frame_OFFSET             3
unsigned short Get_CRC_CCITT(unsigned short u_crc_val, unsigned char btVal) {
    u_crc_val = ((unsigned char) (u_crc_val >> 8)) | (u_crc_val << 8);
    u_crc_val ^= btVal;
    u_crc_val ^= ((unsigned char) (u_crc_val & 0xFF)) >> 4;
    u_crc_val ^= u_crc_val << 12;
    u_crc_val ^= (u_crc_val & 0xFF) << 5;
    return u_crc_val;
}
unsigned short Calc_CRC_CCITT(unsigned char* pBuf, unsigned short uLength) {
    unsigned short u_crc_ccitt;
    for (u_crc_ccitt = 0xFFFF; uLength--; pBuf++) {
        u_crc_ccitt = Get_CRC_CCITT(u_crc_ccitt, *pBuf);
    }
    return u_crc_ccitt;
}
#define false 0
#define true 1
//Android UART protocol define
#define UART_Preamble_OFFSET 0
#define UART_Size_OFFSET 1
#define UART_Service_ID_OFFSET 2
#define UART_Service_Frame_OFFSET 3
//L_Data_Standard Frame size
const unsigned char DataSize_TAB[16] = { 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 1,
        1, 2, 3, 4, 6, 8, 10, 14, 14 };
#define DATA_Type_1BIT 0
#define DATA_Type_2BIT 1
#define DATA_Type_3BIT 2
#define DATA_Type_4BIT 3
#define DATA_Type_5BIT 4
#define DATA_Type_6BIT 5
#define DATA_Type_7BIT 6
#define DATA_Type_8BIT 7
#define DATA_Type_2byte 8
#define DATA_Type_3byte 9
#define DATA_Type_4byte 10
#define DATA_Type_6byte 11
#define DATA_Type_8byte 12
#define DATA_Type_10byte 13
#define DATA_Type_14byte 14
//get short group address from main, middle, sub
#define EIB_Group_Addr3(main, middle, sub) ((main&0x0f)<<11|(middle&0x07)<<8|(sub&0x0ff))
// frame service
#define A_SERVICE_NO 0
#define A_SERVICE_L_Data_Frame_req 1
#define A_SERVICE_L_Data_Frame_ind 3
//----------------------------------------------------------------------------------------------------//
//this function encode group telegram to *p_suart_buf.
//source_addr:Individual address
//dest_addr:Group address
//*p_data:data for send
//data_type:data type 1 bit..14 bytes
//*p_suart_buf: send this buf to uart
//this function return send size
//----------------------------------------------------------------------------------------------------//
unsigned char UART_EncodeGroupTelegram(unsigned short source_addr,
        unsigned short dest_addr, unsigned char *p_data,
        unsigned char data_type, unsigned char *p_suart_buf) {
    unsigned char crc_h, crc_l, count, data_size, l_data_len, uart_size;
    unsigned short crc;
    p_suart_buf[UART_Service_Frame_OFFSET + 0] = 0xBC;
    p_suart_buf[UART_Service_Frame_OFFSET + 1] = (unsigned char) ((source_addr
            >> 8) & 0x00ff);
    p_suart_buf[UART_Service_Frame_OFFSET + 2] = (unsigned char) (source_addr
            & 0x00ff);
    p_suart_buf[UART_Service_Frame_OFFSET + 3] = (unsigned char) ((dest_addr
            >> 8) & 0x00ff);
    p_suart_buf[UART_Service_Frame_OFFSET + 4] = (unsigned char) (dest_addr
            & 0x00ff);
    p_suart_buf[UART_Service_Frame_OFFSET + 5] = 0xE0;
    p_suart_buf[UART_Service_Frame_OFFSET + 6] = 0x00;
    p_suart_buf[UART_Service_Frame_OFFSET + 7] = 0x80;
    if (data_type < 6) {
        p_suart_buf[UART_Service_Frame_OFFSET + 5] |= 0x01;
        p_suart_buf[UART_Service_Frame_OFFSET + 7] |= p_data[0]
                & DataSize_TAB[data_type];
    } else {
        data_size = DataSize_TAB[data_type];
        p_suart_buf[UART_Service_Frame_OFFSET + 5] |= data_size + 1;
        for (count = 0; count < data_size; count++)
            p_suart_buf[UART_Service_Frame_OFFSET + 8 + count] = p_data[count];
    }
    l_data_len = (p_suart_buf[UART_Service_Frame_OFFSET + 5] & 0x0f) + 7;
    uart_size = l_data_len + 5;
    p_suart_buf[UART_Preamble_OFFSET] = 0xAA;
    p_suart_buf[UART_Size_OFFSET] = uart_size;
    p_suart_buf[UART_Service_ID_OFFSET] = A_SERVICE_L_Data_Frame_req;
    crc = Calc_CRC_CCITT(p_suart_buf, uart_size - 2);
    crc_h = (unchar) ((crc >> 8) & 0x00ff);
    crc_l = (unchar) (crc & 0x00ff);
    p_suart_buf[A_Service_Frame_OFFSET + l_data_len] = crc_h;
    p_suart_buf[A_Service_Frame_OFFSET + l_data_len + 1] = crc_l;
    return uart_size;
}
//----------------------------------------------------------------------------------------------------//
//this function decode the *p_ruart_buf telegram to:
//*p_source_addr,*p_dest_addr,*p_data,*p_data_size
//return true: decoding success
//return false: decoding failure
//----------------------------------------------------------------------------------------------------//
unsigned char UART_DecodeGroupTelegram(unsigned short *p_source_addr,
        unsigned short *p_dest_addr, unsigned char *p_data,
        unsigned char *p_data_size, unsigned char *p_ruart_buf) {
    unchar crc_h, crc_l, count, data_size, uart_size;
    unint crc;
    uart_size = p_ruart_buf[UART_Size_OFFSET];
    if (uart_size < 13)
        return false;
    crc = Calc_CRC_CCITT(p_ruart_buf, uart_size - 2);
    crc_h = (unchar) ((crc >> 8) & 0x00ff);
    crc_l = (unchar) (crc & 0x00ff);
    if ((crc_h != p_ruart_buf[uart_size - 2])
            || (crc_l != p_ruart_buf[uart_size - 1]))
        return false; //check CRC
    if (p_ruart_buf[UART_Service_ID_OFFSET] != A_SERVICE_L_Data_Frame_ind)
        return false; //ind frame
    if ((p_ruart_buf[UART_Service_Frame_OFFSET] & 0xd3) != 0x90)
        return false;
    if ((p_ruart_buf[UART_Service_Frame_OFFSET + 5] & 0x80) != 0x80)
        return false; //not group telegram
    *p_source_addr = p_ruart_buf[UART_Service_Frame_OFFSET + 1];
    *p_source_addr <<= 8;
    *p_source_addr |= p_ruart_buf[UART_Service_Frame_OFFSET + 2];
    *p_dest_addr = p_ruart_buf[UART_Service_Frame_OFFSET + 3];
    *p_dest_addr <<= 8;
    *p_dest_addr |= p_ruart_buf[UART_Service_Frame_OFFSET + 4];
    data_size = p_ruart_buf[UART_Service_Frame_OFFSET + 5] & 0x0f;
    if (data_size == 1) {
        p_data[0] = p_ruart_buf[UART_Service_Frame_OFFSET + 7] & 0x3f;
    } else {
        for (count = 0; count < (data_size - 1); count++)
            p_data[count] = p_ruart_buf[UART_Service_Frame_OFFSET + 8 + count];
        data_size -= 1;
    }
    *p_data_size = data_size;
    return true;
}
void UART_Send(void) {
    unsigned short individual_addr = 0x1101; //1.1.1
    unsigned short group_addr = EIB_Group_Addr3(1,0,1); //1/0/1
    unsigned char data_buf[2], suart_buf[22 + 5];
    unsigned char uart_size;
    data_buf[0] = 0x01; //ON (unsigned char)int
    uart_size = UART_EncodeGroupTelegram(individual_addr, group_addr, data_buf,
            DATA_Type_1BIT, suart_buf);
}
JNIEXPORT jbyteArray JNICALL Java_android_serialport_api_sample_KNX_get_1SendBuffer(
        JNIEnv *env, jclass thiz, jint _individual_addr, jint obj1, jint obj2,
        jint obj3, jint on_off) {
    unsigned short individual_addr = (unsigned short) _individual_addr;
    unsigned short group_addr =
            EIB_Group_Addr3((unsigned char)obj1,(unsigned char)obj2,(unsigned char)obj3); //1/0/1
    unsigned char data_buf[2], suart_buf[22 + 5];
    unsigned char uart_size;
    data_buf[0] = (unsigned char) on_off; //0x01; //ON (unsigned char)int
    uart_size = UART_EncodeGroupTelegram(individual_addr, group_addr, data_buf,
            DATA_Type_1BIT, suart_buf);
    jbyteArray array = (*env)->NewByteArray(env, 27);
    (*env)->SetByteArrayRegion(env, array, 0, 27, suart_buf);
    return array;
}
JNIEXPORT jboolean JNICALL Java_android_serialport_api_sample_KNX_Parity_1Data(
        JNIEnv *env, jclass thiz, jbyteArray buffer) {
    unchar *p_ruart_buf = (unchar *) buffer;
    unsigned short individual_addr, group_addr;
    unsigned char data_buf[14];
    unsigned char data_size;
    if (!UART_DecodeGroupTelegram(&individual_addr, &group_addr, data_buf,
            &data_size, p_ruart_buf))
        return false;
    return true;
}
unsigned short Individual_addr, Group_addr;
unsigned char Data_buf[14];
JNIEXPORT jboolean JNICALL Java_android_serialport_api_sample_KNX_UART_1Receive(
        JNIEnv *env, jclass thiz, jbyteArray array) {
    jint len = (*env)->GetArrayLength(env, array);
    unchar p_ruart_buf[len];
    (*env)->GetByteArrayRegion(env, array, 0, len, p_ruart_buf);
    unsigned char data_size;
    if (!UART_DecodeGroupTelegram(&Individual_addr, &Group_addr, Data_buf,
            &data_size, p_ruart_buf))
        return false;
    return true;
}
JNIEXPORT jint JNICALL Java_android_serialport_api_sample_KNX_get_1Individual_1addr(
        JNIEnv *env, jclass thiz) {
    return (jint) Individual_addr;
}
JNIEXPORT jint JNICALL Java_android_serialport_api_sample_KNX_get_1Group_1addr(
        JNIEnv *env, jclass thiz) {
    return (jint) Group_addr;
}
JNIEXPORT jint JNICALL Java_android_serialport_api_sample_KNX_set_1Group_1addr(
        JNIEnv *env, jclass thiz, jint obj1, jint obj2, jint obj3) {
    unsigned short group_addr =
            EIB_Group_Addr3((unsigned char)obj1,(unsigned char)obj2,(unsigned char)obj3);
    return (jint) group_addr;
}
JNIEXPORT jint JNICALL Java_android_serialport_api_sample_KNX_get_1State(
        JNIEnv *env, jclass thiz) {
    return (jint) Data_buf[0];
}
app/src/main/jni/android_serialport_api_sample_KNX.h
New file
@@ -0,0 +1,27 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class android_serialport_api_SerialPort */
#ifndef _Included_android_serialport_api_sample_KNX
#define _Included_android_serialport_api_sample_KNX
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jbyteArray JNICALL Java_android_serialport_api_sample_KNX_get_1SendBuffer(JNIEnv *, jclass, jbyte, jint, jint, jint, jint);
JNIEXPORT jboolean JNICALL Java_android_serialport_api_sample_KNX_Parity_1Data(JNIEnv *, jclass, jbyteArray);
JNIEXPORT jbyteArray JNICALL Java_android_serialport_api_sample_KNX_get_1Individual_1addr(JNIEnv *, jclass);
JNIEXPORT jint JNICALL Java_android_serialport_api_sample_KNX_get_1Group_1addr(JNIEnv *, jclass);
JNIEXPORT jint JNICALL Java_android_serialport_api_sample_KNX_set_1Group_1addr(JNIEnv *, jclass, jint, jint, jint);
JNIEXPORT jint JNICALL Java_android_serialport_api_sample_KNX_get_1State(JNIEnv *, jclass);
JNIEXPORT jboolean JNICALL Java_android_serialport_api_sample_KNX_UART_1Receive(JNIEnv *, jclass, jbyteArray);
#ifdef __cplusplus
}
#endif
#endif
app/src/main/jni/sun8iw6p_display.h
New file
@@ -0,0 +1,429 @@
#ifndef __SUN8XI6P_DISPLAY_H__
#define __SUN8XI6P_DISPLAY_H__
#define bool signed char
typedef signed char         __s8;
typedef unsigned char       __u8;
typedef signed short        __s16;
typedef unsigned short      __u16;
typedef signed int          __s32;
typedef unsigned int        __u32;
typedef unsigned int        u32;
typedef signed long long    __s64;
typedef unsigned long long  __u64;
typedef struct {unsigned char  alpha;unsigned char red;unsigned char green; unsigned char blue; }disp_color;
typedef struct {int x; int y; unsigned int width; unsigned int height;}disp_rect;
typedef struct {unsigned int width;unsigned int height;                   }disp_rectsz;
typedef struct {int x; int y;                           }disp_position;
typedef enum
{
    DISP_FORMAT_ARGB_8888                    = 0x00,//MSB  A-R-G-B  LSB
    DISP_FORMAT_ABGR_8888                    = 0x01,
    DISP_FORMAT_RGBA_8888                    = 0x02,
    DISP_FORMAT_BGRA_8888                    = 0x03,
    DISP_FORMAT_XRGB_8888                    = 0x04,
    DISP_FORMAT_XBGR_8888                    = 0x05,
    DISP_FORMAT_RGBX_8888                    = 0x06,
    DISP_FORMAT_BGRX_8888                    = 0x07,
    DISP_FORMAT_RGB_888                      = 0x08,
    DISP_FORMAT_BGR_888                      = 0x09,
    DISP_FORMAT_RGB_565                      = 0x0a,
    DISP_FORMAT_BGR_565                      = 0x0b,
    DISP_FORMAT_ARGB_4444                    = 0x0c,
    DISP_FORMAT_ABGR_4444                    = 0x0d,
    DISP_FORMAT_RGBA_4444                    = 0x0e,
    DISP_FORMAT_BGRA_4444                    = 0x0f,
    DISP_FORMAT_ARGB_1555                    = 0x10,
    DISP_FORMAT_ABGR_1555                    = 0x11,
    DISP_FORMAT_RGBA_5551                    = 0x12,
    DISP_FORMAT_BGRA_5551                    = 0x13,
    /* SP: semi-planar, P:planar, I:interleaved
     * UVUV: U in the LSBs;     VUVU: V in the LSBs */
    DISP_FORMAT_YUV444_I_AYUV                = 0x40,//MSB  A-Y-U-V  LSB, reserved
    DISP_FORMAT_YUV444_I_VUYA                = 0x41,//MSB  V-U-Y-A  LSB
    DISP_FORMAT_YUV422_I_YVYU                = 0x42,//MSB  Y-V-Y-U  LSB
    DISP_FORMAT_YUV422_I_YUYV                = 0x43,//MSB  Y-U-Y-V  LSB
    DISP_FORMAT_YUV422_I_UYVY                = 0x44,//MSB  U-Y-V-Y  LSB
    DISP_FORMAT_YUV422_I_VYUY                = 0x45,//MSB  V-Y-U-Y  LSB
    DISP_FORMAT_YUV444_P                     = 0x46,//MSB  P3-2-1-0 LSB,  YYYY UUUU VVVV, reserved
    DISP_FORMAT_YUV422_P                     = 0x47,//MSB  P3-2-1-0 LSB   YYYY UU   VV
    DISP_FORMAT_YUV420_P                     = 0x48,//MSB  P3-2-1-0 LSB   YYYY U    V
    DISP_FORMAT_YUV411_P                     = 0x49,//MSB  P3-2-1-0 LSB   YYYY U    V
    DISP_FORMAT_YUV422_SP_UVUV               = 0x4a,//MSB  V-U-V-U  LSB
    DISP_FORMAT_YUV422_SP_VUVU               = 0x4b,//MSB  U-V-U-V  LSB
    DISP_FORMAT_YUV420_SP_UVUV               = 0x4c,
    DISP_FORMAT_YUV420_SP_VUVU               = 0x4d,
    DISP_FORMAT_YUV411_SP_UVUV               = 0x4e,
    DISP_FORMAT_YUV411_SP_VUVU               = 0x4f,
}disp_pixel_format;
typedef enum
{
    DISP_3D_OUT_MODE_CI_1 = 0x5,//column interlaved 1
    DISP_3D_OUT_MODE_CI_2 = 0x6,//column interlaved 2
    DISP_3D_OUT_MODE_CI_3 = 0x7,//column interlaved 3
    DISP_3D_OUT_MODE_CI_4 = 0x8,//column interlaved 4
    DISP_3D_OUT_MODE_LIRGB = 0x9,//line interleaved rgb
    DISP_3D_OUT_MODE_TB = 0x0,//top bottom
    DISP_3D_OUT_MODE_FP = 0x1,//frame packing
    DISP_3D_OUT_MODE_SSF = 0x2,//side by side full
    DISP_3D_OUT_MODE_SSH = 0x3,//side by side half
    DISP_3D_OUT_MODE_LI = 0x4,//line interleaved
    DISP_3D_OUT_MODE_FA = 0xa,//field alternative
}disp_3d_out_mode;
typedef enum
{
    DISP_BT601  = 0,
    DISP_BT709  = 1,
    DISP_YCC    = 2,
}disp_color_space;
typedef enum
{
    DISP_CSC_TYPE_RGB        = 0,
    DISP_CSC_TYPE_YUV1       = 1,//HDMI
    DISP_CSC_TYPE_YUV2       = 2,//TV
}disp_csc_type;
typedef enum
{
    DISP_COLOR_RANGE_16_255 = 0,
    DISP_COLOR_RANGE_0_255  = 1,
    DISP_COLOR_RANGE_16_235 = 2,
}disp_color_range;
typedef enum
{
    DISP_OUTPUT_TYPE_NONE   = 0,
    DISP_OUTPUT_TYPE_LCD    = 1,
    DISP_OUTPUT_TYPE_TV     = 2,
    DISP_OUTPUT_TYPE_HDMI   = 4,
    DISP_OUTPUT_TYPE_VGA    = 8,
}disp_output_type;
typedef enum
{
    DISP_TV_MOD_480I                = 0,
    DISP_TV_MOD_576I                = 1,
    DISP_TV_MOD_480P                = 2,
    DISP_TV_MOD_576P                = 3,
    DISP_TV_MOD_720P_50HZ           = 4,
    DISP_TV_MOD_720P_60HZ           = 5,
    DISP_TV_MOD_1080I_50HZ          = 6,
    DISP_TV_MOD_1080I_60HZ          = 7,
    DISP_TV_MOD_1080P_24HZ          = 8,
    DISP_TV_MOD_1080P_50HZ          = 9,
    DISP_TV_MOD_1080P_60HZ          = 0xa,
    DISP_TV_MOD_1080P_24HZ_3D_FP    = 0x17,
    DISP_TV_MOD_720P_50HZ_3D_FP     = 0x18,
    DISP_TV_MOD_720P_60HZ_3D_FP     = 0x19,
    DISP_TV_MOD_1080P_25HZ          = 0x1a,
    DISP_TV_MOD_1080P_30HZ          = 0x1b,
    DISP_TV_MOD_PAL                 = 0xb,
    DISP_TV_MOD_PAL_SVIDEO          = 0xc,
    DISP_TV_MOD_NTSC                = 0xe,
    DISP_TV_MOD_NTSC_SVIDEO         = 0xf,
    DISP_TV_MOD_PAL_M               = 0x11,
    DISP_TV_MOD_PAL_M_SVIDEO        = 0x12,
    DISP_TV_MOD_PAL_NC              = 0x14,
    DISP_TV_MOD_PAL_NC_SVIDEO       = 0x15,
    DISP_TV_MOD_3840_2160P_30HZ     = 0x1c,
    DISP_TV_MOD_3840_2160P_25HZ     = 0x1d,
    DISP_TV_MOD_3840_2160P_24HZ     = 0x1e,
    DISP_TV_MODE_NUM                = 0x1f,
}disp_tv_mode;
//FIXME:still need?
typedef enum
{
    DISP_EXIT_MODE_CLEAN_ALL    = 0,
    DISP_EXIT_MODE_CLEAN_PARTLY = 1,//only clean interrupt temply
}disp_exit_mode;
typedef enum
{
    DISP_TRANSFORM_ROT_0   = 0,
    DISP_TRANSFORM_ROT_90  = 1,
    DISP_TRANSFORM_ROT_180 = 2,
    DISP_TRANSFORM_ROT_270 = 3,
}disp_transform_type;
typedef enum
{
    DISP_BF_NORMAL        = 0,//non-stereo
    DISP_BF_STEREO_TB     = 1 << 0,//stereo top-bottom
    DISP_BF_STEREO_FP     = 1 << 1,//stereo frame packing
    DISP_BF_STEREO_SSH    = 1 << 2,//stereo side by side half
    DISP_BF_STEREO_SSF    = 1 << 3,//stereo side by side full
    DISP_BF_STEREO_LI     = 1 << 4,//stereo line interlace
}disp_buffer_flags;
typedef enum
{
    LAYER_MODE_BUFFER = 0,
    LAYER_MODE_COLOR = 1,
}disp_layer_mode;
typedef enum
{
    DISP_SCAN_PROGRESSIVE                 = 0,//non interlace
    DISP_SCAN_INTERLACED_ODD_FLD_FIRST    = 1 << 0,//interlace ,odd field first
    DISP_SCAN_INTERLACED_EVEN_FLD_FIRST   = 1 << 1,//interlace,even field first
}disp_scan_flags;
typedef struct
{
    long long x;
    long long y;
    long long width;
    long long height;
}disp_rect64;
typedef struct
{
    unsigned long long   addr[3];          /* address of frame buffer,
                                                                                        single addr for interleaved fomart,
                                                                                        double addr for semi-planar fomart
                                                                                        triple addr for planar format */
    disp_rectsz           size[3];          //size for 3 component,unit: pixels
    unsigned int          align[3];         //align for 3 comonent,unit: bits(align=2^n,i.e. 1/2/4/8/16/32..)
    disp_pixel_format     format;
    disp_color_space      color_space;      //color space
    unsigned int          trd_right_addr[3];/* right address of 3d fb,
                                                                                        used when in frame packing 3d mode */
    bool                  pre_multiply;     //true: pre-multiply fb
    disp_rect64           crop;             //crop rectangle boundaries
    disp_buffer_flags     flags;            //indicate stereo or non-stereo buffer
    disp_scan_flags       scan;             //scan type & scan order
}disp_fb_info;
typedef struct
{
    disp_layer_mode           mode;
    unsigned char             zorder;      /*specifies the front-to-back ordering of the layers on the screen,
                                             the top layer having the highest Z value
                                             can't set zorder, but can get */
    unsigned char             alpha_mode;  //0: pixel alpha;  1: global alpha;  2: global pixel alpha
    unsigned char             alpha_value; //global alpha value
    disp_rect                 screen_win;  //display window on the screen
    bool                      b_trd_out;   //3d display
    disp_3d_out_mode          out_trd_mode;//3d display mode
    union {
        unsigned int            color;       //valid when LAYER_MODE_COLOR
        disp_fb_info            fb;          //framebuffer, valid when LAYER_MODE_BUFFER
    };
    unsigned int              id;          /* frame id, can get the id of frame display currently
                                                                                        by DISP_LAYER_GET_FRAME_ID */
}disp_layer_info;
typedef struct
{
    disp_layer_info info;
    bool enable;
    unsigned int channel;
    unsigned int layer_id;
}disp_layer_config;
typedef struct
{
    disp_color      ck_max;
    disp_color      ck_min;
    unsigned int    red_match_rule;//0/1:always match; 2:match if min<=color<=max; 3:match if color>max or color<min
    unsigned int    green_match_rule;//0/1:always match; 2:match if min<=color<=max; 3:match if color>max or color<min
    unsigned int    blue_match_rule;//0/1:always match; 2:match if min<=color<=max; 3:match if color>max or color<min
}disp_colorkey;
typedef struct
{
    disp_pixel_format format;
    disp_rectsz size[3];
    disp_rect crop;
    unsigned long long addr[3];
}disp_s_frame;
typedef struct
{
    disp_rect window;  // capture window, rectangle of screen to be captured
                              //capture the whole screen if window eq ZERO
    disp_s_frame out_frame;
}disp_capture_info;
typedef struct
{
    disp_s_frame s_frame;
    disp_s_frame d_frame;
    disp_transform_type tr;
}disp_transform_info;
typedef struct
{
    unsigned int    vic;  //video infomation code
    unsigned int    pixel_clk;//khz
    unsigned int    pixel_repeat;//pixel repeat (pixel_repeat+1) times
    unsigned int    x_res;
    unsigned int    y_res;
    unsigned int    hor_total_time;
    unsigned int    hor_back_porch;
    unsigned int    hor_front_porch;
    unsigned int    hor_sync_time;
    unsigned int    ver_total_time;
    unsigned int    ver_back_porch;
    unsigned int    ver_front_porch;
    unsigned int    ver_sync_time;
    unsigned int    hor_sync_polarity;//0: negative, 1: positive
    unsigned int    ver_sync_polarity;//0: negative, 1: positive
    bool            b_interlace;
    unsigned int    vactive_space;
    unsigned int    trd_mode;
}disp_video_timings;
typedef enum
{
    FB_MODE_SCREEN0 = 0,
    FB_MODE_SCREEN1 = 1,
    FB_MODE_SCREEN2 = 2,
    FB_MODE_DUAL_SAME_SCREEN_TB = 3,//two screen, top buffer for screen0, bottom buffer for screen1
    FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS = 4,//two screen, they have same contents;
}disp_fb_mode;
typedef struct
{
    disp_fb_mode       fb_mode;
    disp_layer_mode    mode;
    unsigned int       buffer_num;
    unsigned int       width;
    unsigned int       height;
    unsigned int       output_width;//used when scaler mode
    unsigned int       output_height;//used when scaler mode
}disp_fb_create_info;
typedef enum
{
    DISP_INIT_MODE_SCREEN0 = 0,//fb0 for screen0
    DISP_INIT_MODE_SCREEN1 = 1,//fb0 for screen1
    DISP_INIT_MODE_SCREEN2 = 2,//fb0 for screen1
    DISP_INIT_MODE_TWO_DIFF_SCREEN = 3,//fb0 for screen0 and fb1 for screen1
    DISP_INIT_MODE_TWO_SAME_SCREEN = 4,//fb0(up buffer for screen0, down buffer for screen1)
    DISP_INIT_MODE_TWO_DIFF_SCREEN_SAME_CONTENTS = 5,//fb0 for two different screen(screen0 layer is normal layer, screen1 layer is scaler layer);
}disp_init_mode;
typedef struct
{
    int (*hdmi_open)(void);
    int (*hdmi_close)(void);
    int (*hdmi_set_mode)(disp_tv_mode mode);
    int (*hdmi_mode_support)(disp_tv_mode mode);
    int (*hdmi_get_HPD_status)(void);
    int (*hdmi_set_pll)(unsigned int pll, unsigned int clk);
    int (*hdmi_dvi_enable)(unsigned int mode);
    int (*hdmi_dvi_support)(void);
    int (*hdmi_get_input_csc)(void);
    int (*hdmi_get_hdcp_enable)(void);
    int (*hdmi_get_video_timing_info)(disp_video_timings **video_info);
    int (*hdmi_suspend)(void);
    int (*hdmi_resume)(void);
    int (*hdmi_early_suspend)(void);
    int (*hdmi_late_resume)(void);
}disp_hdmi_func;
typedef enum tag_DISP_CMD
{
    //----disp global----
    DISP_RESERVE0 = 0x00,
    DISP_RESERVE1 = 0x01,
    DISP_SET_BKCOLOR = 0x03,
    DISP_GET_BKCOLOR = 0x04,
    DISP_SET_COLORKEY = 0x05,
    DISP_GET_COLORKEY = 0x06,
    DISP_GET_SCN_WIDTH = 0x07,
    DISP_GET_SCN_HEIGHT = 0x08,
    DISP_GET_OUTPUT_TYPE = 0x09,
    DISP_SET_EXIT_MODE = 0x0A,
    DISP_VSYNC_EVENT_EN = 0x0B,
    DISP_BLANK = 0x0C,
    DISP_SHADOW_PROTECT = 0x0D,
    DISP_HWC_COMMIT = 0x0E,
    DISP_DEVICE_SWITCH = 0x0F,
    //----layer----
    DISP_LAYER_ENABLE = 0x40,
    DISP_LAYER_DISABLE = 0x41,
    DISP_LAYER_SET_INFO = 0x42,
    DISP_LAYER_GET_INFO = 0x43,
    DISP_LAYER_TOP = 0x44,
    DISP_LAYER_BOTTOM = 0x45,
    DISP_LAYER_GET_FRAME_ID = 0x46,
    DISP_LAYER_SET_CONFIG = 0x47,
    DISP_LAYER_GET_CONFIG = 0x48,
    //----hdmi----
    DISP_HDMI_ENABLE = 0xc0,
    DISP_HDMI_DISABLE = 0xc1,
    DISP_HDMI_SET_MODE = 0xc2,
    DISP_HDMI_GET_MODE = 0xc3,
    DISP_HDMI_SUPPORT_MODE = 0xc4,
    DISP_HDMI_GET_HPD_STATUS = 0xc5,
    DISP_HDMI_SET_SRC = 0xc6,
    //----lcd----
    DISP_LCD_ENABLE = 0x100,
    DISP_LCD_DISABLE = 0x101,
    DISP_LCD_SET_BRIGHTNESS = 0x102,
    DISP_LCD_GET_BRIGHTNESS = 0x103,
    DISP_LCD_BACKLIGHT_ENABLE = 0x104,
    DISP_LCD_BACKLIGHT_DISABLE = 0x105,
    DISP_LCD_SET_SRC = 0x106,
    DISP_LCD_SET_FPS = 0x107,
    DISP_LCD_GET_FPS = 0x108,
    DISP_LCD_GET_SIZE = 0x109,
    DISP_LCD_GET_MODEL_NAME = 0x10a,
    DISP_LCD_SET_GAMMA_TABLE = 0x10b,
    DISP_LCD_GAMMA_CORRECTION_ENABLE = 0x10c,
    DISP_LCD_GAMMA_CORRECTION_DISABLE = 0x10d,
    DISP_LCD_USER_DEFINED_FUNC = 0x10e,
    DISP_LCD_CHECK_OPEN_FINISH = 0x10f,
    DISP_LCD_CHECK_CLOSE_FINISH = 0x110,
    //---- capture ---
    DISP_CAPTURE_START = 0x140,//caputre screen and scaler to dram
    DISP_CAPTURE_STOP = 0x141,
    DISP_CAPTURE_COMMIT = 0x142,
    //---enhance ---
    DISP_ENHANCE_ENABLE = 0x180,
    DISP_ENHANCE_DISABLE = 0x181,
    DISP_ENHANCE_GET_EN = 0x182,
    DISP_ENHANCE_SET_WINDOW = 0x183,
    DISP_ENHANCE_GET_WINDOW = 0x184,
    DISP_ENHANCE_SET_MODE = 0x185,
    DISP_ENHANCE_GET_MODE = 0x186,
    //---smart backlight ---
    DISP_SMBL_ENABLE = 0x200,
    DISP_SMBL_DISABLE = 0x201,
    DISP_SMBL_GET_EN = 0x202,
    DISP_SMBL_SET_WINDOW = 0x203,
    DISP_SMBL_GET_WINDOW = 0x204,
    //---- for test
    DISP_FB_REQUEST = 0x280,
    DISP_FB_RELEASE = 0x281,
    DISP_MEM_REQUEST = 0x2c0,
    DISP_MEM_RELEASE = 0x2c1,
    DISP_MEM_GETADR = 0x2c2,
}__DISP_t;
#define FBIOGET_LAYER_HDL_0 0x4700
#define FBIOGET_LAYER_HDL_1 0x4701
#endif
app/src/main/libs/android-support-v4.jar
Binary files differ
app/src/main/libs/armeabi/libserial_port.so
Binary files differ
app/src/main/res/drawable-hdpi/ic_launcher.png
app/src/main/res/drawable-hdpi/off.png
app/src/main/res/drawable-hdpi/on.png
app/src/main/res/drawable-hdpi/poweroff.png
app/src/main/res/drawable-hdpi/poweron.png
app/src/main/res/drawable-hdpi/selected.png
app/src/main/res/drawable-hdpi/unselected.png
app/src/main/res/drawable-ldpi/ic_launcher.png
app/src/main/res/drawable-ldpi/setting.png
app/src/main/res/drawable-mdpi/ic_launcher.png
app/src/main/res/drawable/btn_rounded.xml
New file
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true"><shape>
            <corners android:radius="15dip" />
            <solid android:color="#FF9DD7EE" />
            <padding android:bottom="8dp" android:left="55dp" android:right="55dp" android:top="8dp" />
        </shape></item>
    <item android:state_pressed="true"><shape>
            <corners android:radius="15dip" />
            <solid android:color="#FFFF9600" />
            <padding android:bottom="8dp" android:left="55dp" android:right="55dp" android:top="8dp" />
        </shape></item>
    <item><shape>
            <corners android:radius="15dip" />
            <solid android:color="#FF9DD7EE" />
            <padding android:bottom="8dp" android:left="55dp" android:right="55dp" android:top="8dp" />
        </shape></item>
</selector>
app/src/main/res/drawable/gray_thumb.xml
New file
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <!-- 高度40 -->
    <size
        android:height="60dp"
        android:width="60dp" />
    <!-- 圆角弧度 20 -->
    <corners android:radius="30dp" />
    <!-- 变化率 -->
    <gradient
        android:endColor="#eeeeee"
        android:startColor="#eeeeee" />
    <stroke
        android:width="1dp"
        android:color="#BABABA" />
</shape>
app/src/main/res/drawable/gray_track.xml
New file
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <!-- 高度30   此处设置宽度无效 -->
    <size android:height="60dp" />
    <!-- 圆角弧度 15 -->
    <corners android:radius="30dp" />
    <!-- 变化率  定义从左到右的颜色不变 -->
    <gradient
        android:endColor="#BABABA"
        android:startColor="#BABABA" />
</shape>
app/src/main/res/drawable/green_thumb.xml
New file
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <!-- 高度40 -->
    <size
        android:height="60dp"
        android:width="60dp" />
    <!-- 圆角弧度 20 -->
    <corners android:radius="30dp" />
    <!-- 变化率 -->
    <gradient
        android:endColor="#eeeeee"
        android:startColor="#eeeeee" />
    <stroke
        android:width="1dp"
        android:color="#50C1E9" />
</shape>
app/src/main/res/drawable/green_track.xml
New file
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <!-- 高度40 -->
    <size android:height="60dp" />
    <!-- 圆角弧度 20 -->
    <corners android:radius="30dp" />
    <!-- 变化率 -->
    <gradient
        android:endColor="#CC50C1E9"
        android:startColor="#CC50C1E9" />
</shape>
app/src/main/res/drawable/light.png
app/src/main/res/drawable/light_def.png
app/src/main/res/drawable/line.xml
New file
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >
    <!-- 显示一条虚线,破折线的宽度为 dashWith,破折线之间的空隙的宽度为 dashGap,当 dashGap=0dp 时,为实线 -->
    <item
        android:left="-2dp"
        android:right="-2dp"
        android:top="-2dp">
        <shape>
            <stroke
                android:dashGap="0dp"
                android:dashWidth="1dp"
                android:width="1dp"
                android:color="#A9A9A9" />
            <size android:height="1px" />
        </shape>
    </item>
</layer-list>
app/src/main/res/drawable/line_white.xml
New file
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >
    <!-- 显示一条虚线,破折线的宽度为 dashWith,破折线之间的空隙的宽度为 dashGap,当 dashGap=0dp 时,为实线 -->
    <item
        android:left="-2dp"
        android:right="-2dp"
        android:top="-2dp">
        <shape>
            <stroke
                android:dashGap="0dp"
                android:dashWidth="1dp"
                android:width="1dp"
                android:color="#ffffff" />
            <size android:height="1px" />
        </shape>
    </item>
</layer-list>
app/src/main/res/drawable/my_seekbar_normal.xml
New file
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >
    <!-- 显示一条虚线,破折线的宽度为 dashWith,破折线之间的空隙的宽度为 dashGap,当 dashGap=0dp 时,为实线 -->
    <solid android:color="#eeeeee" />
    <size android:height="2dp" />
    <stroke
        android:dashGap="0dp"
        android:dashWidth="2dp"
        android:width="2dp"
        android:color="#eeeeee" />
</shape>
app/src/main/res/drawable/my_seekbar_pressed.xml
New file
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >
    <!-- 显示一条虚线,破折线的宽度为 dashWith,破折线之间的空隙的宽度为 dashGap,当 dashGap=0dp 时,为实线 -->
    <solid android:color="#eeeeee" />
    <size android:height="4dp" />
    <stroke
        android:dashGap="0dp"
        android:dashWidth="2dp"
        android:width="2dp"
        android:color="#4CAF50" />
</shape>
app/src/main/res/drawable/my_seekbar_thumb_normal.xml
New file
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false" >
    <stroke
        android:dashGap="0dp"
        android:dashWidth="1px"
        android:width="1px"
        android:color="#DADADA" />
    <solid android:color="#DADADA" />
    <size
        android:height="20dp"
        android:width="20dp" />
</shape>
app/src/main/res/drawable/my_seekbar_thumb_pressed.xml
New file
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false" >
    <stroke
        android:dashGap="0dp"
        android:dashWidth="1px"
        android:width="1px"
        android:color="#888888" />
    <solid android:color="#888888" />
    <size
        android:height="40dp"
        android:width="40dp" />
</shape>
app/src/main/res/drawable/seekbar_color_style.xml
New file
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="8dp" />
            <solid android:color="#DADADA" />
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="8dp" />
                <solid android:color="#CC50C1E9" />
            </shape>
        </clip>
    </item>
</layer-list>
app/src/main/res/drawable/thumb.xml
New file
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 按钮的选择器,可以设置按钮在不同状态下的时候,按钮不同的颜色 -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/green_thumb" android:state_checked="true"/>
    <item android:drawable="@drawable/gray_thumb"/>
</selector>
app/src/main/res/drawable/track.xml
New file
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 底层下滑条的样式选择器,可控制Switch在不同状态下,底下下滑条的颜色 -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/green_track" android:state_checked="true"/>
    <item android:drawable="@drawable/gray_track"/>
</selector>
app/src/main/res/layout/activity_main.xml
New file
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="android.serialport.api.sample.MainActivity" >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
        <include
            android:id="@+id/TabLayout"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            layout="@layout/tab" />
        <ImageView
            android:id="@+id/tab_image"
            android:layout_width="100dp"
            android:layout_height="3dp"
            android:layout_below="@id/TabLayout"
            android:background="#FF000000" />
        <android.support.v4.view.ViewPager
            android:id="@+id/mViewPager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/tab_image" />
    </RelativeLayout>
    <fragment
        android:id="@+id/navigation_drawer"
        android:name="android.serialport.api.sample.NavigationDrawerFragment"
        android:layout_width="400dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        tools:layout="@layout/fragment_navigation" />
</android.support.v4.widget.DrawerLayout>
app/src/main/res/layout/console.xml
New file
@@ -0,0 +1,403 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true"
    android:orientation="vertical" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#BB50C1E9"
        android:orientation="horizontal" >
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="30dp"
            android:gravity="center" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="10dp"
                android:text="Dry Contact:"
                android:textColor="#ffffff"
                android:textSize="20sp" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center|left" >
            <RadioButton
                android:id="@+id/radioButton1"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginRight="6dp"
                android:enabled="false"
                android:text="1"
                android:textColor="#ffffff" />
            <RadioButton
                android:id="@+id/radioButton2"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginRight="6dp"
                android:enabled="false"
                android:text="2"
                android:textColor="#ffffff" />
            <RadioButton
                android:id="@+id/radioButton3"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginRight="6dp"
                android:enabled="false"
                android:text="3"
                android:textColor="#ffffff" />
            <RadioButton
                android:id="@+id/radioButton4"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginRight="6dp"
                android:enabled="false"
                android:text="4"
                android:textColor="#ffffff" />
            <RadioButton
                android:id="@+id/radioButton5"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginRight="6dp"
                android:enabled="false"
                android:text="5"
                android:textColor="#ffffff" />
            <RadioButton
                android:id="@+id/radioButton6"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginRight="6dp"
                android:enabled="false"
                android:text="6"
                android:textColor="#ffffff" />
        </LinearLayout>
        <Button
            android:id="@+id/btn_state"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_marginBottom="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="20dp"
            android:background="@null"
            android:gravity="center|right"
            android:minWidth="80dp" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9"
        android:orientation="horizontal" >
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="30dp"
                android:layout_marginTop="30dp"
                android:text="Relay:"
                android:textSize="20sp" />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_weight="1"
                android:gravity="center" >
                <Switch
                    android:id="@+id/loopId1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:switchTextAppearance="@style/MySwitch"
                    android:textOff="OFF"
                    android:textOn="ON"
                    android:thumb="@drawable/thumb"
                    android:track="@drawable/track" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_weight="1"
                android:gravity="center" >
                <Switch
                    android:id="@+id/loopId2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:switchTextAppearance="@style/MySwitch"
                    android:textOff="OFF"
                    android:textOn="ON"
                    android:thumb="@drawable/thumb"
                    android:track="@drawable/track" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_weight="1"
                android:gravity="center" >
                <Switch
                    android:id="@+id/loopId3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:switchTextAppearance="@style/MySwitch"
                    android:textOff="OFF"
                    android:textOn="ON"
                    android:thumb="@drawable/thumb"
                    android:track="@drawable/track" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_weight="1"
                android:gravity="center" >
                <Switch
                    android:id="@+id/loopId4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:switchTextAppearance="@style/MySwitch"
                    android:textOff="OFF"
                    android:textOn="ON"
                    android:thumb="@drawable/thumb"
                    android:track="@drawable/track" />
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#8BD5EE" />
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical" >
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center|left"
                    android:orientation="horizontal" >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="30dp"
                        android:layout_marginRight="10dp"
                        android:text="Compensation:"
                        android:textSize="20dp" />
                    <EditText
                        android:id="@+id/c_value"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:background="@drawable/line"
                        android:digits="-0123456789"
                        android:gravity="center"
                        android:minWidth="40dp"
                        android:text="0"
                        android:textColor="#FF0000" />
                    <Button
                        android:id="@+id/c_btn"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:layout_marginRight="10dp"
                        android:text="Save" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center|left"
                    android:orientation="horizontal" >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="30dp"
                        android:text="Temperature:"
                        android:textSize="20dp" />
                    <EditText
                        android:id="@+id/Temperature"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="20dp"
                        android:layout_weight="1"
                        android:background="@drawable/line"
                        android:enabled="false"
                        android:focusable="false"
                        android:focusableInTouchMode="false"
                        android:gravity="center"
                        android:textColor="#FF0000" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center|left"
                    android:orientation="horizontal" >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="30dp"
                        android:text="Key Status:"
                        android:textSize="20dp" />
                    <EditText
                        android:id="@+id/key_status"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="20dp"
                        android:layout_weight="1"
                        android:background="@drawable/line"
                        android:enabled="false"
                        android:focusable="false"
                        android:focusableInTouchMode="false"
                        android:gravity="center"
                        android:textColor="#FF0000" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center|left"
                    android:orientation="horizontal" >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="30dp"
                        android:text="Sensitivity:"
                        android:textSize="20sp" />
                    <SeekBar
                        android:id="@+id/set_sensitivity"
                        style="@android:attr/progressBarStyleHorizontal"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:layout_weight="1"
                        android:max="10"
                        android:maxHeight="5dp"
                        android:minHeight="5dp"
                        android:progressDrawable="@drawable/seekbar_color_style"
                        android:thumb="@drawable/my_seekbar_thumb_pressed"
                        android:thumbOffset="0dip" />
                    <TextView
                        android:id="@+id/seekbar_value"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="5dp"
                        android:layout_marginRight="20dp"
                        android:minWidth="20dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center|left"
                    android:orientation="horizontal" >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="30dp"
                        android:text="SerialPort:"
                        android:textSize="20sp" />
                    <Switch
                        android:id="@+id/powerButton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:switchTextAppearance="@style/MySwitch"
                        android:textOff="OFF"
                        android:textOn="ON"
                        android:thumb="@drawable/thumb"
                        android:track="@drawable/track" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center|left" >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="30dp"
                        android:text="BackLight"
                        android:textSize="20sp" />
                    <Switch
                        android:id="@+id/openbacklight"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:switchTextAppearance="@style/MySwitch"
                        android:textOff="OFF"
                        android:textOn="ON"
                        android:thumb="@drawable/thumb"
                        android:track="@drawable/track" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
app/src/main/res/layout/dialog_pro.xml
New file
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical" >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="正在升级固件,请勿进行其他操作!!!"
        android:textSize="30dp"
        android:textColor="@color/red"
        />
    <ProgressBar
        android:id="@+id/pro"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:max="100"
        android:progress="30" />
</LinearLayout>
app/src/main/res/layout/fragment_knx.xml
New file
@@ -0,0 +1,395 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="10dp"
            android:text="individual_addr:" />
        <EditText
            android:layout_width="90dp"
            android:layout_height="wrap_content"
            android:hint="1101"
            android:text="1101" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal" >
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:layout_weight="1"
            android:orientation="vertical" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:text="Channel 1:" />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_marginTop="5dp"
                android:orientation="horizontal" >
                <Button
                    android:id="@+id/light1_1"
                    android:layout_width="90dp"
                    android:layout_height="90dp"
                    android:layout_marginBottom="10dp"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:background="@drawable/light_def" />
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="120dp"
                    android:layout_weight="1"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical" >
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1" >
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Switch:" />
                        <EditText
                            android:id="@+id/edit_obj1_1"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:hint="1/0/1"
                            android:text="1/0/1" />
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1" >
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Status:" />
                        <EditText
                            android:id="@+id/edit_obj1_2"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:hint="1/0/2"
                            android:text="1/0/2" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center" >
                <Button
                    android:id="@+id/switch_btn1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Save" />
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:layout_weight="1"
            android:orientation="vertical" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:text="Channel 2:" />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_marginTop="5dp"
                android:orientation="horizontal" >
                <Button
                    android:id="@+id/light_2"
                    android:layout_width="90dp"
                    android:layout_height="90dp"
                    android:layout_marginBottom="10dp"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:background="@drawable/light_def" />
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="120dp"
                    android:layout_weight="1"
                    android:orientation="vertical" >
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1" >
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Switch:" />
                        <EditText
                            android:id="@+id/edit_obj2_1"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:hint="1/0/1"
                            android:text="1/0/3" />
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1" >
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Status:" />
                        <EditText
                            android:id="@+id/edit_obj2_2"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:hint="1/0/2"
                            android:text="1/0/4" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center" >
                <Button
                    android:id="@+id/switch_btn2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Save" />
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:layout_weight="1"
            android:orientation="vertical" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:text="Channel 3:" />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_marginTop="5dp"
                android:orientation="horizontal" >
                <Button
                    android:id="@+id/light_3"
                    android:layout_width="90dp"
                    android:layout_height="90dp"
                    android:layout_marginBottom="10dp"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:background="@drawable/light_def" />
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="120dp"
                    android:layout_weight="1"
                    android:orientation="vertical" >
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1" >
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Switch:" />
                        <EditText
                            android:id="@+id/edit_obj3_1"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:hint="1/0/1"
                            android:text="1/0/5" />
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1" >
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Status:" />
                        <EditText
                            android:id="@+id/edit_obj3_2"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:hint="1/0/2"
                            android:text="1/0/6" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center" >
                <Button
                    android:id="@+id/switch_btn3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Save" />
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:layout_weight="1"
            android:orientation="vertical" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:layout_marginTop="5dp"
                android:text="Channel 4:" />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_marginTop="5dp"
                android:orientation="horizontal" >
                <Button
                    android:id="@+id/light_4"
                    android:layout_width="90dp"
                    android:layout_height="90dp"
                    android:layout_marginBottom="10dp"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:background="@drawable/light_def" />
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="120dp"
                    android:layout_weight="1"
                    android:orientation="vertical" >
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1" >
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Switch:" />
                        <EditText
                            android:id="@+id/edit_obj4_1"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:hint="1/0/1"
                            android:text="1/0/7" />
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1" >
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Status:" />
                        <EditText
                            android:id="@+id/edit_obj4_2"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:hint="1/0/2"
                            android:text="1/0/8" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center" >
                <Button
                    android:id="@+id/switch_btn4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Save" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
app/src/main/res/layout/fragment_navigation.xml
New file
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#50C1E9"
    android:orientation="vertical" >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"
        android:background="@drawable/setting" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="5dp"
        android:text="Setting"
        android:textColor="#ffffff"
        android:textSize="30sp" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:layout_marginTop="15dp"
        android:orientation="horizontal" >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="SubNetID:"
            android:textColor="#ffffff" />
        <EditText
            android:id="@+id/editText_SubNet"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="4dp"
            android:layout_weight="1"
            android:background="@drawable/line_white"
            android:digits="0123456789"
            android:gravity="center"
            android:minWidth="40dp"
            android:text="250"
            android:textColor="#ffffff" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:layout_marginTop="55dp"
        android:orientation="horizontal" >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="SubNetID:"
            android:textColor="#ffffff" />
        <EditText
            android:id="@+id/editText_Device"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="4dp"
            android:layout_weight="1"
            android:background="@drawable/line_white"
            android:digits="0123456789"
            android:gravity="center"
            android:minWidth="40dp"
            android:text="250"
            android:textColor="#ffffff" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="65dp"
        android:gravity="center"
        android:orientation="horizontal" >
        <Button
            android:id="@+id/save_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/btn_rounded"
            android:textColor="#ffffff"
            android:text="Save"
            android:textSize="25sp" />
    </LinearLayout>
</LinearLayout>
app/src/main/res/layout/fragment_upgrade.xml
New file
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="horizontal" >
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" />
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:orientation="horizontal" >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Root Directory:" />
        <EditText
            android:id="@+id/EditText_Path"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:enabled="false" />
        <Button
            android:id="@+id/Btn_path"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:text="…" />
        <Button
            android:id="@+id/Btn_Upgrade"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Upgrade" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" />
</LinearLayout>
app/src/main/res/layout/tab.xml
New file
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:orientation="vertical" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >
        <TextView
            android:id="@+id/textView_bus"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="BUS"
            android:textSize="20dp" />
        <TextView
            android:id="@+id/textView_knx"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="KNX"
            android:textSize="20dp" />
        <TextView
            android:id="@+id/textView_upgrade"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Upgrade"
            android:textSize="20dp" />
    </LinearLayout>
</LinearLayout>
app/src/main/res/values/baudrates.xml
New file
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="baudrates_name">
        <item>4800</item>
        <item>9600</item>
        <item>19200</item>
    </string-array>
    <string-array name="baudrates_value">
        <item>4800</item>
        <item>9600</item>
        <item>19200</item>
    </string-array>
</resources>
app/src/main/res/values/colors.xml
New file
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="transparent">#00000000</color>
    <color name="red">#FFFF0000</color>
</resources>
app/src/main/res/values/strings.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Serial Port Demo</string>
    <string name="error_configuration">Please configure your serial port first.</string>
    <string name="error_security">You do not have read/write permission to the serial
        port.</string>
    <string name="error_unknown">The serial port can not be opened for an unknown
        reason.</string>
</resources>
app/src/main/res/values/styles.xml
New file
@@ -0,0 +1,39 @@
<resources>
    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>
    <!-- Application theme. -->
    <style name="AppTheme" parent="android:Theme.Light.NoTitleBar.Fullscreen">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>
    <style name="MySwitch" parent="android:Theme.Light">
        <item name="android:textSize">20sp</item>
        <item name="android:textColor">#000</item>
    </style>
    <style name="Theme_Transparent" parent="@android:Theme.DeviceDefault.Light.Dialog">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
    </style>
    <style name="Theme_Transparent_NoTitle" parent="@android:Theme.DeviceDefault.Light.Dialog">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/white</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>
app/src/main/res/xml/serial_port_preferences.xml
New file
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    android:title="Serial port setup" >
    <ListPreference
        android:key="DEVICE"
        android:persistent="true"
        android:title="Device" >
    </ListPreference>
    <ListPreference
        android:entries="@array/baudrates_name"
        android:entryValues="@array/baudrates_value"
        android:key="BAUDRATE"
        android:persistent="true"
        android:title="Baud rate" >
    </ListPreference>
</PreferenceScreen>
build.gradle
New file
@@ -0,0 +1,20 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
//        classpath 'com.novoda:bintray-release:+'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}
gradle/wrapper/gradle-wrapper.jar
Binary files differ
gradle/wrapper/gradle-wrapper.properties
New file
@@ -0,0 +1,6 @@
#Tue Jun 25 09:40:34 GMT+08:00 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
gradlew
New file
@@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
##  Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
    echo "$*"
}
die () {
    echo
    echo "$*"
    echo
    exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
  CYGWIN* )
    cygwin=true
    ;;
  Darwin* )
    darwin=true
    ;;
  MINGW* )
    msys=true
    ;;
  NONSTOP* )
    nonstop=true
    ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD="$JAVA_HOME/jre/sh/java"
    else
        JAVACMD="$JAVA_HOME/bin/java"
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD="java"
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
    MAX_FD_LIMIT=`ulimit -H -n`
    if [ $? -eq 0 ] ; then
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
            MAX_FD="$MAX_FD_LIMIT"
        fi
        ulimit -n $MAX_FD
        if [ $? -ne 0 ] ; then
            warn "Could not set maximum file descriptor limit: $MAX_FD"
        fi
    else
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
    fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
    JAVACMD=`cygpath --unix "$JAVACMD"`
    # We build the pattern for arguments to be converted via cygpath
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
    SEP=""
    for dir in $ROOTDIRSRAW ; do
        ROOTDIRS="$ROOTDIRS$SEP$dir"
        SEP="|"
    done
    OURCYGPATTERN="(^($ROOTDIRS))"
    # Add a user-defined pattern to the cygpath arguments
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
    fi
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    i=0
    for arg in "$@" ; do
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
        else
            eval `echo args$i`="\"$arg\""
        fi
        i=$((i+1))
    done
    case $i in
        (0) set -- ;;
        (1) set -- "$args0" ;;
        (2) set -- "$args0" "$args1" ;;
        (3) set -- "$args0" "$args1" "$args2" ;;
        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
    esac
fi
# Escape application args
save () {
    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
    echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
  cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
gradlew.bat
New file
@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
import-summary.txt
New file
@@ -0,0 +1,61 @@
ECLIPSE ANDROID PROJECT IMPORT SUMMARY
======================================
Ignored Files:
--------------
The following files were *not* copied into the new Gradle project; you
should evaluate whether these are still needed in your project and if
so manually move them:
* .idea\
* .idea\.name
* .idea\compiler.xml
* .idea\copyright\
* .idea\copyright\profiles_settings.xml
* .idea\encodings.xml
* .idea\misc.xml
* .idea\modules.xml
* .idea\myserial.iml
* .idea\scopes\
* .idea\scopes\scope_settings.xml
* .idea\vcs.xml
* .idea\workspace.xml
* proguard.cfg
Replaced Jars with Dependencies:
--------------------------------
The importer recognized the following .jar files as third party
libraries and replaced them with Gradle dependencies instead. This has
the advantage that more explicit version information is known, and the
libraries can be updated automatically. However, it is possible that
the .jar file in your project was of an older version than the
dependency we picked, which could render the project not compileable.
You can disable the jar replacement in the import wizard and try again:
android-support-v4.jar => com.android.support:support-v4:22.2.1
Moved Files:
------------
Android Gradle projects use a different directory structure than ADT
Eclipse projects. Here's how the projects were restructured:
* AndroidManifest.xml => app\src\main\AndroidManifest.xml
* assets\ => app\src\main\assets\
* jni\ => app\src\main\jni\
* res\ => app\src\main\res\
* src\ => app\src\main\java\
Next Steps:
-----------
You can now build the project. The Gradle project needs network
connectivity to download dependencies.
Bugs:
-----
If for some reason your project does not build, and you determine that
it is due to a bug or limitation of the Eclipse to Gradle importer,
please file a bug at http://b.android.com with category
Component-Tools.
(This import summary is for your information only, and can be deleted
after import once you are satisfied with the results.)
settings.gradle
New file
@@ -0,0 +1 @@
include ':app'