Пример #1
0
void
ieee_init()
{
  void *mac;
  MAC_Pib_s *pib;

  if (process_is_running(&ieee_process))
    return;

  /* initialize ieee_eventhandler and event queue*/
  rxq_init();

  /* setup mac <-> app interface */
  u32AppApiInit((PR_GET_BUFFER) rxq_mlme_alloc, (PR_POST_CALLBACK) ieee_process_poll, NULL,
                (PR_GET_BUFFER) rxq_mcps_alloc, (PR_POST_CALLBACK) ieee_process_poll, NULL);

  /* get mac and pib handles */
  mac   = pvAppApiGetMacHandle();
  pib   = MAC_psPibGetHandle(mac);

  /* do a full reset */
  req_reset(true);

  /* set panid and default parameters */
  MAC_vPibSetPanId(mac, IEEE802154_PANDID);
  MAC_vPibSetRxOnWhenIdle(mac, true, false);

  /* allocate an event for this process */
  ieee_event = process_alloc_event();
  pib->bAutoRequest = true;

  /* bandwidth control, smaller interframe gap and higher data rate,
   * this is not standard conform! */
#if defined(__BA2__) && defined(JENNIC_CONF_JN5148_FASTDATARATE)
  vAHI_BbcSetHigherDataRate(E_AHI_BBC_CTRL_DATA_RATE_1_MBPS);
  vAHI_BbcSetInterFrameGap(48);
#endif

  process_start(&ieee_process, NULL);
}
Пример #2
0
int
start_sniffer(int channel) {
    void      *mac;
    MAC_Pib_s *pib;
    int res;

    rxq_init();

    /* setup mac <-> app interface */
    u32AppApiInit((PR_GET_BUFFER) rxq_mlme_alloc, (PR_POST_CALLBACK) dummy, NULL,
                  (PR_GET_BUFFER) rxq_mcps_alloc, (PR_POST_CALLBACK) dummy, NULL);

    /* get mac and pib handles */
    mac   = pvAppApiGetMacHandle();
    pib   = MAC_psPibGetHandle(mac);

    /* do a full reset */
    req_reset(true);
    MAC_vPibSetShortAddr(mac, 0x0001);
    MAC_vPibSetPromiscuousMode(mac, true, true);
    res = req_start(channel, true);
    MAC_vPibSetPromiscuousMode(mac, true, false);
    return res;
}