Gateway nodes not showing - gateway.db not logging [solved]

Started by EnMon, January 23, 2017, 07:02:59 PM

EnMon

Hi Guys,

Thanks for the help in advance.

I am using Moteino gateway app, with NeDB 1.8.0, I see data getting logged by logUtil.js, but I don't see the same being saved in gateway.db, does it have something to do with NeDB version, I have no clue as to why the nodes are not showing up on the gateway app.

If possible can you please share a sample gateway.db file, so that I make sure there is no other configuration or code issue, other than NeDB setup.


Felix

How did you install the Gateway app?
Does it have disk permissions to write to that file?

The gateway.db file only logs the node information, the graph data goes in binary files.

EnMon

Hello Felix,
Thanks for your ever ready help!
I understand the gateway.db logs the node information but the gateway app is not showing any nodes.
I followed the steps you posted in the gateway app guide.
I'm using a moteinoUSB and I changed the settings to ttyUSB0. I believe I followed through all the steps you mentioned.
I'm able to the information from the nodes via Minicom and also in the log file but the nodes are not coming up on the app.
I'm willing to give you access to my system via "Team Viewer" if you don't mind. That might help you understand what's going on exactly.


EnMon

I'm not sure I understand how to give it disk permission to write to the file? Is there some settings I'm missing out?

sparky

If you right click on that file there will be check box's for the permissions.  Did you verify that it is ttyUSB0?

EnMon

This is what I currently have as permission, however, I'm unable to change any permissions on the gateway.db file.

Felix

You will need to root ssh into your Pi to make any changes, cant do that from windows explorer  ;)
I suggest you revisit the install guide for a fresh install.

sparky

Although I didn't say, I primarily was showing him how to check the permissions.  I used WinSCP which apparently he didn't.

Felix

Sorry sparky - I completely missed that  ::)

EnMon - which sketch do you use on the MoteinoUSB?
Is it configured as /dev/ttyUSB0 in settings? Does it run at 19200 baud?

EnMon

Thanks for the help thus far,
@ Felix So I am trying a new install but basically, I am using the Pigateway code attached. I also changed the settings to tty/USB0 which enabled me view the received data via minicom. The only challenge was the database.db was not updating node information, hence the app is showing count 0 for nodes.
@sparky: I used the WinSCP to check for the permissions like you suggested but I couldn't make changes.

I'll give an update as soon as I'm done with the installation. (I actually decided to format the SD card and install NOOBs afresh.)
#define NODEID          1 //the ID of this node
#define NETWORKID     200 //the network ID of all nodes this node listens/talks to
#define FREQUENCY     RF69_915MHZ //Match this with the version of your Moteino! (others: RF69_433MHZ, RF69_868MHZ)
#define ENCRYPTKEY    "sampleEncryptKey" //identical 16 characters/bytes on all nodes, not more not less!
#define IS_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
#define ACK_TIME       30  // # of ms to wait for an ack packet
//*****************************************************************************************************************************
#define ENABLE_ATC    //comment out this line to disable AUTO TRANSMISSION CONTROL
#define ATC_RSSI      -90  //target RSSI for RFM69_ATC (recommended > -80)
//*****************************************************************************************************************************
// Serial baud rate must match your Pi/host computer serial port baud rate!
#define SERIAL_EN     //comment out if you don't want any serial verbose output
#define SERIAL_BAUD  19200
//*****************************************************************************************************************************

#ifdef __AVR_ATmega1284P__
  #define LED           15 // Moteino MEGAs have LEDs on D15
  #define FLASH_SS      23 // and FLASH SS on D23
#else
  #define LED           9 // Moteinos have LEDs on D9
  #define FLASH_SS      8 // and FLASH SS on D8
#endif

#ifdef SERIAL_EN
  #define DEBUG(input)   {Serial.print(input); delay(1);}
  #define DEBUGln(input) {Serial.println(input); delay(1);}
#else
  #define DEBUG(input);
  #define DEBUGln(input);
#endif

#ifdef ENABLE_ATC
  RFM69_ATC radio;
#else
  RFM69 radio;
#endif

SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for 4mbit Windbond FlashMEM chip

void setup() {
  Serial.begin(SERIAL_BAUD);
  delay(10);
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
  //radio.setHighPower(); //uncomment only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  
#ifdef ENABLE_ATC
  radio.enableAutoPower(ATC_RSSI);
#endif
  
  char buff[50];
  sprintf(buff, "\nListening at %d Mhz...", radio.getFrequency()/1000000);
  DEBUGln(buff);

  if (flash.initialize())
  {
    DEBUGln("SPI Flash Init OK!");
  }
  else
  {
    DEBUGln("SPI FlashMEM not found (is chip onboard?)");
  }
}

byte ackCount=0;
byte inputLen=0;
char input[64];
byte buff[61];
String inputstr;

void loop() {
  inputLen = readSerialLine(input);
  inputstr = String(input);
  inputstr.toUpperCase();
  
  if (inputLen > 0)
  {
    if (inputstr.equals("KEY?"))
    {
      DEBUG("ENCRYPTKEY:");
      DEBUG(ENCRYPTKEY);
    }
    
    byte targetId = inputstr.toInt(); //extract ID if any
    byte colonIndex = inputstr.indexOf(":"); //find position of first colon

    if (targetId > 0)
    {
      inputstr = inputstr.substring(colonIndex+1); //trim "ID:" if any
    }

    if (targetId > 0 && targetId != NODEID && targetId != RF69_BROADCAST_ADDR && colonIndex>0 && colonIndex<4 && inputstr.length()>0)
    {
      inputstr.getBytes(buff, 61);
      //DEBUGln((char*)buff);
      //DEBUGln(targetId);
      //DEBUGln(colonIndex);
      if (radio.sendWithRetry(targetId, buff, inputstr.length()))
      {
        DEBUGln("ACK:OK");
      }
      else
        DEBUGln("ACK:NOK");
    }
  }

  if (radio.receiveDone())
  {
    int rssi = radio.RSSI;
    DEBUG('[');DEBUG(radio.SENDERID);DEBUG("] ");
    if (radio.DATALEN > 0)
    {
      for (byte i = 0; i < radio.DATALEN; i++)
        DEBUG((char)radio.DATA[i]);
      DEBUG("   [RSSI:");DEBUG(rssi);DEBUG("]");
    }

    CheckForWirelessHEX(radio, flash, false); //non verbose DEBUG

    if (radio.ACKRequested())
    {
      byte theNodeID = radio.SENDERID;
      radio.sendACK();
      DEBUG("[ACK-sent]");
    }
    DEBUGln();
    Blink(LED,3);
  }
}

void Blink(byte PIN, int DELAY_MS)
{
  pinMode(PIN, OUTPUT);
  digitalWrite(PIN,HIGH);
  delay(DELAY_MS);
  digitalWrite(PIN,LOW);
}



Felix

Sketch looks fine.
I can support raspbian, I think you can install that via NOOBs. But I know others were able to install this on other distros.

EnMon

So I'm done with the installation. I am still experiencing the same situation.
I think screenshots will better explain my case.


Felix

I think the gateway.db is fine since that file is created by the app anyway.
I see the input from the Moteino but what I don't see is actual data.

Can you show a portion of the log where you're receiving data?

EnMon

The highlighted line is data coming from Node 3.

Felix

Bingo, your data is unrecognized. That will go in the gateway_nonmatches.db instead.
You will need to define a metric under userMetrics folder as outlined in the example.