⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myapp_ex01.c

📁 This network protcol stack,it is very strong and powerful!
💻 C
字号:
/******************************************************************************
* = MyApp_Ex01.c  - Initialization and main loop. ================ This file ==
*   MyApp_Ex02.c  - Energy Detection Scan. 
*   MyApp_Ex03a.c - A PAN Coordinator is started
*   MyApp_Ex03b.c - Device locates coordinator using Active Scan
*   MyApp_Ex04a.c - Coordinator responds to an Associate request
*   MyApp_Ex04b.c - Device Associates to the PAN coordinator
*   MyApp_Ex05a.c - Coordinator receives data from device
*   MyApp_Ex05b.c - Device sends direct data to the coordinator
*   MyApp_Ex06a.c - Coordinator sends indirect data to device
*   MyApp_Ex06b.c - Device polls for data from the coordinator
*   MyApp_Ex07a.c - Coordinator starts a beaconed network
*   MyApp_Ex07b.c - Device receives data using automatic polling
*   MyApp_Ex08a.c - Coordinator uses security
*   MyApp_Ex08b.c - Device uses security
*
* This application is the first in a series of demo applications. The purpose
* of the series is to demonstrate how the features of the 802.15.4 stack
* can be utilized to create a simple point to point network. We will end up
* with two applications: 1) A device which is able to discover a PAN
* coordinator, associate to it, and transmit/receive data. 2) A coordinator
* which is able to start a network (PAN), accept associations from devices,
* and transmit/receive data.
*
* Throughout this series of applications the included UART module is used
* for printing out status messages to the RS232 console. The serial port on
* your PC must be configured to 19200-8N1. Flow control is optional.
*
* In this first application the state machine concept chosen is introduced.
* Furthermore, proper initialization of the MAC is demonstrated. Last but
* not least the MLME main function is called in the main loop. This
* application does not yet have any real functionality. In the next code
* example we will use MAC interface calls to find a suitable channel to
* operate a PAN on.
*
******************************************************************************/

#include "802_15_4.h" /* Include everything related to the 802.15.4 interface*/
#include "Uart.h"     /* Defines the interface of the demo UART. */


/* The various states of the application state machine. */
enum {
  stateInit,
  stateListen,
  stateTerminate
};

/* The current state of the applications state machine */
uint8_t state;


/* Application Main Loop */
void main(void)
{ 
  /* return value of Mlme_Main() - not used yet */
  uint8_t macStatus;
  
  /* Initialize variables */
  state = stateInit;

  /* Execute the application state machine. */
  while(state < stateTerminate)
  {
    switch(state)
    {
    case stateInit:
      /* Initialize the UART so that we can print out status messages */
      Uart_Init();
      /* Initialize the 802.15.4 stack */
      Init_802_15_4();
      /* Goto idle state and listen for input to the state machine. */
      state = stateListen;
      
      /* Print to UART */
      Uart_Print("The Myapp_Ex01 demo application is initialized and ready.\n\n");
      break;
      
    case stateListen:
      /* Stay in this state forever. */
      break;
    }
        
    /* Call the MAC main function continuously. */
    macStatus = Mlme_Main();
  }
}

/* The following functions are called by the MAC
   to put messages into the Application's queue.
   They need to be defined even if they are not
   used in order to avoid linker errors. */
uint8_t MLME_NWK_SapHandler(nwkMessage_t *pMsg)
{
  /* If the message is not handled anywhere it must be freed. */
  MSG_Free(pMsg);
  return gSuccess_c;
}

uint8_t MCPS_NWK_SapHandler(mcpsToNwkMessage_t *pMsg)
{
  /* If the message is not handled anywhere it must be freed. */
  MSG_Free(pMsg);
  return gSuccess_c;
}

uint8_t ASP_APP_SapHandler(aspToAppMsg_t *pMsg)
{
  /* If the message is not handled anywhere it must be freed. */
  MSG_Free(pMsg);
  return gSuccess_c;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -