Pages: [1]   Go Down
Author Topic: VIRTUALWIRE SERVER & CLIENT SYNCRONIZATION HELP  (Read 502 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

GOOD AFTERNOON, I'D LIKE TO DO THIS:

SCENARIO: SERVER AND ONE OR MORE CLIENT CONNECTED USE VIRTUAL WIRE

SCOPE: SYNCRONIZE TRASMISSION AND RECEPTION BETWEEN SERVER & CLIENT/S

SO, DUE THE FACT SEND OUT A CHAR FOR EXAPLE "A" THEN THE CLIENT THAT IS LISTENING MODE RECEIVED "A" IF THE MESSAGE IS FOR THE CLIENT REPLY "CLIENT A OK" TURN CLIENT A LED

THE FOR THE FIRST PART CHECK IF THE MESSAGE IS FOR THE CLIENT AND THEN SEND OUT ANSWER IS SIMPLY ... BUT THE SERVER SEEMS DOESN'T RECEIVED NOTHING,
IS THERE SOMEONE THAT USE VIRTUAL WIRE IN BOTH RECEPTION AND TRASMISSION MODE WITHOUT ISSUES ?

THANSK
ANDREA
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50064
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You mind not screaming any more? My ears can't take it.

You have some code that apparently doesn't do what you expect it to. Yet, you didn't post the code.

What is providing the virtual connection between the two (or more) Arduinos? Perhaps the server and client(s) are not communicating at all.
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so, you have reason I will push the code also, the problem is not push the code,
just when i'll go back to home i will send it ... 
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

here you are the code for trasmitt, so at home I've send out the data "a" using a key pad but is the same the logical:

Code:
#include <VirtualWire.h>

void setup()
{
    Serial.begin(9600);   // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR

    vw_setup(1200); // Bits per sec
    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
   
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
   
    const char *msg = "a";
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
   
      // Wait at most 200ms for a reply
                if (vw_wait_rx_max(200))
                  {
                  if (vw_get_message(buf, &buflen)) // Non-blocking
                        {
                            int i;
               
                              // Message with a good checksum received, dump it.
                               Serial.print("Got: ");
               
                          for (i = 0; i < buflen; i++)
                              {
                        Serial.print(buf[i], HEX);
                        Serial.print(" ");
                                }
                            Serial.println("");
                          }
                      }
                else
            Serial.println("Timout");
           
}

and here the code of the receiver without check if the char if the char "a" is for the client but it is the same ... just for semplify to you ... is there sometiming to wait for syncronize both ?
Code:
#include <VirtualWire.h>

void setup()
{
    Serial.begin(9600); // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
   
    vw_setup(12000); // Bits per sec

    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
int i;

        digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");

for (i = 0; i < buflen; i++)
{
    Serial.print(buf[i], HEX);
    Serial.print(" ");
}
Serial.println("");
        digitalWrite(13, false);
    }
 
   
    const char *msg = "Client 1 arrived";
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
   
}

Thanks Andrea
Logged

Pages: [1]   Go Up
Jump to: