added wifi support for 2.4ghz, very big hack
This commit is contained in:
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '23.0.2'
|
||||
buildToolsVersion '25.0.0'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "de.fhws.indoor.sensorreadout"
|
||||
@@ -23,7 +23,7 @@ dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testCompile 'junit:junit:4.12'
|
||||
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'
|
||||
//provided 'com.google.android.wearable:wearable:1.0.0'
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
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.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
|
||||
@@ -11,7 +11,7 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
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.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
@@ -35,7 +35,7 @@ import de.fhws.indoor.sensorreadout.sensors.mySensor;
|
||||
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 Logger logger = new Logger(this);
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.Debug;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -29,9 +30,8 @@ public class WiFi extends mySensor {
|
||||
this.wifi = (WifiManager) act.getSystemService(Context.WIFI_SERVICE);
|
||||
isReceiverRegistered = true;
|
||||
|
||||
|
||||
this.wifi.setWifiEnabled(false);
|
||||
this.wifi.setWifiEnabled(true);
|
||||
//this.wifi.setWifiEnabled(false);
|
||||
//this.wifi.setWifiEnabled(true);
|
||||
|
||||
if (wifi == null) {
|
||||
throw new MyException("WIFI not supported!");
|
||||
@@ -82,6 +82,21 @@ public class WiFi extends mySensor {
|
||||
isReceiverRegistered = true;
|
||||
wifi.createWifiLock(wifi.WIFI_MODE_SCAN_ONLY, "ipin");
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user