Work on FITBIT classes proceeds
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
/** 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 ")) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
public class UserData {
|
||||
|
||||
@Key
|
||||
public List<Data> list;
|
||||
public List<FITIBITData> list;
|
||||
/*
|
||||
@Key
|
||||
public int limit;
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package tests;
|
||||
|
||||
import device.Hue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestLights {
|
||||
|
||||
@Test
|
||||
synchronized public void firstTestLights() throws InterruptedException {
|
||||
Hue lights = new Hue("http://localhost/api/newdeveloper/");
|
||||
|
||||
for(int i=0; i<10; i++) {
|
||||
lights.turnOn();
|
||||
this.wait(0b11001000); // 200
|
||||
lights.turnOff();
|
||||
this.wait(0b11001000); // 200
|
||||
}
|
||||
|
||||
lights.turnOn();
|
||||
for(int i=0; i<256; i++) {
|
||||
lights.setBrightness(i);
|
||||
this.wait(50);
|
||||
}
|
||||
|
||||
for(int i=256; i>=0; i--) {
|
||||
lights.setBrightness(i);
|
||||
this.wait(50);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user