Fixed some thing

* api -> www
* fixed test lights (for some reason it was sent back in time)
This commit is contained in:
2018-06-01 23:10:15 +02:00
parent 9d995e093e
commit 4695b9ddfc
2 changed files with 34 additions and 13 deletions

View File

@@ -24,8 +24,13 @@ import java.util.Arrays;
public class AuthFITBIT {
/** Directory to store user credentials. */
/* Throw a Warning when change permission: they said it's a google bug 'cause is meant to run in linux/unix
*
* https://stackoverflow.com/questions/30634827/warning-unable-to-change-permissions-for-everybody
* https://github.com/google/google-http-java-client/issues/315
*/
private static final java.io.File DATA_STORE_DIR =
new java.io.File(System.getProperty("user.home"), ".store/dailymotion_sample");
new java.io.File(System.getProperty("user.home"), ".store/seniorAssistant");
/**
* Global instance of the {@link DataStoreFactory}. The best practice is to make it a single
@@ -34,17 +39,20 @@ public class AuthFITBIT {
private static FileDataStoreFactory DATA_STORE_FACTORY;
/** OAuth 2 scope. */
private static final String SCOPE = "activity";
//private static final String SCOPE[] = new String[]{"activity","heartrate","location","sleep"};
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();
/** Global instance of the JSON factory. */
static final JsonFactory JSON_FACTORY = new JacksonFactory();
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
/* When i try to accept the request it'll send a 401 Unauthorized
* on internet i found that this message appears when the client put a wrong
* header, client_id or client_secret
* https://dev.fitbit.com/build/reference/web-api/oauth2/ -> ALT+F "401 Unauthorized"
*/
private static final String TOKEN_SERVER_URL = " https://api.fitbit.com/oauth2/token";
private static final String AUTHORIZATION_SERVER_URL =
"https://api.fitbit.com/oauth2/authorize";
private static final String AUTHORIZATION_SERVER_URL = "https://www.fitbit.com/oauth2/authorize";
/** Authorizes the installed application to access user's protected data. */
private static Credential authorize() throws Exception {
@@ -104,10 +112,11 @@ public class AuthFITBIT {
}
});
run(requestFactory);
System.err.print("DONE");
// Success!
return;
} catch (IOException e) {
System.err.println(e.getMessage());
System.err.println(e.getClass().getSimpleName()+" "+e.getMessage());
} catch (Throwable t) {
t.printStackTrace();
}

View File

@@ -1,11 +1,20 @@
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);
for(int i=0; i<10; i++) {
lights.turnOn();
@@ -15,16 +24,19 @@ public class TestLights {
}
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);
}
for(int i=0; i<256; i++) {
lights.setBrightness(i);
this.wait(50);
}
lights.colorLoop();
this.wait(10000); // 10 sec
lights.turnOff();
}
}