Hi, i am doing a project which needs my device to transmit the measured data (from the force sensors) wireless to an android phone. Can spark core do the WIFI direct P2P communication with an android phone? Say can i write my own app for the phone to let the core to transmit data measured from force sensors to the phone. Because i read that WIFI P2P only allows Android 4.0 (API level 14) or higher hardware to communicate. If i cannot use WIFI P2P, then how can implement the wifi transmission from Core to my android phone. I mean under myself written app, is it possible? Thanks in advance for your help!
Seems like no one has tackled this question yet so i'll take a stab.
I believe this is a no.
You will need come kind of TCP or UDP server running on the core which will then transmit when a client connects or use the Spark.variable
via the Spark Cloud.
Are you saying that I use Core as a TCP server and my phone as a client and put them in a same network to communicatet?
Yes. That’s gonna be possible
You can place the core in manual mode which turns off connection to the cloud. (But you will need to download firmware via USB)
The Spark core needs to talk to an WiFi access point, so if you phone can be a hotspot access point for other devices you are fine.
Then as @kennethlimcp says you get to choose between internet Spark Cloud or local TCP/UDP.
My phone can be a Wifi hotspot but as i know to be the hotspot, the Wifi function on the phone will be turned off so how can the phone talk to Core?
Sorry for so many questions, i am really new for this wireless communication.
Try this. I use this method to detect a remote device on a network where the IP is given via DHCP to both end devices.
Setup the core to listen for a UDP broadcast on a port of your choice.
On your Android device, setup a listening socket on a port of your choice and then send out a UDP broadcast on the port that the core is listening on. The core will detect this UDP and get the IP address of your phone. The core can now open a connection to your phone and you can now send and receive data over this socket connection.
This will work on your network even when both devices get a DHCP assigned IP address. Note that this will only work within your internal network.
Hi, what if i want to use TCP to realize the communication between these two? Am i supposed to know the ip address of my Core first?
If you don’t like the USB update, you can add a function that monitors the mode button to re-connect to the cloud when it’s pressed. The required code is mentioned in some other post and you should be able to find it using the search function.
Yes. That is why I suggested the UDP idea as you can use this to broadcast a message that all devices on the network will see and the core recognises the contents of this UDP message and then responds to the IP address it detects with a TCP/IP connection.
As I said, I use this on an Android device to detect a PC running the logging software. The Android device sends out a UDP packet with a unique message. The PC is listening on a port for UDP and once it gets this, it replies back with a message and then the Android device now knows the IP address of the remote PC. You can consider your Spark Core as the remote PC.