added wifi support for 2.4ghz, very big hack

This commit is contained in:
toni
2017-10-10 16:04:00 +02:00
parent dad881e2b0
commit 53dc3f5fed
8 changed files with 27 additions and 20 deletions

7
.idea/gradle.xml generated
View File

@@ -12,12 +12,7 @@
<option value="$PROJECT_DIR$/app" /> <option value="$PROJECT_DIR$/app" />
</set> </set>
</option> </option>
<option name="myModules"> <option name="resolveModulePerSourceSet" value="false" />
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>

2
.idea/misc.xml generated
View File

@@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" /> <ConfirmationsSetting value="0" id="Remove" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion '23.0.2' buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
applicationId "de.fhws.indoor.sensorreadout" applicationId "de.fhws.indoor.sensorreadout"
@@ -23,7 +23,7 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.support:wearable:1.3.0' //compile 'com.google.android.support:wearable:1.3.0'
//compile 'com.google.android.gms:play-services-wearable:8.4.0' //compile 'com.google.android.gms:play-services-wearable:8.4.0'
//provided 'com.google.android.wearable:wearable:1.0.0' //provided 'com.google.android.wearable:wearable:1.0.0'
} }

View File

@@ -3,9 +3,6 @@
package="de.fhws.indoor.sensorreadout">> package="de.fhws.indoor.sensorreadout">>
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />

View File

@@ -11,7 +11,7 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.content.pm.ActivityInfoCompat; import android.support.v4.content.pm.ActivityInfoCompat;
import android.support.wearable.activity.WearableActivity; //import android.support.wearable.activity.WearableActivity;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@@ -35,7 +35,7 @@ import de.fhws.indoor.sensorreadout.sensors.mySensor;
import de.fhws.indoor.sensorreadout.sensors.SensorType; import de.fhws.indoor.sensorreadout.sensors.SensorType;
public class MainActivity extends WearableActivity { public class MainActivity extends Activity {
private final ArrayList<mySensor> sensors = new ArrayList<mySensor>(); private final ArrayList<mySensor> sensors = new ArrayList<mySensor>();
private final Logger logger = new Logger(this); private final Logger logger = new Logger(this);

View File

@@ -10,6 +10,7 @@ import android.net.wifi.WifiManager;
import android.os.Debug; import android.os.Debug;
import android.util.Log; import android.util.Log;
import java.lang.reflect.Method;
import java.util.List; import java.util.List;
@@ -29,9 +30,8 @@ public class WiFi extends mySensor {
this.wifi = (WifiManager) act.getSystemService(Context.WIFI_SERVICE); this.wifi = (WifiManager) act.getSystemService(Context.WIFI_SERVICE);
isReceiverRegistered = true; isReceiverRegistered = true;
//this.wifi.setWifiEnabled(false);
this.wifi.setWifiEnabled(false); //this.wifi.setWifiEnabled(true);
this.wifi.setWifiEnabled(true);
if (wifi == null) { if (wifi == null) {
throw new MyException("WIFI not supported!"); throw new MyException("WIFI not supported!");
@@ -82,6 +82,21 @@ public class WiFi extends mySensor {
isReceiverRegistered = true; isReceiverRegistered = true;
wifi.createWifiLock(wifi.WIFI_MODE_SCAN_ONLY, "ipin"); wifi.createWifiLock(wifi.WIFI_MODE_SCAN_ONLY, "ipin");
//wifi.disconnect(); //wifi.disconnect();
//this is a very nice hack. do not try this at home.
Method m = null;
try {
m = this.wifi.getClass().getDeclaredMethod("setFrequencyBand", int.class, boolean.class);
m.setAccessible(true);
m.invoke(this.wifi, 2, true);
m.invoke(this.wifi, 2, true);
m.invoke(this.wifi, 2, true);
Log.d("ok", "ok");
} catch (Exception e) {
e.printStackTrace();
}
startScan(); startScan();
} }

View File

@@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha2' classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

View File

@@ -1,6 +1,6 @@
#Thu Jun 02 19:04:18 CEST 2016 #Tue Oct 10 15:36:44 CEST 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip