Ejemplo n.º 1
0
static void appSendData(void)
{
#ifdef NWK_ENABLE_ROUTING
  appMsg.parentShortAddr = NWK_RouteNextHop(0, 0);
#else
  appMsg.parentShortAddr = 0;
#endif

  appMsg.sensors.battery     = rand() & 0xffff;
  appMsg.sensors.temperature = rand() & 0x7f;
  appMsg.sensors.light       = rand() & 0xff;

#if APP_COORDINATOR
  appSendMessage((uint8_t *)&appMsg, sizeof(appMsg));
  SYS_TimerStart(&appDataSendingTimer);
  appState = APP_STATE_WAIT_SEND_TIMER;
#else
  nwkDataReq.dstAddr = 0;
  nwkDataReq.dstEndpoint = APP_ENDPOINT;
  nwkDataReq.srcEndpoint = APP_ENDPOINT;
  nwkDataReq.options = NWK_OPT_ACK_REQUEST | NWK_OPT_ENABLE_SECURITY;
  nwkDataReq.data = (uint8_t *)&appMsg;
  nwkDataReq.size = sizeof(appMsg);
  nwkDataReq.confirm = appDataConf;

  LED_On(LED_DATA);
  NWK_DataReq(&nwkDataReq);

  appState = APP_STATE_WAIT_CONF;
#endif
}
Ejemplo n.º 2
0
static bool appDataInd(NWK_DataInd_t *ind)
{
  AppMessage_t *msg = (AppMessage_t *)ind->data;

  ledToggle(LED_DATA);

  msg->lqi = ind->lqi;
  msg->rssi = ind->rssi;

  appSendMessage(ind->data, ind->size);
  return true;
}
Ejemplo n.º 3
0
static bool appDataInd(NWK_DataInd_t *ind)
{
  AppMessage_t *msg = (AppMessage_t *)ind->data;

  LED_Toggle(LED_DATA);

  msg->lqi = ind->lqi;
  msg->rssi = ind->rssi;
#if APP_COORDINATOR
  appSendMessage(ind->data, ind->size);
#endif  
  return true;
}