Closed bartkiers closed 11 years ago
This is curious. If data is being sent, that means the list of sensors should be known and getting sensor data should also be possible. I cannot pinpoint exactly where the problem exists.
However, I see that you are calling the SenseApi class directly, which I would not recommend in this case. The SenseApi.registerUser() call only registers a new user at CommonSense, but it does not alter the state of the app. That means that the session ID stays intact, and the list of sensor ID is also still linked the old user. So actually I am amazed that data is being sent to the newly registered account at all.
What happens when you replace the SenseApi.registerUser call with a call to a SensePlatform instance? See this example in the sense-android-demo project (replace 'login' with 'register').
@Smuldr
However, I see that you are calling the SenseApi class directly, which I would not recommend in this case.
Perhaps this registerUser(Context, String, String, String, String, String, String)
should be made (package) protected in that case?
The SenseApi.registerUser() call only registers a new user at CommonSense, but it does not alter the state of the app.
When looking at the API docs of that method:
/**
* Tries to register a new user at CommonSense. Discards private data of any previous users.
* ...
*/
it looks to me that it does alter the state. Or did I misinterpret the part "Discards private data of any previous users." incorrectly?
What happens when you replace the SenseApi.registerUser call with a call to a SensePlatform instance?
I did something similar: I checked out the release-2.7.0
branch, replaced:
// line 126 of LoginActivity.java
application.getSensePlatform().login(mEmail, SenseApi.hashPassword(mPassword), callback);
with:
application.getSensePlatform().registerUser(mEmail, SenseApi.hashPassword(mPassword), mEmail, "", "", "", "", "", "", callback);
and the registered the new user. Of course, the spinner will keep on spinning because I didn't do anything in onRegisterResult
, but the user will obviously be created. With this newly created user, I could log into common-sense (so, that works). I then Launched the demo app and logged in with the same account and started sensing. Going back to common-sense I could see the data was sent from the phone to Sense. However, on the logcat I see the following:
...
05-16 10:14:05.272: ERROR/SenseApi(29247): Failed to get URL for sensor 'position': sensor ID is not available
05-16 10:14:05.747: DEBUG/SenseApi(29247): Created sensor: 'light' for device: 'GT-N7000'
05-16 10:14:06.307: DEBUG/SenseApi(29247): Created sensor: 'noise_sensor' for device: 'GT-N7000'
05-16 10:14:06.407: ERROR/SenseApi(29247): Failed to get URL for sensor 'traveled distance 1h': sensor ID is not available
05-16 10:14:06.937: DEBUG/SenseApi(29247): Created sensor: 'noise_sensor' for device: 'GT-N7000'
05-16 10:14:07.132: DEBUG/com.askcs.asksensedemo.task.PollSenseTask(29247): ticking every 10 seconds
05-16 10:14:07.132: DEBUG/com.askcs.asksensedemo.database.DatabaseHelper(29247): retrieving dao: Dao<class com.askcs.asksensedemo.model.Setting, class java.lang.String>
05-16 10:14:07.627: INFO/Sense Motion(29247): Acquire wake lock for 500ms
05-16 10:14:07.702: DEBUG/SenseApi(29247): Created sensor: 'audio_spectrum' for device: 'GT-N7000'
05-16 10:14:08.342: DEBUG/SenseApi(29247): Created sensor: 'pressure' for device: 'GT-N7000'
05-16 10:14:08.607: ERROR/SenseApi(29247): Failed to get URL for sensor 'proximity': sensor ID is not available
05-16 10:14:09.042: DEBUG/SenseApi(29247): Created sensor: 'magnetic field' for device: 'GT-N7000'
05-16 10:14:09.582: DEBUG/SenseApi(29247): Created sensor: 'loudness' for device: 'GT-N7000'
05-16 10:14:10.017: ERROR/SenseApi(29247): Failed to get URL for sensor 'gyroscope': sensor ID is not available
...
and no data is retrieved from Sense (to the phone).
First: you are right about the confusing documentation. This is bad, and we should remove the offending doc. The SenseApi class is meant as an easy way to call the CommonSense API, so anything that suggest otherwise is incorrect.
Second: I think I don't quite undestand what you did to register a new user. Where did you replace login...
with register...
?
Third: I am afraid the error logs that you posted are another case of misinformation. When you log in, it can take some time to create and prepare all the different sensors for your phone. If you try to send or get data before the sensor is registered, you will get an error message as shown above. The transmission of data will be retried later. So we should probably use a less scary message in the logs.
@Smuldr
Okay, I'll register, log in and wait for a couple of minutes to see if data can be retrieved from Sense.
I'll get back to you on this.
@Smuldr
Okay, a quick update: both these method calls:
application.getSensePlatform().registerUser( ... )
and the (not to be used from now on!) static call:
SenseApi.registerUser( ... )
results in the same (observed) behavior:
service.getSensePlatform().getData( ... )
In both cases I've let the newly registered user stay logged in for at least 15 minutes (ample time for the sensors to be registered I recon).
However, when I registered a new user through the Sense website and log in with that user in the mobile app, I successfully get data from Sense after a few minutes! Yay!
Perhaps you can investigate a bit where things go differently between the API calls and the website?
Cool, this works now (even through the illegal SenseApi.registerUser( ... )
:))
I'll close this now.
Thanks!
When registering an account through the Sense-library (via the Demo App) like this:
(source)
I cannot fetch any data from the Sense back end. I see the following being printed on the log-cat:
The data is being received by Sense (I can see it when logging into common.sense-os.nl).
The exception is not thrown when using my existing account (bkiers@ask-cs.com).