Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT Transport? #21

Open
ccoenen opened this issue May 19, 2018 · 5 comments
Open

MQTT Transport? #21

ccoenen opened this issue May 19, 2018 · 5 comments

Comments

@ccoenen
Copy link

ccoenen commented May 19, 2018

I'm currently working on a project involving an MQTT broker. I am looking into modifying this app, to also send data via mqtt. Do you think it's possibly? From my point of view, it's already doing 95% of all the neccessary things.

I tried understanding the code, and I guess I'd have to (more or less) implement this directory over again, but with mqtt: https://github.com/SensorApps/Sensors2OSC/tree/master/app/src/main/java/org/sensors2/osc/dispatch

What I didn't quite understand, is, where these classes can be found. I didn't find anything with the same name or even the common package.

import org.sensors2.common.dispatch.DataDispatcher;
import org.sensors2.common.dispatch.Measurement;
import org.sensors2.common.nfc.NfcActivity;
import org.sensors2.common.sensors.Parameters;
import org.sensors2.common.sensors.SensorActivity;
import org.sensors2.common.sensors.SensorCommunication;

@residuum
Copy link
Member

residuum commented May 19, 2018

It would be a good idea to use this app as a template for an additional app for MQTT (Maybe Sensors2MQTT?). The idea is basically to use a common package for apps to send sensor data to different receivers, whatever that would be. For now, only OSC and Puredata (Sensors2Pd) are done.

These classes are in a different project and package: https://github.com/SensorApps/Common/tree/master/src/main/java/org/sensors2/common

To include the project as a package in your app, you can add it via jitpack: https://jitpack.io/#SensorApps/Common

@ccoenen
Copy link
Author

ccoenen commented May 20, 2018

Thank you for the pointer! I wouldn't have found it otherwise (well, at least not as fast :-D ).

I have no problem with forking, but in the end the two apps will be virtually identical (perhaps even all three?)

I'll try whipping up a fork. From what I read so far, I believe that everything will be going through the dispatcher in the StartupActivity, right? Touch calls this directly, and SensorCommunication calls this indirectly as well, as far as I can see. So this would be the place to actually forward it to something like an MqttDispatcher and the rest wouldn't even have to change that much, would it?

@ccoenen
Copy link
Author

ccoenen commented May 20, 2018

Thanks to your help I was able to whip up a VERY basic demo in less than two hours :-). It currently can't do very much, and it will only send the first element of a float array, but It connects to a server and sends it successfully!

@ccoenen
Copy link
Author

ccoenen commented May 20, 2018

Here's my (very hackish) MQTT-Fork: https://github.com/ccoenen/Sensors2OSC

With a slight alteration of DataDispatcher, I wouldn't have to touch MultiTouchFragment:

https://github.com/ccoenen/Sensors2OSC/blob/245e41421029772e5360b3ba493f431895867c37/app/src/main/java/org/sensors2/osc/fragments/MultiTouchFragment.java#L36

If DataDispatcher contained addSensorConfiguration, the typecast wouldn't be needed:

OscDispatcher dispatcher = (OscDispatcher) activity.getDispatcher();

@residuum
Copy link
Member

Possibly, yes. Sorry, but I have no time to really have a look at the code at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants