Konuyu Oyla:
  • Toplam: 0 Oy - Ortalama: 0
Share Thread:
[Soru] LoRaWAN Gateway C++ kodu hakkinda
#1
Selamlar, 

Elimde waspmote icin yazilmis bir ornek kod var ve bu kodu raspberry pi icin uyarlamam gerekiyor. Konfigurasyonlar icin ornek kod bulabildim fakat voip loop kisminda hatalar aliyorum.

c++ pek iyi bilmedigim icin oneri ve yonlendirmeler benim icin cok yararli olacak.

waspmote ornek kod

Simdiden tesekkurler. 


void loop() 
{
  //////////////////////////////////////////////
  // 1. Switch on
  //////////////////////////////////////////////

  error = LoRaWAN.ON(socket);

  // Check status
  if( error == 0 ) 
  {
    printf("1. Switch ON OK");     
  }
  else 
  {
    printf("1. Switch ON error = "); 
    printf(error, DEC);
  }

  
  
//////////////////////////////////////////////
  // 2. Join network
  //////////////////////////////////////////////

  error = LoRaWAN.joinOTAA();

  // Check status
  if( error == 0 ) 
  {
    printf("2. Join network OK"); 

  }
  else 
  {
    //2. Join network error
      printf("OTAA error");
  }
  
  
 //////////////////////////////////////////////
    // 3. Send unconfirmed packet 
    //////////////////////////////////////////////

    error = LoRaWAN.sendUnconfirmed( PORT, data);

    // Error messages:
    /*
     * '6' : Module hasn't joined a network
     * '5' : Sending error
     * '4' : Error with data length  
     * '2' : Module didn't response
     * '1' : Module communication error   
     */
    // Check status
    if( error == 0 ) 
    {
      printf("3. Send unconfirmed packet OK");     
      if (LoRaWAN._dataReceived == true)
      { 
        printf("   There's data on port number ");
        printf(LoRaWAN._port,DEC);
        printf(F(".\r\n   Data: ");
        printf(LoRaWAN._data);
      }
    }
    else 
    {
      printf("3. Send unconfirmed packet error = "); 
      printf(error, DEC);
    }    
  }
  else 
  {
    printf("2. Join network error = "); 
    printf(error, DEC);
  }
  
    
 //////////////////////////////////////////////
  // 4. Switch off
  //////////////////////////////////////////////

  error = LoRaWAN.OFF(socket);

  // Check status
  if( error == 0 ) 
  {
    printf("4. Switch OFF OK");     
  }
  else 
  {
    printf("4. Switch OFF error = "); 
    printf(error, DEC);
  }


  USB.println();
  delay(10000);

}



hata :

~/cooking/examples/LoRaWAN $ ./cook.sh Lora_ota.cpparduPi already compiled
arduPiUART already compiled
arduPiUtils already compiled
arduPiMultiprotocol already compiled
arduPiLoRa already compiled
Compiling Example...
Lora_ota.cpp: In function ‘void loop()’:
Lora_ota.cpp:437:24: error: invalid conversion from ‘uint8_t {aka
unsigned char}’ to ‘const char*’ [-fpermissive]
       printf(error, DEC);
                        ^
In file included from /home/pi/cooking/arduPi-api/../arduPi/arduPi.h:30:0,
                 from /home/pi/cooking/arduPi-api/arduPiUART.h:33,
                 from
/home/pi/cooking/libraries/arduPiLoRaWAN/arduPiLoRaWAN.h:33,
                 from Lora_ota.cpp:29:
/usr/include/stdio.h:362:12: note: initializing argument 1 of ‘int
printf(const char*, ...)’
 extern int printf (const char *__restrict __format, ...);
            ^
Lora_ota.cpp: At global scope:
Lora_ota.cpp:440:3: error: expected unqualified-id before ‘else’
   else
   ^
Lora_ota.cpp:451:3: error: ‘error’ does not name a type
   error = LoRaWAN.OFF(sock);
   ^
Lora_ota.cpp:454:3: error: expected unqualified-id before ‘if’
   if( error == 0 )
   ^
Lora_ota.cpp:458:3: error: expected unqualified-id before ‘else’
   else
   ^
Lora_ota.cpp: In function ‘int main(int, char**)’:
Lora_ota.cpp:466:10: error: too few arguments to function ‘int
printf(const char*, ...)’
   printf();
          ^
In file included from /home/pi/cooking/arduPi-api/../arduPi/arduPi.h:30:0,
                 from /home/pi/cooking/arduPi-api/arduPiUART.h:33,
                 from
/home/pi/cooking/libraries/arduPiLoRaWAN/arduPiLoRaWAN.h:33,
                 from Lora_ota.cpp:29:
/usr/include/stdio.h:362:12: note: declared here
 extern int printf (const char *__restrict __format, ...);
            ^
Lora_ota.cpp: In function ‘int main(int, char**)’:
Lora_ota.cpp:468:7: error: redefinition of ‘int main(int, char**)’
   int main(int argc, char *argv[])
       ^
Lora_ota.cpp:464:7: note: ‘int main(int, char**)’ previously defined here
   int main(int argc, char *argv[])
       ^
Lora_ota.cpp: At global scope:
Lora_ota.cpp:475:1: error: expected declaration before ‘}’ token
 }
 ^
Ara
Cevapla


Hızlı Menü:


Konuyu Okuyanlar: 1 Ziyaretçi