i’m trying to send UDP packet through Argon. but for some reason there are not packets received. However, I tried the same code on Photon hardware and the code working fine.
if you can help me with that. below code for your reference.
UDP Udp;
char myIpAddress[24];
uint8_t server[] = { 192, 168, 23, 12}; // ip address of my phone
IPAddress IPfromBytes( server );
unsigned int localPort = 33334;
int led1 = D7;
int counter=0;
uint32_t timer;
void setup() {
publish("tripStatus") ]
pinMode(led1, OUTPUT);
Particle.variable("ipAddress", myIpAddress, STRING);
IPAddress myIp = WiFi.localIP();
sprintf(myIpAddress, "%d.%d.%d.%d", myIp[0], myIp[1], myIp[2], myIp[3]);
// start the UDP
Udp.begin(localPort);
}
void loop() {
digitalWrite(led1, HIGH);
// We'll leave it on for 1 second...
delay(1000);
// Then we'll turn it off...
digitalWrite(led1, LOW);
// Wait 1 second...
delay(1000);
char ReplyBuffer[] = "acknowledged";
Udp.beginPacket(IPfromBytes, localPort);
sprintf(ReplyBuffer, "%d", counter);
Udp.write(ReplyBuffer);
Udp.endPacket();
counter++;
}
i really appreciate your help. now it’s working. I’m trying to do is to gather variables from Xenon(s) and send it to Argon and then get this values on UDP packet to the laptop. since the BLE central is not published yet. however, Xenon is stop sending the values after some time. this is the code i’m using
On the Xenon, you are publishing rather quick. Do you mean to publish every 100ms? In my testing, the Argon isn’t the most stable and the latency on the mesh network can easily exceed 100ms. So one packet won’t finish sending before you try to transmit the next. You also aren’t incrementing count within your code. Is that intentional?
On the Argon, you call Udp.begin() but are you actually listening for UDP packets? I ask because you never check if there is data available on Udp. You could just leave that begin call out. You also transmit via UDP within your subscribe handler. It is always recommended to just set a flag in the handler function and then process the UDP packet send in the loop. Again, you also delay only 100ms, not a full second as your comments describe… is that intended? Not an issue on the Argon, just doesn’t match the comments.
@Areezo, the mesh itself communicates at 250Kbps so “as fast as I can” is most likely not doable on Mesh. If you need real-time streaming data, a Photon may be better. Or rethink how you collect and send data. Does it need to be streamed or can it be collected, treated (avg, etc) and then sent on?
Thanks for the information. I was trying to gather the sensors data in realtime through the bluetooth using Xenon to the phone (iOS, android). but since the BLE is not publish yet i’m went this way just for testing.
So would it be possible to send data in realtime using Xenon on BLE when it’s published?
What is “real time” for this sensor? How fast does the collection and publish need to happen? Does BLE even have the bandwidth you desire if it was available on the mesh devices right now?
Perhaps you want to describe what you are trying to do in more detail for better ideas.
@ninjatill What I would like to do is each Xenon is connected to one ultrasonic sensor. each Xenon should calculate the distance and send the distance back to phone in about realtime. Basically it’s not a lot of data but the the transfer speed is more important to be represented on the phone. most of the processing will be done on phone. what I need is to send is like 3 values (node name, distance, …) between the Xenon and phone.