wireless programming question: handshake fail

Started by xavier, October 19, 2015, 01:38:59 PM

xavier

hey there,

I'm trying to program wirelessly my moteino but having some issues...

I'm using the code from github (https://github.com/LowPowerLab/RFM69/blob/master/Examples/WirelessProgramming_node/WirelessProgramming_node.ino) and applied it to my weather kinda sensor.

One thing that is different with the sample code: I changed the bit rate for the node and the hub to be as follow:
//the bitrate settings
//https://lowpowerlab.com/forum/index.php?topic=562.0
radio.writeReg(0x03,0x68); ////RegBitrateMsb 1200 bitrate
radio.writeReg(0x04,0x2B);


my loop code for the sensor/node is roughly something like:
{
checkWirelessProgramming();
time++;
sendSensorData();
sleepTenMinutes();
}


void sleepTenMinutes()
{
  for (int i = 0; i < 113; i++) { //75 for 10m
     checkWirelessProgramming();
     LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  }
}

void checkWirelessProgramming() {
  // Check for existing RF data, potentially for a new sketch wireless upload
  // For this to work this check has to be done often enough to be
  // picked up when a GATEWAY is trying hard to reach this node for a new sketch wireless upload
  if (radio.receiveDone())
  {
    Serial.print("Wireless Programming -> Got [");
    Serial.print(radio.SENDERID);
    Serial.print(':');
    Serial.print(radio.DATALEN);
    Serial.print("] > ");
    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((char)radio.DATA[i], HEX);
    Serial.println();
    CheckForWirelessHEX(radio, flash, true);
    Serial.println();
  }
}


SendSensorData is something around the lines of :
void sendSensorData() {
 ...Get sensor Data ...
  if (radio.sendWithRetry(GATEWAYID, (const void*)(&data), sizeof(data), 2, 220)){
    Serial.print(" sensor data sent ok!");
    //flashLed(1,1000);
  }
  else {Serial.print(" nothing...");flashLed(3,500);}
}


now, just to be transparent the code does not go to the sleep loop until 20 data points have been sent - during that time I run the python script to send the new code - it seems the gateway does find the target but I alway get the following error:
Moteino: [Handshake fail 2]
FLX?

This after 5 or 7 tries fyi but looking at the python code (with my basic understanding of python) I suppose the gateway did find the target but then the handshake between the 2 failed...any idea if I missed anything obvious?

I'm going to try to remove the bit rate setting on both gateway and node but I have a feeling I may be missing something...

Thanks in advance!

X

xavier

actually I think I'm mistaken in my assumption that the target is found - I never get the "Wireless Programming -> Got" console message.

Maybe I need to try to use an interrupt to be notified of a message during my delay loop...

xavier

k sorry about the realtime debugging  - but I've changed my delay loop so it check every second wirelessProgramming if we're trying to get reprogrammed and now I do get the debug info shown, unfortunately I get the following error now:

Wireless Programming -> Got [254:4] > 464C583F
FLX?OK (ACK sent)
Timeout/Error, erasing written data ... DONE

Looking is the shift channel is causing an issue now..

xavier

k, so it seems my issue is due to the fact I'm changing the bitrate on the radio for the gateway and the target. If I removed these lines everything works fine.

I tried to pass -b 1200 in the command line for the python script thinking the script was sending too much data to the gateway and not splitting the data to 1200 bauds but it did not change anything (though I'm not certain the communication speed and the chunks being sent are related) - oh well I guess I'll change my other sensors and the wifi gateway to not use 1200 bauds since the wireless programming feature is quite useful when your sensors are far...

Let me know if anyone figures this out and what I missed... thanks!

X