예제 #1
0
// the loop to receive messages
void loop() {
  int previous_cmd_status;
  int shield_status;
  int available_msb;
  int available_lsb;
  int available;
  int read_data;
  int i;
  time_t rawtime;
  struct tm * timeinfo;
  uint8_t data[MAX_STRING];

  available = LoRa_available();

  if (available) 
  {

    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    printf ("\n%s", asctime (timeinfo) );
    printf("Message received, size=%d\n",available);
    delay(1);

    // loop for reading data
    for (i=0; i<available; i++) 
    {
      data[i]=LoRa_read();
    }
    treatMsg(data,available);
  }
  delay(100);
}
예제 #2
0
void* MessageProcessor::run(){
    while(true){
        Message * msg= moduleCom->ttMsgPop();
        treatMsg(msg);
        delete msg;
    }
    return 0;
}
예제 #3
0
// the loop to receive messages
void loop() {
  int previous_cmd_status;
  int shield_status;
  int available_msb;
  int available_lsb;
  int available;
  int read_data;
  int i;
  time_t rawtime;
  struct tm * timeinfo;
  uint8_t data[MAX_STRING];

  digitalWrite(slaveSelectPin,LOW);

  delayMicroseconds(80);

  // data available cmd
  previous_cmd_status = SPI.transfer(0x00);
  delay(1);

  shield_status = SPI.transfer(0x00);
  delay(1);
  available_msb = SPI.transfer(0x00);
  delay(1);

  available_lsb = SPI.transfer(0x00);
  delay(1);

  // take the SS pin high to de-select the chip:
  digitalWrite(slaveSelectPin,HIGH);

  available = (available_msb<<8) + available_lsb;

  if (available) 
  {

    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    printf ("\n%s", asctime (timeinfo) );
    printf("Message received, size=%d\n",available);
    delay(1);

    // loop for reading data
    for (i=0; i<available; i++) 
    {
      digitalWrite(slaveSelectPin,LOW);
      delayMicroseconds(80);
      // read data
      previous_cmd_status = SPI.transfer(0x01);
      delay(1);

      shield_status = SPI.transfer(0x00);
      delay(1);

      read_data = SPI.transfer(0x00);
      delay(1);
      digitalWrite(slaveSelectPin,HIGH);

      delay(1);
           
      data[i]=read_data;
    }
    treatMsg(data,available);
  }
  delay(100);
}