Skip to content

Commit

Permalink
Checkpoint for app v2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
scaryghost committed Feb 14, 2015
1 parent ff7b33c commit 70152b4
Show file tree
Hide file tree
Showing 14 changed files with 584 additions and 31 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mbientlab.metawear.app"
android:versionCode="6"
android:versionName="2.4" >
android:versionCode="7"
android:versionName="2.5" >

<uses-sdk
android:minSdkVersion="18"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# MetaWear Android App #

## Version ##
2.5

## About ##
This app provides an example of how to use the MetaWear API. It uses the sample BluetoothLeGatt app on the Android developer page and the Nordic nRF Toolbox app as references.

[http://developer.android.com/samples/BluetoothLeGatt/index.html](http://developer.android.com/samples/BluetoothLeGatt/index.html)
[https://play.google.com/store/apps/details?id=no.nordicsemi.android.nrftoolbox&hl=en](https://play.google.com/store/apps/details?id=no.nordicsemi.android.nrftoolbox&hl=en)

### Version ###
Current version is: 2.4

### Build ###
## Build ##
The API was created with Android Developer Tools v22.6.2-1085508. It is targeted for Android 4.4.2 (API 19) SDK with Android 4.3 (API 18) as the minimum required SDK and requires a JDK compiler compliance level of 1.7. To build the project, you will need to download the MetaWear API and configure the example app to include the API in the build path. More information on configuring the build is available in the "Getting Started" guide, available on the MbientLab website: [https://mbientlab.com/docs/](https://mbientlab.com/docs/).

By default, the app is configured to refer to the MetaWear API Eclipse project. You may change it to link to the jar instead if you do not plan on modifying the API code.
10 changes: 9 additions & 1 deletion res/layout/activity_feature_dfu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,18 @@
android:text="@string/dfu_action_select_file" />

<Button
android:id="@+id/action_update_latest"
android:id="@+id/action_choose_version"
android:layout_below="@+id/action_select_file"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onChooseVersionClicked"
android:text="@string/dfu_action_choose_version" />

<Button
android:id="@+id/action_update_latest"
android:layout_below="@+id/action_choose_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onUpdateLatestClicked"
android:text="@string/dfu_action_update_latest" />

Expand Down
2 changes: 1 addition & 1 deletion res/layout/fragment_device_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY
DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact MbientLab Inc, at www.mbientlab.com.
contact MbientLab Inc, at www.mbientlab.com.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
Expand Down
7 changes: 7 additions & 0 deletions res/layout/fragment_firmware_selector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/firmware_version_list"
android:layout_width="match_parent"
android:layout_height="match_parent" >

</ListView>
162 changes: 162 additions & 0 deletions res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014 MbientLab Inc. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user who
downloaded the software, his/her employer (which must be your employer) and
MbientLab Inc, (the "License"). You may not use this Software unless you
agree to abide by the terms of the License which can be found at
www.mbientlab.com/terms . The License limits your use, and you acknowledge,
that the Software may not be modified, copied or distributed and can be used
solely and exclusively in conjunction with a MbientLab Inc, product. Other
than for the foregoing purpose, you may not use, reproduce, copy, prepare
derivative works of, modify, distribute, perform, display or sell this
Software and/or its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
MBIENTLAB OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE,
STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE
THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED
TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST
PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY,
SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY
DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact MbientLab Inc, at www.mbientlab.com.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/accelerometer_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp" >

<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:labelFor="@+id/editText1"
android:text="@string/label_settings_device_name" />

<EditText
android:id="@+id/editText1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:hint="@string/label_settings_device_name_hint"
android:inputType="text" >

</EditText>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2" >

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:labelFor="@+id/editText2"
android:text="@string/label_settings_advertising_interval" />

<EditText
android:id="@+id/editText2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:hint="@string/label_settings_advertising_interval_hint"
android:inputType="number" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2" >

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:labelFor="@+id/editText4"
android:text="@string/label_settings_advertising_timeout" />

<EditText
android:id="@+id/editText4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:ems="10"
android:hint="@string/label_settings_advertising_timeout_hint"
android:inputType="number" >

</EditText>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2" >

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:labelFor="@+id/editText3"
android:text="@string/label_settings_tx_power" />

<EditText
android:id="@+id/editText3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:hint="@string/label_settings_tx_power_hint"
android:inputType="numberSigned" />

</LinearLayout>

<LinearLayout
android:id="@+id/LinearLayout1"
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >

<Button
android:id="@+id/button1"
style="@style/MetaWear.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_set" />

<Button
android:id="@+id/button2"
style="@style/MetaWear.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_clear" />
</LinearLayout>
</LinearLayout>

</ScrollView>
2 changes: 1 addition & 1 deletion res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin_top">16dp</dimen>
<dimen name="activity_vertical_margin_bottom">32dp</dimen>
<dimen name="activity_vertical_margin_bottom">24dp</dimen>
<dimen name="feature_horizontal_margin">50dp</dimen>
<dimen name="feature_vertical_margin_top">50dp</dimen>
<dimen name="feature_section_padding">8dp</dimen>
Expand Down
10 changes: 10 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ contact MbientLab Inc, at www.mbientlab.com.
<string name="label_gpio_digital_output">Digital Output</string>
<string name="label_gpio_read">Read</string>
<string name="label_gpio_value">Value</string>

<string name="label_settings_device_name">Device Name</string>
<string name="label_settings_device_name_hint">8 ASCII Chars</string>
<string name="label_settings_advertising_interval">Advertising Interval</string>
<string name="label_settings_advertising_interval_hint">[0, 65535] ms</string>
<string name="label_settings_advertising_timeout">Advertising Timeout</string>
<string name="label_settings_advertising_timeout_hint">[0, 180] s</string>
<string name="label_settings_tx_power">TX Power</string>
<string name="label_settings_tx_power_hint">4, 0, -4, -8, -12, -16, -20, -30</string>

<string name="error_thermistor_pins">Enter valid numbers for the analog and pulldown GPIO pins</string>
<string name="error_connect_board">Connect to a board before using the app\'s features</string>
</resources>
1 change: 1 addition & 0 deletions res/values/strings_dfu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<string name="dfu_file_status_invalid_message">Please, select valid HEX file</string>

<string name="dfu_action_update_latest">USE LATEST</string>
<string name="dfu_action_choose_version">CHOOSE VER</string>
<string name="dfu_action_select_file">SELECT FILE</string>

<string name="dfu_alert_no_filebrowser_title">File Browser not found</string>
Expand Down
1 change: 1 addition & 0 deletions src/com/mbientlab/metawear/app/AppFragments.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class AppFragments {
fragments.put("Neo Pixel", NeoPixelFragment.class);
fragments.put("Temperature", TemperatureFragment.class);
fragments.put("Event", EventFragment.class);
fragments.put("Settings", SettingsFragment.class);

items= fragments.keySet().toArray(new String[fragments.size()]);
}
Expand Down
24 changes: 8 additions & 16 deletions src/com/mbientlab/metawear/app/DeviceInfoFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
Expand Down Expand Up @@ -87,6 +86,14 @@ public void receivedRemoteRSSI(int rssi) {
((TextView) getView().findViewById(R.id.remote_rssi)).setText(String.format(Locale.US, "%d ", rssi));
}
}

@Override
public void disconnected() {
for(Entry<GATTCharacteristic, Integer> it: views.entrySet()) {
values.remove(it.getKey());
((TextView) getView().findViewById(it.getValue())).setText("");
}
}
};
private ModuleCallbacks mCallback= new MechanicalSwitch.Callbacks() {
@Override
Expand Down Expand Up @@ -117,7 +124,6 @@ public void released() {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
setHasOptionsMenu(true);
return inflater.inflate(R.layout.fragment_device_info, container, false);
}

Expand Down Expand Up @@ -195,18 +201,4 @@ public void controllerReady(MetaWearController mwController) {
switchController.enableNotification();
}
}

@Override
public boolean onOptionsItemSelected (MenuItem item) {
switch (item.getItemId()) {
case R.id.ble_disconnect:
for(Entry<GATTCharacteristic, Integer> it: views.entrySet()) {
values.remove(it.getKey());
((TextView) getView().findViewById(it.getValue())).setText("");
}
break;
}

return super.onOptionsItemSelected(item);
}
}
Loading

0 comments on commit 70152b4

Please sign in to comment.