Merge branches 'dawit' and 'master' of https://github.com/reti2vc-2018/SeniorAssistant into dawit

# Conflicts:
#	.gradle/4.4/fileHashes/fileHashes.bin
#	.gradle/4.4/fileHashes/fileHashes.lock
#	.idea/gradle.xml
#	.idea/workspace.xml
#	build.gradle
#	src/test/java/TestLights.java

#MaybeThisTimeIsCorrect
This commit is contained in:
2018-06-01 21:33:50 +02:00
7 changed files with 81 additions and 89 deletions

View File

@@ -34,8 +34,8 @@ public class AuthFITBIT {
private static FileDataStoreFactory DATA_STORE_FACTORY;
/** OAuth 2 scope. */
private static final String SCOPE = "read";
private static final String SCOPE = "activity";
//private static final String SCOPE[] = new String[]{"activity","heartrate","location","sleep"};
/** Global instance of the HTTP transport. */
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
@@ -63,7 +63,8 @@ public class AuthFITBIT {
// authorize
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setHost(
OAuth2ClientCredentials.DOMAIN).setPort(OAuth2ClientCredentials.PORT).build();
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user" );
}
private static void run(HttpRequestFactory requestFactory) throws IOException {
@@ -74,19 +75,19 @@ public class AuthFITBIT {
UserData data = request.execute().parseAs(UserData.class);
if (data.list.isEmpty()) {
System.out.println("Error in retrieve user data");
} /*else {
} else/* {
if (data.hasMore) {
System.out.print("First ");
}*/ //i don't think is necessary
/* System.out.println(data.list.size() + " favorite videos found:");
for (Data datas: data.list) {
System.out.println();
*/for (FITIBITData datas: data.list) {
System.out.println(datas.toString());/*
System.out.println("-----------------------------------------------");
System.out.println("ID: " + datas.id);
System.out.println("Title: " + datas.title);
System.out.println("Tags: " + datas.tags);
System.out.println("URL: " + datas.url);
}
*/ }/*
}*/ //neither this
}

View File

@@ -1,22 +0,0 @@
package manage;
import com.google.api.client.util.Key;
import java.util.List;
//da modificare inserendo gli attributi del json (activity, heartrate, sleep, location)
public class Data {
@Key
public String id;
@Key
public List<String> tags;
@Key
public String title;
@Key
public String url;
}

View File

@@ -0,0 +1,21 @@
package manage;
import com.google.api.client.util.Key;
import java.util.List;
public class FITIBITData {
@Key
public String activity;
@Key
public String heartrate;
@Key
public String sleep;
@Key
public String location;
}

View File

@@ -3,16 +3,16 @@ package manage;
public class OAuth2ClientCredentials {
/** Value of the "API Key". */
public static final String API_KEY = "22CSTL";
public static final String API_KEY = "22CSTL"; //maybe togliere le virgolette
/** Value of the "API Secret". */
public static final String API_SECRET = "ea2452013abd35609940ce5601960a08";
public static final String API_SECRET = "ea2452013abd35609940ce5601960a08"; //maybe togliere le virgolette
/** Port in the "Callback URL". */
public static final int PORT = 8080;
/** Domain name in the "Callback URL". */
public static final String DOMAIN = "http://127.0.0.1:8080/";
public static final String DOMAIN = "127.0.0.1";
public static void errorIfNotSpecified() {
if (API_KEY.startsWith("Enter ") || API_SECRET.startsWith("Enter ")) {

View File

@@ -7,7 +7,7 @@ import java.util.List;
public class UserData {
@Key
public List<Data> list;
public List<FITIBITData> list;
/*
@Key
public int limit;

View File

@@ -1,38 +1,30 @@
import device.Hue;
import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
public class TestLights {
@Test
synchronized public void firstTestLights() throws InterruptedException {
//Hue lights = new Hue("http://localhost/api/newdeveloper/");
Hue lights = new Hue();
Set<String> toRemove = new HashSet<>();
for(String str: lights.getNameLights())
if(!str.equals("4"))
toRemove.add(str);
lights.removeLights(toRemove);
Hue lights = new Hue("http://localhost/api/newdeveloper/");
for(int i=0; i<10; i++) {
lights.turnOn();
this.wait(0b1111101000); // 1000
this.wait(0b11001000); // 200
lights.turnOff();
this.wait(0b1111101000); // 1000
this.wait(0b11001000); // 200
}
lights.turnOn();
for(int i=0; i<256; i++) {
lights.setBrightness(i);
this.wait(2);
this.wait(50);
}
for(int i=256; i>=0; i--) {
lights.setBrightness(i);
this.wait(50);
}
lights.colorLoop();
this.wait(20);
lights.turnOff();
}
}