You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@edgent.apache.org by Arun KN <re...@gmail.com> on 2019/04/05 02:53:30 UTC
Apache EDGENT on Android issue
Hi Sir,
I am hobby developer and have experience in IoT and embedded product, i
got to know Edgent SDK while one of the search, i was very much impressed
with the feature...meanwhile i tried to develop a small app on Android App
to get sensor data from Android phone...am able to clear all errors related
to dependency on Android studio and generate APK , install and run app on
Mobile phone ...here in code(pasted below) am trying to print sensor data
in TextView of App, once i run app am getting output on TextView is
"ConnectStream alias=null tags=[] " ...i am expecting sensor data of
Acceleration,but am getting above mentioned output,
Please help me in resolving this issue ...why am getting "ConnectStream
alias=null tags=[] " .....provide me solution to get proper data from
sensor.so that i can go further in my exploring EDGENT.
my Android App code is below :
package com.example.temperaturesensor;
import android.support.v7.app.AppCompatActivity;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import org.apache.edgent.providers.direct.DirectProvider;
import org.apache.edgent.topology.TStream;
import org.apache.edgent.topology.Topology;
import java.util.concurrent.TimeUnit;
public class MainActivity extends AppCompatActivity {
/* private val findViewById; */
private static final String TAG = "EdgeNT Sample App";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView resultsTextView = (TextView)
findViewById(R.id.resultsTextView);
TempSensor sensor = new TempSensor(getApplicationContext());
DirectProvider provider = new DirectProvider();
Topology t = provider.newTopology("EdgentSampleApp");
Log.d("Sensor Data",":Pritnt Sensor Data "+sensor.toString());
TStream<Double> tempReadings = t.poll(sensor,1, TimeUnit.SECONDS);
TStream<Double> filterReadings = tempReadings.filter(reading->
reading < 10 || reading > 20);
Log.i("Sensor Sample", "Printing temperature values:
"+filterReadings.print());
// resultsTextView.setText(filterReadings.asString().toString());
resultsTextView.setText(filterReadings.asString().toString());
filterReadings.print();
provider.submit(t);
}
}
Awaiting for your response.
Thanks & Regards,
Arun Kumar N
Re: Apache EDGENT on Android issue
Posted by Christofer Dutz <ch...@c-ware.de>.
Hi Arun,
I guess your problem is that you are printing out the stream element and not the content of the stream.
As the API documentation states, asString converts an object stream to a stream of strings.
I guess you should use this instead:
filterReadings.map(value ->
resultsTextView.setText(value.toString());
Hope that helps.
Chris.
Am 05.04.19, 07:14 schrieb "Arun KN" <re...@gmail.com>:
Hi Sir,
I am hobby developer and have experience in IoT and embedded product, i
got to know Edgent SDK while one of the search, i was very much impressed
with the feature...meanwhile i tried to develop a small app on Android App
to get sensor data from Android phone...am able to clear all errors related
to dependency on Android studio and generate APK , install and run app on
Mobile phone ...here in code(pasted below) am trying to print sensor data
in TextView of App, once i run app am getting output on TextView is
"ConnectStream alias=null tags=[] " ...i am expecting sensor data of
Acceleration,but am getting above mentioned output,
Please help me in resolving this issue ...why am getting "ConnectStream
alias=null tags=[] " .....provide me solution to get proper data from
sensor.so that i can go further in my exploring EDGENT.
my Android App code is below :
package com.example.temperaturesensor;
import android.support.v7.app.AppCompatActivity;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import org.apache.edgent.providers.direct.DirectProvider;
import org.apache.edgent.topology.TStream;
import org.apache.edgent.topology.Topology;
import java.util.concurrent.TimeUnit;
public class MainActivity extends AppCompatActivity {
/* private val findViewById; */
private static final String TAG = "EdgeNT Sample App";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView resultsTextView = (TextView)
findViewById(R.id.resultsTextView);
TempSensor sensor = new TempSensor(getApplicationContext());
DirectProvider provider = new DirectProvider();
Topology t = provider.newTopology("EdgentSampleApp");
Log.d("Sensor Data",":Pritnt Sensor Data "+sensor.toString());
TStream<Double> tempReadings = t.poll(sensor,1, TimeUnit.SECONDS);
TStream<Double> filterReadings = tempReadings.filter(reading->
reading < 10 || reading > 20);
Log.i("Sensor Sample", "Printing temperature values:
"+filterReadings.print());
// resultsTextView.setText(filterReadings.asString().toString());
resultsTextView.setText(filterReadings.asString().toString());
filterReadings.print();
provider.submit(t);
}
}
Awaiting for your response.
Thanks & Regards,
Arun Kumar N