Other Parts Discussed in Thread: CC3200
Hello,
It is possible to create my own Android App that gets data from 3 sensors (light, temeprature, humidity) from CC3200STK-WIFIMK using oryginal software on the board? I'm using Java and Andorid Studio. I tried with socket interface (TCP protocol) and i have connection on port 80, but I have problem with reading data. CC3200STK-WIFIMK needs commands/ flags to start sending data? Can you advise me how should I do it (operation algorithm or something)? There is no source code, API or good documentation so i have no idea how client side should looks like. If it's not possible, pls, write me in the comment bellow. Maybe your answer will help me convince my promoter that such a project is impossible to do for a student.
Best regards.
Kamil
I used this to read data
public boolean isConnected()
{
return connectionSocket != null && connectionSocket.isConnected() && !connectionSocket.isConnected();
}
public class ReceiveRunnable implements Runnable
{
private Socket socket;
private InputStream input;
public ReceiveRunnable(Socket serverSocket)
{
this.socket = serverSocket;
try
{
input = socket.getInputStream();
}
catch (IOException e)
{
e.printStackTrace();
}
}
@Override
public void run()
{
Log.i(TAG, "Receiving started");
while (!Thread.currentThread().isInterrupted() && isConnected())
{
if(!receiveThreadRunning)
receiveThreadRunning = true;
startTime = System.currentTimeMillis();
try
{
int read = 0; int downloaded = 0;
byte[] inputData = new byte[2048];
InputStream bis = new BufferedInputStream(input);
while((read = bis.read(inputData)) != -1)
{
downloaded += read;
}
long time = System.currentTimeMillis() - startTime;
Log.d(TAG, "Data received! Took: " + time + "ms and got: " + (downloaded + 8) + "bytes");
stopThread();
}
catch (Exception e)
{
Log.i(TAG, "error");
e.printStackTrace();
disconect();
}
}
receiveThreadRunning = false;
Log.i(TAG, "Receiving stopped");
}
}
public void startReceiving()
{
receiveRunnable = new ReceiveRunnable(connectionSocket);
receiveThread = new Thread(receiveRunnable);
receiveThread.start();
}