rtlduino rtl8710af gcc base version

This commit is contained in:
RtlduinoMan 2016-09-12 17:16:56 +08:00
parent 7675bdb95f
commit 9c0c9edf61
2097 changed files with 779974 additions and 2 deletions

Binary file not shown.

View file

@ -0,0 +1 @@
#Fri Apr 17 15:55:53 CST 2015

View file

@ -0,0 +1 @@
UartThrough

View 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>

View file

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.2.1" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

View file

@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="support-v4-19.1.0">
<CLASSES>
<root url="jar://C:/adt-bundle-windows-x86-20130729/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://C:/adt-bundle-windows-x86-20130729/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="SvnBranchConfigurationManager">
<option name="mySupportsUserInfoFilter" value="true" />
</component>
</project>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/UartThrough1.iml" filepath="$PROJECT_DIR$/UartThrough1.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>

View file

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="svn" />
</component>
</project>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="UartThrough1" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
</component>
</module>

View file

@ -0,0 +1,23 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.realtek.uartthrough"
minSdkVersion 8
targetSdkVersion 18
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
}

View file

@ -0,0 +1,13 @@
/**
* Automatically generated file. DO NOT MODIFY
*/
package com.realtek.uartthrough.test;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.realtek.uartthrough.test";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = -1;
public static final String VERSION_NAME = "";
}

View file

@ -0,0 +1,13 @@
/**
* Automatically generated file. DO NOT MODIFY
*/
package com.realtek.uartthrough;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.realtek.uartthrough";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "";
}

View file

@ -0,0 +1,91 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.realtek.uartthrough;
public final class R {
public static final class attr {
}
public static final class dimen {
public static final int activity_horizontal_margin=0x7f040000;
public static final int activity_vertical_margin=0x7f040001;
}
public static final class drawable {
public static final int add=0x7f020000;
public static final int back=0x7f020001;
public static final int bg_index01=0x7f020002;
public static final int bg_index1=0x7f020003;
public static final int device=0x7f020004;
public static final int ic_launcher=0x7f020005;
public static final int logo=0x7f020006;
public static final int logo1=0x7f020007;
public static final int search=0x7f020008;
public static final int setting=0x7f020009;
}
public static final class id {
public static final int APPTitle=0x7f080003;
public static final int APPimageView=0x7f08000c;
public static final int SCROLLER_ID=0x7f080010;
public static final int action_settings=0x7f08001c;
public static final int btn_back=0x7f080002;
public static final int btn_scanDevices=0x7f08000d;
public static final int btn_send=0x7f080009;
public static final int btn_setting=0x7f08000e;
public static final int btn_setting_apply=0x7f08001b;
public static final int btn_setting_cancel=0x7f08001a;
public static final int chatDisplay=0x7f080006;
public static final int chat_ScrollView=0x7f080005;
public static final int debugLayout=0x7f08000a;
public static final int editTx_send=0x7f080008;
public static final int gridview_list=0x7f08000f;
public static final int item_image=0x7f080012;
public static final int item_text=0x7f080013;
public static final int item_text_info=0x7f080014;
public static final int layer1_linear0=0x7f080001;
public static final int layer1_linear2=0x7f080004;
public static final int layer1_linear3=0x7f080007;
public static final int mainlayout=0x7f080000;
public static final int spinner_baudrate=0x7f080015;
public static final int spinner_data=0x7f080016;
public static final int spinner_flowcontrol=0x7f080019;
public static final int spinner_parity=0x7f080017;
public static final int spinner_stopbit=0x7f080018;
public static final int text_debug=0x7f080011;
public static final int text_test=0x7f08000b;
}
public static final class layout {
public static final int activity_chat=0x7f030000;
public static final int activity_main=0x7f030001;
public static final int layout_item=0x7f030002;
public static final int layout_item_setting=0x7f030003;
public static final int setting_serialport=0x7f030004;
}
public static final class menu {
public static final int chat=0x7f070000;
public static final int main=0x7f070001;
}
public static final class string {
public static final int action_settings=0x7f050000;
public static final int app_name=0x7f050001;
public static final int hello_world=0x7f050002;
public static final int title_activity_chat=0x7f050003;
}
public static final class style {
/**
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
API 11 theme customizations can go here.
API 14 theme customizations can go here.
*/
public static final int AppBaseTheme=0x7f060000;
/** All customizations that are NOT specific to a particular API-level can go here.
*/
public static final int AppTheme=0x7f060001;
}
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="D:\temp\android\mdis_discovery\UartThrough1\app\src\androidTest\assets"/></dataSet></merger>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\assets"/></dataSet><dataSet config="debug"><source path="D:\temp\android\mdis_discovery\UartThrough1\app\src\debug\assets"/></dataSet></merger>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="D:\temp\android\mdis_discovery\UartThrough1\app\src\androidTest\res"/><source path="D:\temp\android\mdis_discovery\UartThrough1\app\build\generated\res\rs\androidTest\debug"/><source path="D:\temp\android\mdis_discovery\UartThrough1\app\build\generated\res\generated\androidTest\debug"/></dataSet><mergedItems/></merger>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res"><file name="add" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable\add.png" qualifiers="" type="drawable"/><file name="back" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable\back.png" qualifiers="" type="drawable"/><file name="bg_index01" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable\bg_index01.png" qualifiers="" type="drawable"/><file name="bg_index1" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable\bg_index1.png" qualifiers="" type="drawable"/><file name="device" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable\device.png" qualifiers="" type="drawable"/><file name="logo" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable\logo.png" qualifiers="" type="drawable"/><file name="logo1" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable\logo1.png" qualifiers="" type="drawable"/><file name="search" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable\search.png" qualifiers="" type="drawable"/><file name="setting" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable\setting.png" qualifiers="" type="drawable"/><file name="ic_launcher" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable-hdpi\ic_launcher.png" qualifiers="hdpi-v4" type="drawable"/><file name="ic_launcher" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable-mdpi\ic_launcher.png" qualifiers="mdpi-v4" type="drawable"/><file name="ic_launcher" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable-xhdpi\ic_launcher.png" qualifiers="xhdpi-v4" type="drawable"/><file name="ic_launcher" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\drawable-xxhdpi\ic_launcher.png" qualifiers="xxhdpi-v4" type="drawable"/><file name="activity_chat" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\layout\activity_chat.xml" qualifiers="" type="layout"/><file name="activity_main" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\layout\activity_main.xml" qualifiers="" type="layout"/><file name="layout_item" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\layout\layout_item.xml" qualifiers="" type="layout"/><file name="layout_item_setting" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\layout\layout_item_setting.xml" qualifiers="" type="layout"/><file name="setting_serialport" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\layout\setting_serialport.xml" qualifiers="" type="layout"/><file name="chat" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\menu\chat.xml" qualifiers="" type="menu"/><file name="main" path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\menu\main.xml" qualifiers="" type="menu"/><file path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\values\dimens.xml" qualifiers=""><dimen name="activity_horizontal_margin">16dp</dimen><dimen name="activity_vertical_margin">16dp</dimen></file><file path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\values\strings.xml" qualifiers=""><string name="title_activity_chat">ChatActivity</string><string name="action_settings">Settings</string><string name="app_name">UartThrough</string><string name="hello_world">Hello world!</string></file><file path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\values\styles.xml" qualifiers=""><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><style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style></file><file path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\values-sw720dp-land\dimens.xml" qualifiers="sw720dp-land-v13"><dimen name="activity_horizontal_margin">128dp</dimen></file><file path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\values-v11\styles.xml" qualifiers="v11"><style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style></file><file path="D:\temp\android\mdis_discovery\UartThrough1\app\src\main\res\values-v14\styles.xml" qualifiers="v14"><style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style></file></source><source path="D:\temp\android\mdis_discovery\UartThrough1\app\build\generated\res\rs\debug"/><source path="D:\temp\android\mdis_discovery\UartThrough1\app\build\generated\res\generated\debug"/></dataSet><dataSet config="debug"><source path="D:\temp\android\mdis_discovery\UartThrough1\app\src\debug\res"/></dataSet><mergedItems/></merger>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.realtek.uartthrough.test">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.realtek.uartthrough"
android:handleProfiling="false"
android:functionalTest="false"
android:label="Tests for com.realtek.uartthrough"/>
</manifest>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.realtek.uartthrough"
android:versionCode="1"
android:versionName="1.0.1.20150408" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"
android:required="true" />
<uses-permission
android:name="android.permission.CHANGE_WIFI_STATE"
android:required="true" />
<uses-permission
android:name="android.permission.INTERNET"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.realtek.uartthrough.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.realtek.uartthrough.ChatActivity"
android:label="@string/title_activity_chat" >
</activity>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/layer1_linear0"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:background="@drawable/bg_index01"
android:layout_weight="1">
<ImageButton
android:id="@+id/btn_back"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="2dp"
android:src="@drawable/back"/>
<TextView
android:id="@+id/APPTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center"
android:layout_weight="1.75"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Let us just chat"
android:textColor="@android:color/black"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layer1_linear2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@drawable/bg_index1"
android:layout_weight="8">
<ScrollView
android:id="@+id/chat_ScrollView"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#ffeeeeee"
android:fillViewport="false" >
<TextView
android:id="@+id/chatDisplay"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:background="#ffffffff"
android:focusable="true"
android:focusableInTouchMode="true"/>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/layer1_linear3"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="@+id/editTx_send"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.52"
android:clickable="true"
android:ems="10"
android:enabled="true"
android:text=""
android:textSize="14dp" />
<Button
android:id="@+id/btn_send"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Send" />
</LinearLayout>
<LinearLayout
android:id="@+id/debugLayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#FFFFFF"
android:layout_weight="0">
<TextView
android:id="@+id/text_test"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text=""
android:textSize="12sp"
android:maxLines = "9999999"
android:scrollbars = "vertical"/>
</LinearLayout>
</LinearLayout><!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/layout/activity_chat.xml -->

View file

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/layer1_linear0"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:background="@drawable/bg_index01"
android:layout_weight="1">
<ImageView
android:id="@+id/APPimageView"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="2dp"
android:src="@drawable/logo"/>
<TextView
android:id="@+id/APPTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center"
android:layout_weight="3"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Uart Through"
android:textColor="@android:color/black"
android:textSize="16sp" />
<ImageButton
android:id="@+id/btn_scanDevices"
android:contentDescription="@string/app_name"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="5dp"
android:layout_margin= "1dp"
android:src="@drawable/search"/>
<!--ImageButton
android:id="@+id/btn_addDevice"
android:contentDescription="@string/app_name"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="5dp"
android:layout_margin= "1dp"
android:src="@drawable/add"/-->
<ImageButton
android:id="@+id/btn_setting"
android:contentDescription="@string/app_name"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="5dp"
android:layout_margin= "1dp"
android:src="@drawable/setting"/>
</LinearLayout>
<LinearLayout
android:id="@+id/layer1_linear2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@drawable/bg_index1"
android:layout_weight="8">
<GridView
android:id="@+id/gridview_list"
android:listSelector="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
android:numColumns="2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="35dp"
android:gravity="center"
android:layout_gravity="center"
android:columnWidth="50pt"
android:stretchMode="columnWidth"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/debugLayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#FFFFFF"
android:layout_weight="0">
<TextView
android:id="@+id/text_test"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text=""
android:textSize="12sp"
android:maxLines = "9999999"
android:scrollbars = "vertical"/>
</LinearLayout>
<LinearLayout
android:id="@+id/debugLayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#FFFFFF"
android:layout_weight="3">
<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="@+id/text_debug"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Debug Message"
android:textSize="12sp"
android:maxLines = "9999999"
android:scrollbars = "vertical"/>
</ScrollView>
</LinearLayout>
</LinearLayout><!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/layout/activity_main.xml -->

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" >
<ImageView
android:id="@+id/item_image"
android:scaleType="centerCrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" >
</ImageView>
<TextView
android:id="@+id/item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_image"
android:layout_centerHorizontal="true"
android:background="#22000000"
android:textSize="12sp"
android:ellipsize="middle"
android:singleLine="true"
android:maxEms="10"
>
</TextView>
<!-- com.realtek.myspeaker.SpeakerTextView
android:id="@+id/item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_image"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever">
</com.realtek.myspeaker.SpeakerTextView-->
</RelativeLayout><!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/layout/layout_item.xml -->

View file

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" >
<ImageView
android:id="@+id/item_image"
android:scaleType="centerCrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" >
</ImageView>
<TextView
android:id="@+id/item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_image"
android:layout_centerHorizontal="true"
android:textSize="16sp"
>
</TextView>
<TextView
android:id="@+id/item_text_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_text"
android:layout_centerHorizontal="true"
android:textSize="14sp"
>
</TextView>
<!-- com.realtek.myspeaker.SpeakerTextView
android:id="@+id/item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_image"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever">
</com.realtek.myspeaker.SpeakerTextView-->
</RelativeLayout><!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/layout/layout_item_setting.xml -->

View file

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_light"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="@android:color/darker_gray"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="1dp"
android:background="@android:color/darker_gray"
android:orientation="horizontal">
<!-- ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical|center"
android:layout_weight="1"
android:src="@drawable/ic_launcher" /-->
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center"
android:layout_weight="3"
android:text="Serial Port Setup" />
</LinearLayout>
<Spinner
android:id="@+id/spinner_baudrate"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<Spinner
android:id="@+id/spinner_data"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<Spinner
android:id="@+id/spinner_parity"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<Spinner
android:id="@+id/spinner_stopbit"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<Spinner
android:id="@+id/spinner_flowcontrol"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2"
android:layout_margin="1dp"
android:background="@android:color/darker_gray"
android:orientation="horizontal">
<Button
android:id="@+id/btn_setting_cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Cancel" />"
<Button
android:id="@+id/btn_setting_apply"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Apply" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout><!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/layout/setting_serialport.xml -->

View file

@ -0,0 +1,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>
<!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/menu/chat.xml -->

View file

@ -0,0 +1,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>
<!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/menu/main.xml -->

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/values-sw720dp-land/dimens.xml -->
<eat-comment/>
<dimen name="activity_horizontal_margin">128dp</dimen>
</resources>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/values-v11/styles.xml -->
<eat-comment/>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/values-v14/styles.xml -->
<eat-comment/>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/values/dimens.xml -->
<eat-comment/>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/values/strings.xml -->
<eat-comment/>
<string name="action_settings">Settings</string>
<string name="app_name">UartThrough</string>
<string name="hello_world">Hello world!</string>
<string name="title_activity_chat">ChatActivity</string>
<!-- From: file:/D:/temp/android/mdis_discovery/UartThrough1/app/src/main/res/values/styles.xml -->
<eat-comment/>
<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>
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>

View file

@ -0,0 +1,75 @@
-- Merging decision tree log ---
manifest
ADDED from AndroidManifest.xml:2:1
xmlns:android
ADDED from AndroidManifest.xml:2:11
package
ADDED from AndroidManifest.xml:3:5
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
android:versionName
ADDED from AndroidManifest.xml:5:5
android:versionCode
ADDED from AndroidManifest.xml:4:5
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
uses-sdk
ADDED from AndroidManifest.xml:7:5
android:targetSdkVersion
ADDED from AndroidManifest.xml:9:9
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
android:minSdkVersion
ADDED from AndroidManifest.xml:8:9
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
uses-permission#android.permission.ACCESS_WIFI_STATE
ADDED from AndroidManifest.xml:11:5
android:required
ADDED from AndroidManifest.xml:13:9
android:name
ADDED from AndroidManifest.xml:12:9
uses-permission#android.permission.CHANGE_WIFI_STATE
ADDED from AndroidManifest.xml:14:5
android:required
ADDED from AndroidManifest.xml:16:9
android:name
ADDED from AndroidManifest.xml:15:9
uses-permission#android.permission.INTERNET
ADDED from AndroidManifest.xml:17:5
android:required
ADDED from AndroidManifest.xml:19:9
android:name
ADDED from AndroidManifest.xml:18:9
application
ADDED from AndroidManifest.xml:21:5
android:label
ADDED from AndroidManifest.xml:24:9
android:allowBackup
ADDED from AndroidManifest.xml:22:9
android:icon
ADDED from AndroidManifest.xml:23:9
android:theme
ADDED from AndroidManifest.xml:25:9
activity#com.realtek.uartthrough.MainActivity
ADDED from AndroidManifest.xml:26:9
android:label
ADDED from AndroidManifest.xml:28:13
android:name
ADDED from AndroidManifest.xml:27:13
intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
ADDED from AndroidManifest.xml:29:13
action#android.intent.action.MAIN
ADDED from AndroidManifest.xml:30:17
android:name
ADDED from AndroidManifest.xml:30:25
category#android.intent.category.LAUNCHER
ADDED from AndroidManifest.xml:32:17
android:name
ADDED from AndroidManifest.xml:32:27
activity#com.realtek.uartthrough.ChatActivity
ADDED from AndroidManifest.xml:35:9
android:label
ADDED from AndroidManifest.xml:37:13
android:name
ADDED from AndroidManifest.xml:36:13

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.realtek.uartthrough"
android:versionCode="1"
android:versionName="1.0.1.20150408" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"
android:required="true" />
<uses-permission
android:name="android.permission.CHANGE_WIFI_STATE"
android:required="true" />
<uses-permission
android:name="android.permission.INTERNET"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.realtek.uartthrough.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.realtek.uartthrough.ChatActivity"
android:label="@string/title_activity_chat" >
</activity>
</application>
</manifest>

View file

@ -0,0 +1,183 @@
package com.realtek.uartthrough;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
public class ChatActivity extends Activity {
//UI layout
private ImageButton btn_back;
private EditText editTx_send;
private Button btn_send;
private TextView text_chatDisplay;
private boolean rxThreadExit = false;
//Thread
private Thread rxThread = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_chat);
initData();
initComponent();
initComponentAction();
}
@Override
protected void onStart()
{
super.onStart();
rxThread = new Thread(){
@Override
public void run() {
//while(!isInterrupted()){
while(!rxThreadExit){
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
runOnUiThread(new Runnable() {
@Override
public void run() {
if(MainActivity.g_d.isReadable()) {
updateInfoDisplay(MainActivity.g_d.getInfo());
MainActivity.g_d.resetInfo();
MainActivity.g_d.setReadable(false);
}
}}
);
}
rxThreadExit = false;
Log.i("Sean debugging", "Chat rxThread exit");
}
};
rxThread.start();
}
@Override
protected void onStop() {
super.onStop();
if(rxThread != null){
//rxThread.interrupt();
rxThreadExit = true;
rxThread = null;
}
}
private void initData() {
// TODO Auto-generated method stub
}
private void initComponent() {
btn_back = (ImageButton) findViewById(R.id.btn_back);
editTx_send = (EditText) findViewById(R.id.editTx_send);
btn_send = (Button) findViewById(R.id.btn_send);
text_chatDisplay = (TextView) findViewById(R.id.chatDisplay);
SimpleDateFormat df = new SimpleDateFormat("yyyy.MM.dd");
String date = df.format(Calendar.getInstance().getTime());
text_chatDisplay.append("========== "+date+" ==========\n");
editTx_send.setText("");
}
private void initComponentAction() {
btn_back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MainActivity.g_d.setCmd("stop");
MainActivity.g_d.resetInfo();
MainActivity.g_d.opStates().setOpState(MainActivity.g_d.opStates().stateAppStart());
Intent intent_Navigation = new Intent();
intent_Navigation.setClass(ChatActivity.this, MainActivity.class);
startActivity(intent_Navigation);
finish();
}
});
btn_send.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(editTx_send.getText().toString().length()>0){
String text = editTx_send.getText().toString();
MainActivity.g_d.setTx(text);
MainActivity.g_d.setCmd("send");
//text_chatDisplay.setTextColor(Color.parseColor("#e54545"));
text_chatDisplay.append( Html.fromHtml(getCurrentTimeforHTML()) );
text_chatDisplay.append( Html.fromHtml( "<font color=\"#47a842\">[Me]" + text + "</font>" ) );
text_chatDisplay.append("\n");
editTx_send.setText("");
}
}
});
}
private void updateInfoDisplay(String recvStr) {
if(recvStr.length()>0){
String lines[] = recvStr.split("\\r?\\n");
for (int i = 0; i < lines.length; i++) {
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
String date = df.format(Calendar.getInstance().getTime());
//text_chatDisplay.setTextColor(Color.parseColor("#8ebbeb"));
text_chatDisplay.append(Html.fromHtml(getCurrentTimeforHTML()));
text_chatDisplay.append(Html.fromHtml("<font color=\"#8ebbeb\">[Ameba]" + lines[i] + "</font>"));
text_chatDisplay.append("\n");
}
}
}
private String getCurrentTimeforHTML() {
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
String date = df.format(Calendar.getInstance().getTime());
String result = "<i><small><font color=\"#c5c5c5\">"+ date + "</font></small></i>";
return result;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.chat, menu);
return true;
}
}

View file

@ -0,0 +1,87 @@
package com.realtek.uartthrough;
//import java.io.Serializable;
public class DeviceManager {
public static enum CmdType {
/*SETUP,
CH_POS,
REMOVE,
TIP_G,
TIP,
RENAME,
TODO_FINISH,*/
DEFAULT
};
public static class DeviceInfo //implements Serializable
{
private static final long serialVersionUID = 1L;
private int aliveFlag;
private String name;
private String name_small;
private String IP;
private int port;
private String macAdrress;
private int img;
public int getaliveFlag()
{
return this.aliveFlag;
}
public void setaliveFlag(int aliveFlag)
{
this.aliveFlag = aliveFlag;
}
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name= name;
}
public String getName_small()
{
return this.name_small;
}
public void setName_small(String name)
{
this.name_small= name;
}
public String getIP()
{
return this.IP;
}
public void setIP(String IP)
{
this.IP= IP;
}
public int getPort()
{
return this.port;
}
public void setPort(int port)
{
this.port= port;
}
public String getmacAdrress()
{
return this.macAdrress;
}
public void setmacAdrress(String macAdrress)
{
this.macAdrress= macAdrress;
}
public int getimg()
{
return this.img;
}
public void setimg(int speaker)
{
this.img= speaker;
}
}
}

View file

@ -0,0 +1,294 @@
package com.realtek.uartthrough;
import android.net.nsd.NsdServiceInfo;
import android.util.Log;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Objects;
import java.util.Vector;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class Globals_ctrl {
private static Globals_ctrl thisGlobal;
private static String infoDisplay = "";
private static final String mServiceName = "AMEBA";
private static final String TAG = "Globals_ctrl";
private static final String mServiceType = "_uart_control._tcp";
private static String successRec = "";
private static String sensorReadings = "";
private static Vector<NsdServiceInfo> deviceList = new Vector<NsdServiceInfo>();
private static InetAddress connIP = null;
private static int connPort=0;
private static String cmd="continue";
private static ByteBuffer tx = ByteBuffer.allocate(32);
private static byte[] recvBuffer = new byte[64];
private final Lock _mutex_recvBuf = new ReentrantLock(true);
private static OpStates os = OpStates.getInstance();
public Globals_ctrl(){}
public void resetRecvBuffer(){
Arrays.fill( recvBuffer, (byte) 0 );
}
public boolean checkRecvBufUpdate(){
if(recvBuffer.length>0)
return true;
else
return false;
}
public void commitRecvBuffer(byte[] info, int len){
_mutex_recvBuf.lock();
resetRecvBuffer();
System.arraycopy(info, 0, recvBuffer, 0, len);
_mutex_recvBuf.unlock();
}
public String pullRecvBuffer(){
if(recvBuffer[0]<=0){
return "";
}else{
_mutex_recvBuf.lock();
byte [] res = new byte[recvBuffer.length];
System.arraycopy(recvBuffer, 0, res, 0, recvBuffer.length);
_mutex_recvBuf.unlock();
String controlInfo = parseRecvBuf(res);
return controlInfo;
}
}
private String parseRecvBuf(byte[] res) {
String result = "";
//check prefix
if(checkPrefix(res)){
int readbit = 10;
//-------- response for setting --------
if( convertirOctetEnEntier(res[readbit])==1 ){
result = "ok";
//-------- response for getting --------
}else if( convertirOctetEnEntier(res[readbit])==3 ){
readbit++;
int type = -1;
String str_len = "";
String str_HexValue = "";
do{
type = convertirOctetEnEntier(res[readbit]);
str_HexValue = Integer.toHexString(type);
if( type==1 ){//baudrate
result += "baudrate,";readbit++;
str_len = Integer.toHexString(convertirOctetEnEntier(res[readbit]));
int len = Integer.valueOf(str_len).intValue();
readbit++;
int bit = 0;
int v_rate = 0;
int tmp = 0;
for(int b=readbit;b<readbit+len;b++){
tmp = (res[b] & 0xFF) << (8*bit);
v_rate = v_rate + tmp ;
bit++;
}
result = result + String.valueOf(v_rate) + ";";readbit+=len;
}else if( type==2 ){//data
result += "data,";readbit++;
str_len = Integer.toHexString(convertirOctetEnEntier(res[readbit])) + ",";
readbit++;
result = result + Integer.toHexString(convertirOctetEnEntier(res[readbit])) + ";";readbit++;
}else if( type==4 ){//parity
result += "parity,";readbit++;
str_len = Integer.toHexString(convertirOctetEnEntier(res[readbit])) + ",";
readbit++;
result = result + Integer.toHexString(convertirOctetEnEntier(res[readbit])) + ";";readbit++;
}else if( type==8 ){//stopbit
result += "stopbit,";readbit++;
str_len = Integer.toHexString(convertirOctetEnEntier(res[readbit])) + ",";
readbit++;
result = result + Integer.toHexString(convertirOctetEnEntier(res[readbit])) + ";";readbit++;
}else if( type==16 ){//flowcontrol
result += "flowcontrol,";readbit++;
str_len = Integer.toHexString(convertirOctetEnEntier(res[readbit])) + ",";
readbit++;
result = result + Integer.toHexString(convertirOctetEnEntier(res[readbit])) + ";";readbit++;
}else
readbit++;
}while(readbit<recvBuffer.length );
}
}else{
Log.e(TAG,"prefix error!!!");
}
return result;
}
private boolean checkPrefix(byte[] recvBuf) {
if("41".equals(String.format("0x%20x", recvBuf[0])) )
return false;
if("4D".equals(String.format("0x%20x", recvBuf[1])) )
return false;
if("45".equals(String.format("0x%20x", recvBuf[2])))
return false;
if("42".equals(String.format("0x%20x", recvBuf[3])))
return false;
if("41".equals(String.format("0x%20x", recvBuf[4])))
return false;
if("5F".equals(String.format("0x%20x", recvBuf[5])))
return false;
if("55".equals(String.format("0x%20x", recvBuf[6])))
return false;
if("41".equals(String.format("0x%20x", recvBuf[7])))
return false;
if("52".equals(String.format("0x%20x", recvBuf[8])))
return false;
if("54".equals(String.format("0x%20x", recvBuf[9])))
return false;
return true;
}
public String byte2bits(byte b) {
int z = b; z |= 256;
String str = Integer.toBinaryString(z);
int len = str.length();
return str.substring(len-8, len);
}
public int convertirOctetEnEntier(byte b){
int MASK = 0xFF;
int result = 0;
result = b & MASK;
return result;
}
public int byteArrayToInt(byte[] bytes) {
int value= 0;
for (int i = 0; i < 4; i++) {
int shift= (4 - 1 - i) * 8;
value +=(bytes[i] & 0x000000FF) << shift;
}
return value;
}
public void addInfo(String str){
infoDisplay+=(str+"\n");
}
public String getInfo(){
return infoDisplay;
}
public void resetInfo(){
infoDisplay="";
}
public String getServiceName(){
return mServiceName;
}
public String getServiceType(){
return mServiceType;
}
public String getSuccessRec(){
return successRec;
}
public void setSuccessRec(String str){
successRec=str;
}
public void setConnIP(InetAddress address){
connIP = address;
}
public InetAddress getConnIP(){
return connIP;
}
public void setConnPort(int p){
connPort=p;
}
public int getConnPort(){
return connPort;
}
public void setTx(byte bytes[]){
tx.put(bytes);
}
public byte[] getTx(){
return tx.array();
}
public void clearTx(){ tx.clear();}
public void clearCmd(){
cmd="";
}
public void setCmd(String str){
cmd=str;
}
public String getCmd(){
return cmd;
}
public void clearDeviceList(){
deviceList.clear();
}
public Vector<NsdServiceInfo> getDeviceList(){
return deviceList;
}
public void addSensorReading(String reading){
sensorReadings = sensorReadings + reading;
}
public OpStates opStates(){
return os;
}
public static synchronized Globals_ctrl getInstance(){
if(thisGlobal==null){
thisGlobal = new Globals_ctrl();
}
return thisGlobal;
}
}

View file

@ -0,0 +1,136 @@
package com.realtek.uartthrough;
import android.net.nsd.NsdServiceInfo;
import java.net.InetAddress;
import java.util.Vector;
public class Globals_d {
private static Globals_d thisGlobal;
private static String infoDisplay_d = "";
private static boolean readable = false;
private static final String mServiceName = "AMEBA";
private static final String mServiceType = "_uart_data._tcp";
private static String successRec = "";
private static String sensorReadings = "";
private static Vector<NsdServiceInfo> deviceList = new Vector<NsdServiceInfo>();
private static InetAddress connIP = null;
private static int connPort=0;
private static String cmd="continue";
private static String tx="";
private static OpStates os = OpStates.getInstance();
public Globals_d(){}
public boolean isReadable(){
return readable;
}
public void setReadable(boolean val){
readable = val;
}
public void addInfo(String str){
infoDisplay_d+=(str);
}
public String getInfo(){
return infoDisplay_d;
}
public void resetInfo(){
infoDisplay_d="";
}
public String getServiceName(){
return mServiceName;
}
public String getServiceType(){
return mServiceType;
}
public String getSuccessRec(){
return successRec;
}
public void setSuccessRec(String str){
successRec=str;
}
public void setConnIP(InetAddress address){
connIP = address;
}
public InetAddress getConnIP(){
return connIP;
}
public void setConnPort(int p){
connPort=p;
}
public int getConnPort(){
return connPort;
}
public void setTx(String str){
tx=str;
}
public String getTx(){
return tx;
}
public void clearTx(){
tx="";
}
public void clearCmd(){
cmd="";
}
public void setCmd(String str){
cmd=str;
}
public String getCmd(){
return cmd;
}
public void clearDeviceList(){
deviceList.clear();
}
public Vector<NsdServiceInfo> getDeviceList(){
return deviceList;
}
public void addSensorReading(String reading){
sensorReadings = sensorReadings + reading;
}
public OpStates opStates(){
return os;
}
public static synchronized Globals_d getInstance(){
if(thisGlobal==null){
thisGlobal = new Globals_d();
}
return thisGlobal;
}
}

View file

@ -0,0 +1,846 @@
package com.realtek.uartthrough;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.annotation.SuppressLint;
import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.PopupWindow;
import android.widget.SimpleAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.realtek.uartthrough.DeviceManager.DeviceInfo;
public class MainActivity extends Activity {
//TAG
private final String TAG = "<uartthrough>";
private final String TAG_DISCOVER = "Discovery";
private final String TAG_UI_THREAD = "Update Ui thread";
//Number
public final int DEVICE_MAX_NUM = 32;
private boolean rcvThreadExit = false;
//UI Layout
private TextView text_debug;
private ImageButton btn_scanDevices;
private ImageButton btn_setting;
private ProgressDialog pd;
private GridView gridView;
//UI Variable
private SimpleAdapter adapter_deviceInfo=null;
private SimpleAdapter adapter_deviceInfo_setting=null;
//Variable
public static DeviceInfo [] infoDevices;
public static Globals_d g_d = Globals_d.getInstance();
public int deviceNumberNow = 0;
private Globals_ctrl g_ctrl = Globals_ctrl.getInstance();
private boolean g_discoverEnable = false;
private List<HashMap<String, Object>> devInfoList = new ArrayList<HashMap<String, Object>>();
private NsdCore mNSD;
private String recvBuf = "";
//Thread
private UpdateUiThread uiThread;
private recvThread rcvThread=null;
private final Lock _gmutex_recvBuf = new ReentrantLock(true);
//TcpClient
private TcpClient dataClient;
private TcpClient ctrlClient;
//serial port Setting
byte[] cmdPrefix = new byte[]{0x41, 0x4D, 0x45, 0x42, 0x41, 0x5F, 0x55, 0x41, 0x52, 0x54};
String setting_rate = "";
String setting_data = "";
String setting_parity = "";
String setting_stopbit = "";
String setting_flowc = "";
String[] Setting_baudrate = {"1200", "9600", "14400"
, "19200", "28800", "38400", "57600"
, "76800", "115200", "128000", "153600"
, "230400", "460800", "500000", "921600"};
String[] Setting_data = {"7", "8"};
String[] Setting_parity = {"none", "odd", "even"};//0 , 1 , 2
String[] Setting_stopbit = {"none", "1 bit"};
String[] Setting_flowc = {"not support"};
Handler handler_pd = new Handler(){
@Override
public void handleMessage(Message msg) {
switch(msg.what){
case 0:{
if(pd!=null)
pd.dismiss();
break;
}
default:
break;
}
};
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
@Override
protected void onStart()
{
super.onStart();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
initData();
initComponent();
initComponentAction();
if(rcvThread == null){
rcvThreadExit = false;
Log.i(TAG,"rcvThread create!!");
rcvThread = new recvThread();
rcvThread.start();
}
}
@Override
protected void onStop() {
rcvThreadExit = true;
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
private void initData() {
if(infoDevices==null){
infoDevices = new DeviceInfo[DEVICE_MAX_NUM];
for(int i=0;i<DEVICE_MAX_NUM;i++)
{
infoDevices[i] = new DeviceInfo();
infoDevices[i].setaliveFlag(0);
infoDevices[i].setName("");
infoDevices[i].setName_small("");
infoDevices[i].setIP("");
infoDevices[i].setPort(0);
infoDevices[i].setmacAdrress("");
infoDevices[i].setimg(R.drawable.device);
}
}
}
private void initComponent() {
btn_scanDevices = null;
btn_setting = null;
pd = null;
text_debug = (TextView) findViewById(R.id.text_debug);
btn_scanDevices = (ImageButton) findViewById(R.id.btn_scanDevices);
btn_setting = (ImageButton) findViewById(R.id.btn_setting);
gridView = (GridView)findViewById(R.id.gridview_list);
if(adapter_deviceInfo==null){
adapter_deviceInfo = new SimpleAdapter(this, devInfoList,
R.layout.layout_item, new String[] { "item_image", "item_text" },
new int[] { R.id.item_image, R.id.item_text });
}
if(adapter_deviceInfo_setting==null){
adapter_deviceInfo_setting = new SimpleAdapter(this, devInfoList,
R.layout.layout_item_setting, new String[] { "item_image", "item_text", "item_text_info" },
new int[] { R.id.item_image, R.id.item_text, R.id.item_text_info });
}
gridViewItemComponent();
for(int i=0;i<DEVICE_MAX_NUM;i++){
if(infoDevices[i].getaliveFlag()>0){
reloadDeviceInfo();
break;
}
}
}
private void initComponentAction() {
btn_scanDevices.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
pd = new ProgressDialog(MainActivity.this);
pd.setTitle("Searching...");
pd.setMessage("Please wait...");
pd.setIndeterminate(true);
pd.setCancelable(false);
pd.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
stopDiscover();
dialog.dismiss();
}
});
pd.show();
//Thread
Thread searchThread = new Thread() {
@SuppressLint("NewApi")
@Override
public void run() {
Log.i(TAG,"startDiscover");
try {
startDiscover();
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Message m = new Message();
m.what = 0;
handler_pd.sendMessage(m);
stopDiscover();
Log.i(TAG,"stopDiscover");
deviceNumberNow = g_d.getDeviceList().size();
for(int i=0;i<deviceNumberNow;i++){
/*Log.d(TAG_DISCOVER,"Name: " + g_d.getDeviceList().elementAt(i).getServiceName() );
Log.d(TAG_DISCOVER,"Type: " + g_d.getDeviceList().elementAt(i).getServiceType() );
Log.d(TAG_DISCOVER,"Host: " + g_d.getDeviceList().elementAt(i).getHost() );
Log.d(TAG_DISCOVER,"Port: " + g_d.getDeviceList().elementAt(i).getPort() );*/
infoDevices[i].setaliveFlag(1);
infoDevices[i].setName(g_d.getDeviceList().elementAt(i).getServiceName());
infoDevices[i].setName_small("");
infoDevices[i].setIP(g_d.getDeviceList().elementAt(i).getHost().getHostAddress());
infoDevices[i].setPort(g_d.getDeviceList().elementAt(i).getPort());
infoDevices[i].setmacAdrress("");
}
runOnUiThread(new Runnable() {
@Override
public void run() {
//show scan result
text_debug.setText("");
for(int i=0;i<deviceNumberNow;i++){
text_debug.append("==== " +i+ " ====\n");
text_debug.append("name: "+infoDevices[i].getName()+"\n");
text_debug.append("host: "+infoDevices[i].getIP()+"\n");
text_debug.append("port: "+infoDevices[i].getPort()+"\n");
}
Toast.makeText(MainActivity.this,
String.valueOf(deviceNumberNow) + " Ameba Found",
Toast.LENGTH_SHORT).show();
reloadDeviceInfo();
}
});
}
};
searchThread.start();
}
});
btn_setting.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
AlertDialog.Builder setting_builder;
setting_builder=new AlertDialog.Builder(MainActivity.this);
//speaker_builder.setIcon(R.drawable.ic_dialog_question);
setting_builder.setTitle("Choose One Ameba");
setting_builder.setCancelable(false);
setting_builder.setSingleChoiceItems(adapter_deviceInfo_setting, -1, new DialogInterface.OnClickListener(){
@SuppressLint("NewApi")
@Override
public void onClick(DialogInterface dialog, final int index) {
//Log.d("!!!!!!!!!!!!!","popupView !!!!");
g_ctrl.resetInfo();
//Log.d(TAG,"setting_builder: "+g_ctrl.getDeviceList().elementAt(index).getServiceName());
//Log.d(TAG,"setting_builder: "+g_ctrl.getDeviceList().elementAt(index).getHost());
//Log.d(TAG,"setting_builder: "+g_ctrl.getDeviceList().elementAt(index).getPort());
g_ctrl.setConnIP(g_ctrl.getDeviceList().elementAt(0).getHost());
g_ctrl.setConnPort(g_ctrl.getDeviceList().elementAt(0).getPort());
ctrlClient = new TcpClient(g_ctrl);
ctrlClient.executeOnExecutor(TcpClient.THREAD_POOL_EXECUTOR);
//TODO
byte[] cmdGet_AllSetting = new byte[]{0x02, 0x1F};
ByteBuffer tmp = ByteBuffer.allocate(cmdPrefix.length + cmdGet_AllSetting.length);
tmp.put(cmdPrefix);
tmp.put(cmdGet_AllSetting);
byte[] test = tmp.array();
g_ctrl.setTx(test);
g_ctrl.setCmd("Request");
pd = new ProgressDialog(MainActivity.this);
pd.setTitle("Serial port");
pd.setMessage("Please wait...");
pd.setIndeterminate(true);
pd.setCancelable(false);
pd.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
pd.show();
//Thread
Thread gettingThread = new Thread() {
@Override
public void run() {
int retry = 20;
do{
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}while(retry-->0 && recvBuf.length()==0);
Message m = new Message();
m.what = 0;
handler_pd.sendMessage(m);
//show serial port setting
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this,
recvBuf,
Toast.LENGTH_SHORT).show();
String[] type = recvBuf.split(";");
String[] info = {};
if(type.length!=5)
return;
for(int index=0;index<type.length;index++){
info = type[index].split(",");
if(index==0 ){//rate
setting_rate = info[1];
}else if(index==1){//data
setting_data = info[1];
}else if(index==2){//parity
setting_parity = info[1];
}else if(index==3){//stopbit
setting_stopbit = info[1];
}else if(index==4){//flowcontrol
setting_flowc = info[1];
}
}
recvBuf = "";
LayoutInflater layoutInflater = (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.setting_serialport,null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
Button btnApply = (Button)popupView.findViewById(R.id.btn_setting_apply);
Button btnCancel = (Button)popupView.findViewById(R.id.btn_setting_cancel);
//====== baud rate =======
final Spinner spinner_baudrate = (Spinner)popupView.findViewById(R.id.spinner_baudrate);
ArrayAdapter<String> adapter_baudrate =
new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_item, Setting_baudrate);
adapter_baudrate.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_baudrate.setAdapter(adapter_baudrate);
int spinnerPosition = adapter_baudrate.getPosition(setting_rate);
spinner_baudrate.setSelection(spinnerPosition);
//====== data =======
final Spinner spinner_data = (Spinner)popupView.findViewById(R.id.spinner_data);
ArrayAdapter<String> adapter_data =
new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_item, Setting_data);
adapter_data.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_data.setAdapter(adapter_data);
spinnerPosition = adapter_data.getPosition(setting_data);
spinner_data.setSelection(spinnerPosition);
//====== parity =======
final Spinner spinner_parity = (Spinner)popupView.findViewById(R.id.spinner_parity);
ArrayAdapter<String> adapter_parity =
new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_item, Setting_parity);
adapter_parity.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_parity.setAdapter(adapter_parity);
spinnerPosition = Integer.valueOf(setting_parity).intValue();//adapter_parity.getPosition(parity);
spinner_parity.setSelection(spinnerPosition);
//====== stop bit =======
final Spinner spinner_stopbit = (Spinner)popupView.findViewById(R.id.spinner_stopbit);
ArrayAdapter<String> adapter_stopbit =
new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_item, Setting_stopbit);
adapter_stopbit.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_stopbit.setAdapter(adapter_stopbit);
spinnerPosition = Integer.valueOf(setting_stopbit).intValue();//adapter_stopbit.getPosition(stopbit);
spinner_stopbit.setSelection(spinnerPosition);
//====== flow control=======
final Spinner spinner_flowc = (Spinner)popupView.findViewById(R.id.spinner_flowcontrol);
ArrayAdapter<String> adapter_flowc =
new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_item, Setting_flowc);
adapter_flowc.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_flowc.setAdapter(adapter_flowc);
spinnerPosition = adapter_flowc.getPosition(setting_flowc);
spinner_flowc.setSelection(spinnerPosition);
btnApply.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
//TODO
setting_rate = spinner_baudrate.getSelectedItem().toString();
setting_data = spinner_data.getSelectedItem().toString();
setting_parity = spinner_parity.getSelectedItem().toString();
setting_stopbit = spinner_stopbit.getSelectedItem().toString();
setting_flowc = spinner_flowc.getSelectedItem().toString();
g_ctrl.setTx(combineReqCmd( setting_rate,
setting_data,
setting_parity,
setting_stopbit,
setting_flowc));
g_ctrl.setCmd("Request");
// Log.d(TAG,"requestCmd: " + requestCmd);
pd = new ProgressDialog(MainActivity.this);
pd.setTitle("Serial port");
pd.setMessage("Please wait...");
pd.setIndeterminate(true);
pd.setCancelable(false);
pd.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
pd.show();
//Thread
Thread settingThread = new Thread() {
@Override
public void run() {
int retry = 20;
do{
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}while(retry-->0 && recvBuf.length()==0);
Message m = new Message();
m.what = 0;
handler_pd.sendMessage(m);
g_ctrl.setCmd("stop");
//show serial port setting
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this,
recvBuf,
Toast.LENGTH_SHORT).show();
recvBuf = "";
};
});
}};
settingThread.start();
popupWindow.dismiss();
}
private byte[] combineReqCmd(String setting_rate, String setting_data, String setting_parity, String setting_stopbit, String setting_flowc) {
String result = "";
//<20150412> So far, flow control no support.
byte[] cmdSet_rate = null;
byte[] cmdSet_data = null;
byte[] cmdSet_parity = null;
byte[] cmdSet_stopbit = null;
//byte[] cmdSet_flowc = new byte[3];
if(setting_rate.equals("1200")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0xB0,(byte)0x04,(byte)0x00,(byte)0x00};
}else if(setting_rate.equals("9600")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte) 0x80,0x25,(byte)0x00,(byte)0x00};
}else if(setting_rate.equals("14400")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x40,(byte)0x38,(byte)0x00,(byte)0x00};
}else if(setting_rate.equals("19200")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0x4B,(byte)0x00,(byte)0x00};
}else if(setting_rate.equals("28800")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x80,(byte)0x70,(byte)0x00,(byte)0x00};
}else if(setting_rate.equals("38400")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0x96,(byte)0x00,(byte)0x00};
}else if(setting_rate.equals("57600")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0xE1,(byte)0x00,(byte)0x00};
}else if(setting_rate.equals("76800")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0x2C,(byte)0x01,(byte)0x00};
}else if(setting_rate.equals("115200")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0xC2,(byte)0x01,(byte)0x00};
}else if(setting_rate.equals("128000")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0xF4,(byte)0x01,(byte)0x00};
}else if(setting_rate.equals("153600")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0x58,(byte)0x02,(byte)0x00};
}else if(setting_rate.equals("230400")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0x84,(byte)0x03,(byte)0x00};
}else if(setting_rate.equals("460800")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0x08,(byte)0x07,(byte)0x00};
}else if(setting_rate.equals("500000")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x20,(byte)0xA1,(byte)0x07,(byte)0x00};
}else if(setting_rate.equals("921600")){
cmdSet_rate = new byte[]{ (byte)0x01,(byte)0x04,(byte)0x00,(byte)0x10,(byte)0x0E,(byte)0x00};
}
if(setting_data.equals("8")){
cmdSet_data = new byte[]{ 0x02,0x01, 0x08};
}else{
cmdSet_data = new byte[]{ 0x02,0x01, 0x07};
}
if(setting_parity.equals("none")){
cmdSet_parity = new byte[]{ 0x04,0x01, 0x00};
}else if(setting_parity.equals("odd")){
cmdSet_parity = new byte[]{ 0x04,0x01, 0x01};
}else if(setting_parity.equals("even")){
cmdSet_parity = new byte[]{ 0x04,0x01, 0x02};
}
if(setting_stopbit.equals("none")){
cmdSet_stopbit = new byte[]{ 0x08,0x01, 0x00};
}else if(setting_stopbit.equals("1 bit")){
cmdSet_stopbit = new byte[]{ 0x08,0x01, 0x01};
}
byte[] reqCmdByte = new byte[]{0x00};
//combine req cmd
ByteBuffer reqTmp = ByteBuffer.allocate(cmdPrefix.length +
reqCmdByte.length+
cmdSet_rate.length+
cmdSet_data.length+
cmdSet_parity.length+
cmdSet_stopbit.length);
reqTmp.put(cmdPrefix);
reqTmp.put(reqCmdByte);
reqTmp.put(cmdSet_rate);
reqTmp.put(cmdSet_data);
reqTmp.put(cmdSet_parity);
reqTmp.put(cmdSet_stopbit);
byte[] test = reqTmp.array();
return reqTmp.array();
}
});
btnCancel.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
g_ctrl.setCmd("stop");
popupWindow.dismiss();
}
});
popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
}
});
}
};
gettingThread.start();
dialog.cancel();
}
} );
setting_builder.setPositiveButton("Cancel",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
setting_builder.create().show();
}
});
//======================= action ======================
//search devices when no device
boolean isSearchTrigger = true;
for(int i=0;i<DEVICE_MAX_NUM;i++){
if(infoDevices[i].getaliveFlag()>0){
isSearchTrigger = false;
break;
}
}
if(isSearchTrigger){
btn_scanDevices.performClick();
}
}
protected int parseInfo(String recvBuf) {
//TODO
return 1;
//-------- response for getting --------
}
private void gridViewItemComponent() {
gridView.setOnItemClickListener( new OnItemClickListener(){
@SuppressLint("NewApi")
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position,
long id) {
//Log.d(TAG,infoDevices[position].getName());
Toast.makeText(MainActivity.this,"Connect to "+
infoDevices[position].getName(),
Toast.LENGTH_SHORT).show();
//TODO
g_d.resetInfo();
g_d.setConnIP(g_d.getDeviceList().elementAt(0).getHost());
g_d.setConnPort(g_d.getDeviceList().elementAt(0).getPort());
g_d.setCmd("Hello");
dataClient = new TcpClient(g_d);
dataClient.executeOnExecutor(TcpClient.THREAD_POOL_EXECUTOR);
g_d.opStates().setOpState(g_d.opStates().stateConnectedServer());
Intent intent_Navigation = new Intent();
intent_Navigation.setClass(MainActivity.this, ChatActivity.class);
startActivity(intent_Navigation);
finish();
}
});
}
private void startDiscover() {
Log.d(TAG_DISCOVER, "Start Service Button clicked");
g_d.resetInfo();
g_d.clearDeviceList();
g_ctrl.resetInfo();
g_ctrl.clearDeviceList();
g_discoverEnable = true;
if (mNSD==null){
mNSD = new NsdCore(this);
mNSD.initializeNsd();
}
mNSD.discoverServices(g_d.getServiceType());
mNSD.discoverServices(g_ctrl.getServiceType());
if(uiThread==null){
uiThread = new UpdateUiThread();
uiThread.start();
}
g_d.opStates().setOpState(g_d.opStates().stateDiscoveringService());
g_ctrl.opStates().setOpState(g_d.opStates().stateDiscoveringService());
}
private void stopDiscover(){
g_discoverEnable = false;
Log.d(TAG_DISCOVER,"canceling discovering clicked");
mNSD.stopDiscovery();
//uiThread.interrupt();
g_d.opStates().setOpState(g_d.opStates().stateAppStart());
g_ctrl.opStates().setOpState(g_d.opStates().stateAppStart());
}
private void reloadDeviceInfo() {
devInfoList.clear();
for(int i=0;i<infoDevices.length;i++){
if(infoDevices[i].getaliveFlag()==1){
HashMap<String, Object> reloadItemHashMap = new HashMap<String, Object>();
reloadItemHashMap.put("item_image",infoDevices[i].getimg());
reloadItemHashMap.put("item_text", infoDevices[i].getName());
reloadItemHashMap.put("item_text_info", infoDevices[i].getIP());
devInfoList.add(reloadItemHashMap);
}
}
gridView.setAdapter(adapter_deviceInfo);
}
public class recvThread extends Thread{
//======================= Thread ======================
@Override
public void run() {
//Log.d(TAG,"recvThread Run");
while(!rcvThreadExit){
if(g_ctrl.checkRecvBufUpdate() && g_ctrl.pullRecvBuffer().length()>0){
_gmutex_recvBuf.lock();
//Log.d(TAG,"recvBuf: lock " + recvBuf + " update? " + g_ctrl.checkRecvBufUpdate() + " length: "+g_ctrl.pullRecvBuffer().length());
recvBuf = g_ctrl.pullRecvBuffer();
g_ctrl.resetRecvBuffer();
_gmutex_recvBuf.unlock();
if(parseInfo(recvBuf)<0)
Log.e(TAG,"parseInfo(recvBuf) Fail!!!!!");
}
try {
// Log.d(TAG,"recvThread update " + g_ctrl.checkRecvBufUpdate() +" pullRecvBuffer length " + g_ctrl.pullRecvBuffer().length());
//Log.d(TAG,"isInterrupted() " + isInterrupted());
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
//Log.d(TAG,"recvThread exit");
}
//recvThread.start();
}
/*
* Class - UpdateUiThread
*/
public class UpdateUiThread extends Thread {
Globals_d g_d = Globals_d.getInstance();
private static final int DELAY = 200; // ms
@Override
public void run() {
Log.v(TAG_UI_THREAD, "Update Ui thread started");
while(g_discoverEnable){
//Log.d(TAG_UI_THREAD,"-----------");
//Log.d(TAG_UI_THREAD,g_d.getInfo());
try {
Thread.sleep(DELAY);
} catch (InterruptedException e) {
Log.e(TAG_UI_THREAD,"Update Ui thread err");
return;
}
}
Log.v(TAG_UI_THREAD, "Update Ui thread close");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

View file

@ -0,0 +1,237 @@
package com.realtek.uartthrough;
import android.annotation.SuppressLint;
import android.content.Context;
import android.net.nsd.NsdManager;
import android.net.nsd.NsdServiceInfo;
import android.util.Log;
import java.lang.*;
public class NsdCore {
Globals_ctrl g_ctrl = Globals_ctrl.getInstance();
Globals_d g_d = Globals_d.getInstance();
Context mContext;
NsdManager mNsdManager;
NsdManager.ResolveListener mResolveListener;
NsdManager.DiscoveryListener mDiscoveryListener;
NsdManager.RegistrationListener mRegistrationListener;
public static final String TAG = "NsdCore";
public final String mServiceType_c = g_ctrl.getServiceType();
public final String mServiceType_d = g_d.getServiceType();
public String mServiceName_c = g_ctrl.getServiceName();
public String mServiceName_d = g_d.getServiceName();
NsdServiceInfo mService;
public NsdCore(Context context) {
mContext = context;
mNsdManager = (NsdManager) context.getSystemService(Context.NSD_SERVICE);
}
public void initializeNsd() {
Log.i(TAG, " discovery initializeNsd: " + mServiceType_c +" & "+mServiceType_d);
initializeDiscoveryListener();
initializeResolveListener();
initializeRegistrationListener();
}
@SuppressLint("NewApi")
public void initializeDiscoveryListener() {
mDiscoveryListener = new NsdManager.DiscoveryListener() {
@Override
public void onDiscoveryStarted(String regType) {
Log.i(TAG, "Service discovery started");
g_ctrl.addInfo(TAG+" "+regType+" g_ctrl Service Discovering\n");
g_d.addInfo(TAG+" "+regType+" g_d Service Discovering\n");
}
@Override
public void onServiceFound(NsdServiceInfo service) {
g_ctrl.addInfo(TAG+"Service discovery success\n " + service);
g_d.addInfo(TAG+"Service Discovery Success\n " + service);
Log.i(TAG, "Service discovery success " + service);
if (service.getServiceType().contains(mServiceType_c)) {
if (service.getServiceName().contains(mServiceName_c)){
g_ctrl.addInfo(TAG+ "Resolving service... \n");
Log.i(TAG, "G_c Resolving service... ");
mNsdManager.resolveService(service, mResolveListener);
}
}else{
g_ctrl.addInfo(TAG+ "Unknown Service Type: " + service.getServiceType());
Log.e(TAG, "G Unknown Service Type: " + service.getServiceType() );
}
if (service.getServiceType().contains(mServiceType_d)) {
if (service.getServiceName().contains(mServiceName_d)) {
g_d.addInfo(TAG + "Resolving service... \n");
Log.i(TAG, "G_d Resolving service... ");
mNsdManager.resolveService(service, mResolveListener);
}
}else{
g_d.addInfo(TAG+ "Unknown Service Type: " + service.getServiceType());
Log.e(TAG, "G_d Unknown Service Type: " + service.getServiceType());
}
}
@Override
public void onServiceLost(NsdServiceInfo service) {
g_ctrl.addInfo(TAG+ "service lost\n" + service);
g_d.addInfo(TAG+ "service lost\n" + service);
Log.e(TAG, "service lost" + service);
if (mService == service) {
mService = null;
}
}
@Override
public void onDiscoveryStopped(String serviceType) {
g_ctrl.addInfo(TAG+ "Discovery stopped:\n " + serviceType);
g_d.addInfo(TAG+ "Discovery stopped:\n " + serviceType);
Log.e(TAG, "Discovery stopped: " + serviceType);
}
@Override
public void onStartDiscoveryFailed(String serviceType, int errorCode) {
g_ctrl.addInfo(TAG+"Discovery failed: Error code:\n" + errorCode);
g_d.addInfo(TAG+"Discovery failed: Error code:\n" + errorCode);
Log.e(TAG, "onStartDiscoveryFailed: Error code:" + errorCode);
mNsdManager.stopServiceDiscovery(this);
}
@Override
public void onStopDiscoveryFailed(String serviceType, int errorCode) {
g_ctrl.addInfo(TAG+ "Discovery failed: Error code:\n" + errorCode);
g_d.addInfo(TAG+ "Discovery failed: Error code:\n" + errorCode);
Log.e(TAG, "onStopDiscoveryFailed: Error code:" + errorCode);
mNsdManager.stopServiceDiscovery(this);
}
};
}
@SuppressLint("NewApi")
public void initializeResolveListener() {
mResolveListener = new NsdManager.ResolveListener() {
@SuppressLint("NewApi")
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
g_ctrl.addInfo(TAG+ "Resolve failed\n" + errorCode);
g_d.addInfo(TAG+ "Resolve failed\n" + errorCode);
Log.e(TAG, "Resolve failed: " + errorCode);
Log.e(TAG, "onResolveFailed"+ " " + serviceInfo.getServiceType());
switch (errorCode) {
case NsdManager.FAILURE_ALREADY_ACTIVE:
Log.e(TAG, "FAILURE_ALREADY_ACTIVE");
// Just try again...
try {
Thread.sleep(300);
} catch (Exception e) {
System.out.println(e);
}
mNsdManager.resolveService( serviceInfo, mResolveListener);
break;
case NsdManager.FAILURE_INTERNAL_ERROR:
Log.e(TAG, "FAILURE_INTERNAL_ERROR");
break;
case NsdManager.FAILURE_MAX_LIMIT:
Log.e(TAG, "FAILURE_MAX_LIMIT");
default:
Log.e(TAG,"XXXXXXX onResolveFailed XXXXXXXX");
break;
}
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Log.e(TAG, "onServiceResolved"+ " " + serviceInfo.getServiceType());
mService = serviceInfo;
if (serviceInfo.getServiceType().contains(mServiceType_c)) {
//Log.e(TAG, "G onServiceResolved");
g_ctrl.opStates().setOpState(g_ctrl.opStates().stateResoledService());
g_ctrl.addInfo(TAG + "Resolve Succeeded.\n " + serviceInfo);
g_ctrl.setSuccessRec(TAG + "Resolve Succeeded. " + serviceInfo);
g_ctrl.getDeviceList().add(mService);//TODO check ip before add to list
}else if (serviceInfo.getServiceType().contains(mServiceType_d)) {
//Log.e(TAG, "G_D onServiceResolved");
g_d.opStates().setOpState(g_d.opStates().stateResoledService());
g_d.addInfo(TAG + "Resolve Succeeded. \n" + serviceInfo);
g_d.setSuccessRec(TAG + "Resolve Succeeded. " + serviceInfo);
g_d.getDeviceList().add(mService);//TODO check ip before add to list
}
Log.w(TAG, "Resolve Succeeded. " + serviceInfo);
}
};
}
@SuppressLint("NewApi")
public void initializeRegistrationListener() {
mRegistrationListener = new NsdManager.RegistrationListener() {
@SuppressLint("NewApi")
@Override
public void onServiceRegistered(NsdServiceInfo NsdServiceInfo) {
String serviceName = NsdServiceInfo.getServiceName();
Log.e(TAG,"NsdServiceInfo.getServiceName(): " + NsdServiceInfo.getServiceName());
mServiceName_c = NsdServiceInfo.getServiceName();
mServiceName_d = mServiceName_c;
}
@Override
public void onRegistrationFailed(NsdServiceInfo arg0, int arg1) {
Log.e(TAG, "onRegistrationFailed");
}
@Override
public void onServiceUnregistered(NsdServiceInfo arg0) {
Log.e(TAG, "onServiceUnregistered");
}
@Override
public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.e(TAG, "onServiceUnregistered: " + serviceInfo.getServiceName() + "/" + errorCode);
}
};
}
@SuppressLint("NewApi")
public void discoverServices(String serviceType) {
Log.d(TAG, "discoverServices " +serviceType+ " start!!");
//mNsdManager.discoverServices(mServiceType, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);
mNsdManager.discoverServices(serviceType, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);
}
@SuppressLint("NewApi")
public void stopDiscovery() {
mNsdManager.stopServiceDiscovery(mDiscoveryListener);
}
/* public NsdServiceInfo getChosenServiceInfo() {
return mService;
}*/
/* public void tearDown() {
mNsdManager.unregisterService(mRegistrationListener);
}*/
}

View file

@ -0,0 +1,64 @@
package com.realtek.uartthrough;
public class OpStates {
private static OpStates thisOpS;
///////////////////////operation states///////////////////////////////
private static String currState="";
private static String appStart ="application start";
private static String discoveringService="discovering service";
private static String discoveredService ="discovered service";
private static String resoledService ="resoled service";
private static String connectedServer="connected to server";
private static String stoppedConnection="stopped connection to server";
private static String appQuit="application quit";
public String getOpState(){
return currState;
}
public void setOpState(String state){
currState=state;
}
public String stateAppStart(){
return appStart;
}
public String stateDiscoveringService(){
return discoveringService;
}
public String stateDiscoveredService(){
return discoveredService;
}
public String stateResoledService(){
return resoledService;
}
public String stateConnectedServer(){
return connectedServer;
}
public String stateStoppedConnection(){
return stoppedConnection;
}
public String stateAppQuit(){
return appQuit;
}
public boolean onOpState(String state){
if(currState==state){
return true;
}
else {
return false;
}
}
////////////////////////operation states end//////////////////////////////
public OpStates(){}
public static synchronized OpStates getInstance(){
if(thisOpS==null){
thisOpS=new OpStates();
}
return thisOpS;
}
}

View file

@ -0,0 +1,209 @@
package com.realtek.uartthrough;
import android.os.AsyncTask;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
///////////////////////////////////////////////
public class TcpClient extends AsyncTask<Void, Void, Void> {
public static final String TAG = "TCP_Client";
public static final String TAG_CTRL = "TCP_Client(CTRL): ";
public static final String TAG_DATA = "TCP_Client(DATA): ";
int type;
Globals_ctrl g_ctrl ;
Globals_d g_d;
InetAddress ip;
int port ;
String cmd_ctrl_req = "null";
String cmd_ctrl_response = "null";
String cmd = "null";
ByteBuffer bf = ByteBuffer.allocate(1024);
CharBuffer cbuf = bf.asCharBuffer();
public TcpClient(Globals_ctrl gInstance) {
//Log.w("TcpClient Developing","G instructor control port");
g_ctrl = gInstance;
ip = g_ctrl.getConnIP();
port = g_ctrl.getConnPort();
type = 0;
}
public TcpClient(Globals_d gInstance) {
//Log.w("TcpClient Developing","G_d instructor data port");
g_d = gInstance;
ip = g_d.getConnIP();
port = g_d.getConnPort();
type = 1;
}
@Override
protected Void doInBackground(Void...params) {
//g_d.addInfo("TcpClient start");
try {
do{
Thread.sleep(1000);
final Socket s = new Socket(ip, port);
s.setTcpNoDelay(true);
final BufferedInputStream rx = new BufferedInputStream(s.getInputStream());
final PrintStream tx = new PrintStream(s.getOutputStream());
switch (type) {
case 0: // control port
g_ctrl.resetInfo();
/*==========================
* thread for control TX
* =========================
*/
new Thread(new Runnable() {
public void run() {
do {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Log.v(TAG_CTRL,"TX thread error");
break;
}
cmd_ctrl_req = g_ctrl.getCmd();
if(cmd_ctrl_req.equals("Request")) {
try {
tx.write(g_ctrl.getTx());
} catch (IOException e) {
Log.v(TAG_CTRL,"TX write error");
break;
}
tx.flush();
g_ctrl.clearTx();
g_ctrl.clearCmd();
}
}while ( !cmd_ctrl_req.equals("stop") );
tx.close();
}
}).start();
/*==========================
* for control RX
* =========================
*/
int len;
byte [] recv_buf = new byte[64];
while (!cmd_ctrl_response.equals("stop")) {
cmd_ctrl_response = g_ctrl.getCmd();
if( rx.available() > 0 ) {
len = rx.read(recv_buf);
g_ctrl.commitRecvBuffer(recv_buf,len);
}else{
Thread.sleep(200);
}
}
break;
case 1: //data port
g_d.resetInfo();
/*==========================
* thread for data TX
* =========================
*/
new Thread(new Runnable() {
public void run() {
do {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Log.v(TAG_DATA,"TX thread error");
break;
}
cmd = g_d.getCmd();
if(cmd.equals("send")) {
tx.println(g_d.getTx());
g_d.clearTx();
g_d.clearCmd();
}
}while ( !cmd.equals("stop") );
tx.close();
}
}).start();
/*==========================
* for data RX
* =========================
*/
int b=0;
cmd = g_d.getCmd();
while (!cmd.equals("stop")) {
cmd = g_d.getCmd();
if( rx.available() > 0 ) {
while(rx.available() > 0) {
b = rx.read();
cbuf.put((char) b);
cbuf.flip();
g_d.addInfo(cbuf.toString());
if(rx.available() == 0) {
g_d.setReadable(true);
}
}
}else{
Thread.sleep(200);
}
}
break;
default:
break;
}
if(!s.isClosed()) {
rx.close();
s.close();
}
}while ( !(!cmd_ctrl_response.equals("stop") || !cmd.equals("stop")) );
if(type == 0)
Log.w(TAG, "TCP Control RX Quit");
else
Log.w(TAG, "TCP data RX Quit");
}
catch (Exception err)
{
Log.e(TAG,""+err);
}
return null;
}
/*
@Override
protected void onPostExecute(Void result) {
//do something....
super.onPostExecute(result);
}
*/
}

View file

@ -0,0 +1,31 @@
package com.realtek.uartthrough;
public class UARTCmd {
//cmd_c : AMEBA_UART 0x02, 0x01
//public char cmd_c[] ={0x41, 0x4D, 0x45, 0x42, 0x41, 0x5F, 0x55, 0x41, 0x52, 0x54, 0x02, 0x01};
public char cmd_c[] ={0x41, 0x4D, 0x45, 0x42, 0x41, 0x5F, 0x55, 0x41, 0x52, 0x54};
public static enum UART_Setting_Type {
UART_BaudRate,
UART_Data,
UART_Parity,
UART_Stop,
UART_FlowControl,
DEFAULT
};
public char[] getReqSettingCmd(UART_Setting_Type uartType){
char[] result = cmd_c;
switch(uartType){
case UART_BaudRate:{
break;
}
}
return cmd_c;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/layer1_linear0"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:background="@drawable/bg_index01"
android:layout_weight="1">
<ImageButton
android:id="@+id/btn_back"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="2dp"
android:src="@drawable/back"/>
<TextView
android:id="@+id/APPTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center"
android:layout_weight="1.75"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Let us just chat"
android:textColor="@android:color/black"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layer1_linear2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@drawable/bg_index1"
android:layout_weight="8">
<ScrollView
android:id="@+id/chat_ScrollView"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#ffeeeeee"
android:fillViewport="false" >
<TextView
android:id="@+id/chatDisplay"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:background="#ffffffff"
android:focusable="true"
android:focusableInTouchMode="true"/>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/layer1_linear3"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="@+id/editTx_send"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.52"
android:clickable="true"
android:ems="10"
android:enabled="true"
android:text=""
android:textSize="14dp" />
<Button
android:id="@+id/btn_send"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Send" />
</LinearLayout>
<LinearLayout
android:id="@+id/debugLayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#FFFFFF"
android:layout_weight="0">
<TextView
android:id="@+id/text_test"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text=""
android:textSize="12sp"
android:maxLines = "9999999"
android:scrollbars = "vertical"/>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/layer1_linear0"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:background="@drawable/bg_index01"
android:layout_weight="1">
<ImageView
android:id="@+id/APPimageView"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="2dp"
android:src="@drawable/logo"/>
<TextView
android:id="@+id/APPTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center"
android:layout_weight="3"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Uart Through"
android:textColor="@android:color/black"
android:textSize="16sp" />
<ImageButton
android:id="@+id/btn_scanDevices"
android:contentDescription="@string/app_name"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="5dp"
android:layout_margin= "1dp"
android:src="@drawable/search"/>
<!--ImageButton
android:id="@+id/btn_addDevice"
android:contentDescription="@string/app_name"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="5dp"
android:layout_margin= "1dp"
android:src="@drawable/add"/-->
<ImageButton
android:id="@+id/btn_setting"
android:contentDescription="@string/app_name"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:padding="5dp"
android:layout_margin= "1dp"
android:src="@drawable/setting"/>
</LinearLayout>
<LinearLayout
android:id="@+id/layer1_linear2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@drawable/bg_index1"
android:layout_weight="8">
<GridView
android:id="@+id/gridview_list"
android:listSelector="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
android:numColumns="2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="35dp"
android:gravity="center"
android:layout_gravity="center"
android:columnWidth="50pt"
android:stretchMode="columnWidth"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/debugLayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#FFFFFF"
android:layout_weight="0">
<TextView
android:id="@+id/text_test"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text=""
android:textSize="12sp"
android:maxLines = "9999999"
android:scrollbars = "vertical"/>
</LinearLayout>
<LinearLayout
android:id="@+id/debugLayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#FFFFFF"
android:layout_weight="3">
<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="@+id/text_debug"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Debug Message"
android:textSize="12sp"
android:maxLines = "9999999"
android:scrollbars = "vertical"/>
</ScrollView>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" >
<ImageView
android:id="@+id/item_image"
android:scaleType="centerCrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" >
</ImageView>
<TextView
android:id="@+id/item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_image"
android:layout_centerHorizontal="true"
android:background="#22000000"
android:textSize="12sp"
android:ellipsize="middle"
android:singleLine="true"
android:maxEms="10"
>
</TextView>
<!-- com.realtek.myspeaker.SpeakerTextView
android:id="@+id/item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_image"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever">
</com.realtek.myspeaker.SpeakerTextView-->
</RelativeLayout>

View file

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" >
<ImageView
android:id="@+id/item_image"
android:scaleType="centerCrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" >
</ImageView>
<TextView
android:id="@+id/item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_image"
android:layout_centerHorizontal="true"
android:textSize="16sp"
>
</TextView>
<TextView
android:id="@+id/item_text_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_text"
android:layout_centerHorizontal="true"
android:textSize="14sp"
>
</TextView>
<!-- com.realtek.myspeaker.SpeakerTextView
android:id="@+id/item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_image"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever">
</com.realtek.myspeaker.SpeakerTextView-->
</RelativeLayout>

View file

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_light"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="@android:color/darker_gray"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="1dp"
android:background="@android:color/darker_gray"
android:orientation="horizontal">
<!-- ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical|center"
android:layout_weight="1"
android:src="@drawable/ic_launcher" /-->
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center"
android:layout_weight="3"
android:text="Serial Port Setup" />
</LinearLayout>
<Spinner
android:id="@+id/spinner_baudrate"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<Spinner
android:id="@+id/spinner_data"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<Spinner
android:id="@+id/spinner_parity"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<Spinner
android:id="@+id/spinner_stopbit"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<Spinner
android:id="@+id/spinner_flowcontrol"
android:spinnerMode="dialog"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2"
android:layout_margin="1dp"
android:background="@android:color/darker_gray"
android:orientation="horizontal">
<Button
android:id="@+id/btn_setting_cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Cancel" />"
<Button
android:id="@+id/btn_setting_apply"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Apply" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>

View file

@ -0,0 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>

View file

@ -0,0 +1,8 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw600dp devices (e.g. 7" tablets) here.
-->
</resources>

View file

@ -0,0 +1,9 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
-->
<dimen name="activity_horizontal_margin">128dp</dimen>
</resources>

View file

@ -0,0 +1,11 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View file

@ -0,0 +1,12 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View file

@ -0,0 +1,7 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">UartThrough</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="title_activity_chat">ChatActivity</string>
</resources>

View file

@ -0,0 +1,20 @@
<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="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>

View file

@ -0,0 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<items version="2" >
<item
jar="C:\adt-bundle-windows-x86-20130729\sdk\extras\android\m2repository\com\android\support\support-v4\19.1.0\support-v4-19.1.0.jar"
jumboMode="false"
revision="21.1.2"
sha1="85f201b380937e61a9dce6ca90ccf6872abbfb67">
<dex dex="D:\temp\android\mdis_discovery\UartThrough1\app\build\intermediates\pre-dexed\debug\support-v4-19.1.0-a37612cea2f3e6b561708a6ce1ffb3939925f184.jar" />
</item>
</items>

Some files were not shown because too many files have changed in this diff Show more