static void pjoin(void)
{
  if (emberPermitJoining(PJOIN_DURATION_S) == EMBER_SUCCESS) {
    halPlayTune_P(happyTune, TRUE);
  } else {
    halPlayTune_P(sadTune, TRUE);
  }
}
Beispiel #2
0
void initAndRunMainLoop(void)
{

//is working if doing it manually with cli commands

#define SENSOR_SINK_SECURITY_KEY    {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,       \
                                     0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,       \
                                     0xAA, 0xAA, 0xAA, 0xAA}



uint8_t duration = 0xFF; //says how long it will allow joining (0xFF means a node can join at any time)
///////////////////////////////////////////////////////////////////
  EmberStatus status;
  EmberStatus net_status;


  emberTaskEnableIdling(true);
  emAppTask = emberTaskInit(emAppEvents);

  status = emberInit();//                                           (5) (continued from step 4 at end of emberAfMainInitCallback()) Bring up Stack
  emberSerialPrintfLine(COM_USART2, "Initialization: 0x%x", status);	//ember success 0x00 so emberinit worked; stack is up?
  assert(status == EMBER_SUCCESS);
  // Initialize the radio and the stack.  If this fails, we have to assert
  // because something is wrong.


  emberAfInit();
  emberAfMainInitCallback();


  emberPermitJoining(duration);
  if(net_status == EMBER_SUCCESS){
      	emberAfGuaranteedPrintln("Stack is up?");
      }
  if (emberStackIsUp()){	//this does not come out true despite emberinit() is producing EMBER_SUCCESS so stack isn't really up?
	  emberAfGuaranteedPrintln("Stack is definitely up");
  }

  while (TRUE) {
    // Let the stack or EZSP layer run periodic tasks.
    emberTick();
    //emberAfGuaranteedPrintln("not stuck");
    // Let the application and plugins run periodic tasks.
    emberAfMainTickCallback();
    emberAfTick();
    emberRunTask(emAppTask);
  }
}