Ejemplo n.º 1
0
void initAndRunMainLoop(void)
{
  EmberStatus status;
  emberTaskEnableIdling(true);

  emAppTask = emberTaskInit(emAppEvents);

  // Initialize the radio and the stack.  If this fails, we have to assert
  // because something is wrong.
  status = emberInit();
  emberSerialPrintfLine(COM_USART2, "Init: 0x%x", status);
  assert(status == EMBER_SUCCESS);

  emberAfInit();
  emberAfMainInitCallback();

  while (TRUE) {
    // Let the stack or EZSP layer run periodic tasks.
    emberTick();

    // Let the application and plugins run periodic tasks.
    emberAfMainTickCallback();
    emberAfTick();

    emberRunTask(emAppTask);
  }
}
Ejemplo n.º 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);
  }
}
Ejemplo n.º 3
0
static void loop(void)
{
  while (true) {
    // Reset the watchdog timer to prevent a timeout.
    halResetWatchdog();

    PROCESS_MANAGEMENT_COMMAND();

    if (init) {
      init = false;
      emberAfInit();
    }

    // Let the stack, application, and plugins run periodic tasks.  This
    // function is generated.
    emberAfTick();

    // Run the application and plugin events.
    emberRunTask(emAppTask);

    simulatedTimePassesMs(emberMsToNextEvent(emAppEvents, MAX_INT32U_VALUE));
  }
}
Ejemplo n.º 4
0
void initAndRunMainLoop(void)
{
  EmberEventControl dataReportControl;
  EmberStatus status;
  int counter_reset = 0;
  emberTaskEnableIdling(true);

  emAppTask = emberTaskInit(emAppEvents);

  // Initialize the radio and the stack.  If this fails, we have to assert
  // because something is wrong.
  status = emberInit();
  emberSerialPrintfLine(COM_USART2, "Inititialization: 0x%x", status);	//ember success;0x00 so emberinit worked
  assert(status == EMBER_SUCCESS);


  emberAfInit();
  emberAfMainInitCallback();       //emberNetworkInit() called here

  emberResetNetworkState(); /////////////////leave network to join coordinator

  EmberNetworkStatus net_status;
  EmberNetworkParameters parameters;

  emberSetSecurityKey(&securityKey);

  MEMSET(&parameters, 0, sizeof(EmberNetworkParameters));
  parameters.radioTxPower = 0;
  parameters.radioChannel = 1;
  parameters.panId = 0x01FF;

  halStackSeedRandom(halCommonGetInt32uMillisecondTick());

  while (TRUE) {
    // Let the stack or EZSP layer run periodic tasks.
    emberTick();
    // Let the application and plugins run periodic tasks.

    emberAfMainTickCallback();
    emberAfTick();
    emberEventControlSetActive(dataReportControl);

    net_status = emberNetworkState();
    //emberResetNetworkState();
    //emberJoinNetwork(EMBER_STAR_END_DEVICE, &parameters);
    /*
    if(!emberStackIsUp()){
    	emberAfGuaranteedPrintln("stack wasn't up");
    	emberJoinNetwork(EMBER_STAR_END_DEVICE, &parameters);
    }
	*/
    //emberAfGuaranteedPrintln("net_status is: %d", net_status);
    if(counter_reset == 10000){
    	emberResetNetworkState();
    	counter_reset = 0;
    }
    else{
    	counter_reset++;
    }
    if (net_status == EMBER_NO_NETWORK){
        //emberPermitJoining(0xFF);
    	//emberResetNetworkState();
    	emberAfGuaranteedPrintln("Network has been reset");
    	emberJoinNetwork(EMBER_STAR_END_DEVICE, &parameters);
    }



    emberRunTask(emAppTask);
  }
}