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:
@@ -34,8 +34,8 @@ public class AuthFITBIT {
|
|||||||
private static FileDataStoreFactory DATA_STORE_FACTORY;
|
private static FileDataStoreFactory DATA_STORE_FACTORY;
|
||||||
|
|
||||||
/** OAuth 2 scope. */
|
/** 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. */
|
/** Global instance of the HTTP transport. */
|
||||||
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
|
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
|
||||||
|
|
||||||
@@ -63,6 +63,7 @@ public class AuthFITBIT {
|
|||||||
// authorize
|
// authorize
|
||||||
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setHost(
|
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setHost(
|
||||||
OAuth2ClientCredentials.DOMAIN).setPort(OAuth2ClientCredentials.PORT).build();
|
OAuth2ClientCredentials.DOMAIN).setPort(OAuth2ClientCredentials.PORT).build();
|
||||||
|
|
||||||
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user" );
|
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,19 +75,19 @@ public class AuthFITBIT {
|
|||||||
UserData data = request.execute().parseAs(UserData.class);
|
UserData data = request.execute().parseAs(UserData.class);
|
||||||
if (data.list.isEmpty()) {
|
if (data.list.isEmpty()) {
|
||||||
System.out.println("Error in retrieve user data");
|
System.out.println("Error in retrieve user data");
|
||||||
} /*else {
|
} else/* {
|
||||||
if (data.hasMore) {
|
if (data.hasMore) {
|
||||||
System.out.print("First ");
|
System.out.print("First ");
|
||||||
}*/ //i don't think is necessary
|
}*/ //i don't think is necessary
|
||||||
/* System.out.println(data.list.size() + " favorite videos found:");
|
/* System.out.println(data.list.size() + " favorite videos found:");
|
||||||
for (Data datas: data.list) {
|
*/for (FITIBITData datas: data.list) {
|
||||||
System.out.println();
|
System.out.println(datas.toString());/*
|
||||||
System.out.println("-----------------------------------------------");
|
System.out.println("-----------------------------------------------");
|
||||||
System.out.println("ID: " + datas.id);
|
System.out.println("ID: " + datas.id);
|
||||||
System.out.println("Title: " + datas.title);
|
System.out.println("Title: " + datas.title);
|
||||||
System.out.println("Tags: " + datas.tags);
|
System.out.println("Tags: " + datas.tags);
|
||||||
System.out.println("URL: " + datas.url);
|
System.out.println("URL: " + datas.url);
|
||||||
}
|
*/ }/*
|
||||||
}*/ //neither this
|
}*/ //neither this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
21
src/main/java/manage/FITIBITData.java
Normal file
21
src/main/java/manage/FITIBITData.java
Normal 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;
|
||||||
|
}
|
||||||
@@ -3,16 +3,16 @@ package manage;
|
|||||||
public class OAuth2ClientCredentials {
|
public class OAuth2ClientCredentials {
|
||||||
|
|
||||||
/** Value of the "API Key". */
|
/** 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". */
|
/** 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". */
|
/** Port in the "Callback URL". */
|
||||||
public static final int PORT = 8080;
|
public static final int PORT = 8080;
|
||||||
|
|
||||||
/** Domain name in the "Callback URL". */
|
/** 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() {
|
public static void errorIfNotSpecified() {
|
||||||
if (API_KEY.startsWith("Enter ") || API_SECRET.startsWith("Enter ")) {
|
if (API_KEY.startsWith("Enter ") || API_SECRET.startsWith("Enter ")) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.List;
|
|||||||
public class UserData {
|
public class UserData {
|
||||||
|
|
||||||
@Key
|
@Key
|
||||||
public List<Data> list;
|
public List<FITIBITData> list;
|
||||||
/*
|
/*
|
||||||
@Key
|
@Key
|
||||||
public int limit;
|
public int limit;
|
||||||
|
|||||||
@@ -1,38 +1,30 @@
|
|||||||
import device.Hue;
|
import device.Hue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class TestLights {
|
public class TestLights {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
synchronized public void firstTestLights() throws InterruptedException {
|
synchronized public void firstTestLights() throws InterruptedException {
|
||||||
//Hue lights = new Hue("http://localhost/api/newdeveloper/");
|
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);
|
|
||||||
|
|
||||||
for(int i=0; i<10; i++) {
|
for(int i=0; i<10; i++) {
|
||||||
lights.turnOn();
|
lights.turnOn();
|
||||||
this.wait(0b1111101000); // 1000
|
this.wait(0b11001000); // 200
|
||||||
lights.turnOff();
|
lights.turnOff();
|
||||||
this.wait(0b1111101000); // 1000
|
this.wait(0b11001000); // 200
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lights.turnOn();
|
lights.turnOn();
|
||||||
for(int i=0; i<256; i++) {
|
for(int i=0; i<256; i++) {
|
||||||
lights.setBrightness(i);
|
lights.setBrightness(i);
|
||||||
this.wait(2);
|
this.wait(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
lights.colorLoop();
|
for(int i=256; i>=0; i--) {
|
||||||
this.wait(20);
|
lights.setBrightness(i);
|
||||||
lights.turnOff();
|
this.wait(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user