Neurosky MindWave Weird Json output
Posted: 06 Apr 2012, 00:41
Hi,
This is how I am sending the command:
OutputStream outStream;
JSONObject format = new JSONObject();
format.put("enableRawOutput", true);
PrintWriter out = new PrintWriter(outStream, true);
out.println(format.toString());
When trying to read the mindwave data:
BufferedReader stdIn;
String userInput;
while ((userInput = stdIn.readLine()) != null) {
System.out.println(userInput.toString());
the ThinkGear Connector replies by connected from .....
but I don't get {"isAuthorized":true} when I do this:
String appName="Karim";
String appKey="1111111111111111111111111111111111111111";
JSONObject appAuth = new JSONObject();
try {
appAuth.put("appName", appName);
} catch (JSONException e1) {
// Auto-generated catch block
e1.printStackTrace();
}
try {
appAuth.put("appKey", appKey);
} catch (JSONException e1) {
// Auto-generated catch block
e1.printStackTrace();
}
out.println(appAuth.toString());
plus I get this kind of weird output: Í@ø±@_ßá@´§@@4n?µLò?ˆ™™»Å C7M~B@ó®@ÇãD@˘AÚ@ˆ~˙Ay>A,˝Ù@˛r∞™™»Å BeÁ’AÃx°@H©@ÑO@BQ?˝Lò@Ã?∫3ú™™»Å AÄ0æA5W?@8Ü@eŒ>ŒÊ2?Œªô?ú,=@
fij™™»Å Aw≠C@€≈?¢Î@ä”[@«#£@$_?õ•„?zπı™™»Å Aû[ı@€å@;S@
Œ?4◊@)ÓÃ?é´6@.L0™™»Å C:!B+6@ÃˇóABh‹A2aA¬C-AiFt@ëïÅ™™»Å Bu‡\@à¨⁄@øó$A{≥@¢Á@?]Ã?^´6?M<6™™»Å CD«áAñ¡Ú?!è≈A^†êAÜ;@≥x’A⁄∫@∂ÙÒ™™»Å @FÆ}@≤¯8@] \@ı¸@ZV@bär?ø€ı?†bN™™»Å @Å`BA X=çÑM@fö‘@ã¨@3ïÅ@
˘€?ølã™™»Å B⁄ÜA¬ñ@Üø@ÃÈyAZ1Aí£AS≥h@¬ô1™™»Å Aúu@ù;d@[$t@äh‹@àΩ<?Ãõ¶@ ˇ.@_Mj™™»Å C V+A◊ò¸@ u%A(>´@≤OvA5w2A´üAíÌ˙™™»Å AΩ+Aé"?ù@∑∫^@ËãD@@ÜY?æ‚Î?]󈙙»Å Bfi7
I believe this is UTF-8 I tried to decode it to ASCII but it gives nonsense output similar to the one above but in ASCII characters.
I would appreciate any help or help. please let me know if I am doing something wrong
Thanks
This is how I am sending the command:
OutputStream outStream;
JSONObject format = new JSONObject();
format.put("enableRawOutput", true);
PrintWriter out = new PrintWriter(outStream, true);
out.println(format.toString());
When trying to read the mindwave data:
BufferedReader stdIn;
String userInput;
while ((userInput = stdIn.readLine()) != null) {
System.out.println(userInput.toString());
the ThinkGear Connector replies by connected from .....
but I don't get {"isAuthorized":true} when I do this:
String appName="Karim";
String appKey="1111111111111111111111111111111111111111";
JSONObject appAuth = new JSONObject();
try {
appAuth.put("appName", appName);
} catch (JSONException e1) {
// Auto-generated catch block
e1.printStackTrace();
}
try {
appAuth.put("appKey", appKey);
} catch (JSONException e1) {
// Auto-generated catch block
e1.printStackTrace();
}
out.println(appAuth.toString());
plus I get this kind of weird output: Í@ø±@_ßá@´§@@4n?µLò?ˆ™™»Å C7M~B@ó®@ÇãD@˘AÚ@ˆ~˙Ay>A,˝Ù@˛r∞™™»Å BeÁ’AÃx°@H©@ÑO@BQ?˝Lò@Ã?∫3ú™™»Å AÄ0æA5W?@8Ü@eŒ>ŒÊ2?Œªô?ú,=@
fij™™»Å Aw≠C@€≈?¢Î@ä”[@«#£@$_?õ•„?zπı™™»Å Aû[ı@€å@;S@
Œ?4◊@)ÓÃ?é´6@.L0™™»Å C:!B+6@ÃˇóABh‹A2aA¬C-AiFt@ëïÅ™™»Å Bu‡\@à¨⁄@øó$A{≥@¢Á@?]Ã?^´6?M<6™™»Å CD«áAñ¡Ú?!è≈A^†êAÜ;@≥x’A⁄∫@∂ÙÒ™™»Å @FÆ}@≤¯8@] \@ı¸@ZV@bär?ø€ı?†bN™™»Å @Å`BA X=çÑM@fö‘@ã¨@3ïÅ@
˘€?ølã™™»Å B⁄ÜA¬ñ@Üø@ÃÈyAZ1Aí£AS≥h@¬ô1™™»Å Aúu@ù;d@[$t@äh‹@àΩ<?Ãõ¶@ ˇ.@_Mj™™»Å C V+A◊ò¸@ u%A(>´@≤OvA5w2A´üAíÌ˙™™»Å AΩ+Aé"?ù@∑∫^@ËãD@@ÜY?æ‚Î?]󈙙»Å Bfi7
I believe this is UTF-8 I tried to decode it to ASCII but it gives nonsense output similar to the one above but in ASCII characters.
I would appreciate any help or help. please let me know if I am doing something wrong
Thanks