# server.c File Reference

The functions in this file initializes the wireless interface and starts the TCP server. More...

`#include <sys/svcs.h>`
`#include <sys/time.h>`
`#include <sys/socket.h>`
`#include <string.h>`
`#include <stdio.h>`
`#include <unistd.h>`
`#include <netinet/inet.h>`
`#include <netinet/in.h>`
`#include <iwconfig.h>`
`#include <raven.h>`
`#include "ieee802154.h"`
`#include "uart.h"`
`#include "shell.h"`

Include dependency graph for server.c:

## Defines
#define | LEDMAX 20
| Maximum LED blink window, in units of 200ms epochs.
#define | MAXIP 128
| maximum number of characters used to display IPv6 address
#define | IPMSG "IPv6:"
| default display string preceding IP addresses
## Functions
void | __main (event_t event, void *cbargs, void *context)
| this function is invoked after boot
void | timer_handler (event_t event, void *cbaargs, void *context)
| this function is invoked when the timer is fired
void | iwconfig_handler (event_t event, void *cbargs, void *context)
| this function is invoked when iwconfig() UP operation is complete
void | route_notify_handler (event_t event, void *cbargs, void *context)
| this function is invoked when svccntl() ROUTESVC_NOTIFY signal takes place
void | iwstatus_handler (event_t event, void *cbargs, void *context)
| this function is invoked when iwconfig() STATUS operation is complete
void | setBlink (uint8_t count)
| this function sets LED_cnt and LED_limit
void | iwconfig_init (net_device_t net_device)
## Variables
static int16_t | g_timerfd
| timer descripter, used to hold the return value of timer()
static uint8_t | LED_cnt = 0
| Current LED blink count, in units of 200ms epochs, initialized to 0.
static uint8_t | LED_limit = 0
| Current LED blink limit, in units of 200ms epochs, initialized to 0.
uint8_t | ieee154_channel = default_ieee154_channel
| default 802.15.4 channel, defiend in ieee802154.h
uint16_t | ieee154_panid = default_ieee154_panid
| default 80215.4 PAN ID, defined in ieee802154.h
static net_device_info_t | g_lpan0_info
| Network interface information from iwconfig.

## Detailed Description

The functions in this file initializes the wireless interface and starts the TCP server.

## Define Documentation

#define IPMSG "IPv6:"

default display string preceding IP addresses

#define LEDMAX 20

Maximum LED blink window, in units of 200ms epochs.

#define MAXIP 128

maximum number of characters used to display IPv6 address

## Function Documentation

void __main | ( | event_t | event,
|  | void * | cbargs,
|  | void * | context |
| ) |  |  |

this function is invoked after boot

__main

Parameters:

  | event | equals MAIN as this is a boot event
  | cbargs | is NULL for boot event
  | context | is NULL for boot event

Returns:
  none

Here is the call graph for this function:

void iwconfig_handler | ( | event_t | event,
|  | void * | cbargs,
|  | void * | context |
| ) |  |  |

this function is invoked when iwconfig() UP operation is complete

iwconfig_handler

Parameters:

  | event | equals to IWCONFIG as this is a iwconfig() UP callback
  | cbargs | passes dev_info back from iwconfig() UP call
  | context | passes context back from iwconfig() UP call

Returns:
  none

Here is the call graph for this function:

void iwconfig_init | ( | net_device_t | net_device | ) |

iwconfig_init

Initialize the wireless interface

Parameters:

  | net_device | is the data structure used to hold the interface configuration data

Returns:
  none

Here is the call graph for this function:

void iwstatus_handler | ( | event_t | event,
|  | void * | cbargs,
|  | void * | context |
| ) |  |  |

this function is invoked when iwconfig() STATUS operation is complete

iwstatus_handler

Parameters:

  | event | equals to IWCONFIG as this is a iwconfig() STATUS callback
  | cbargs | passes dev_info back from iwconfig() STATUS call
  | context | passes context back from iwconfig() STATUS call

Returns:
  none

Here is the call graph for this function:

void route_notify_handler | ( | event_t | event,
|  | void * | cbargs,
|  | void * | context |
| ) |  |  |

this function is invoked when svccntl() ROUTESVC_NOTIFY signal takes place

route_notify_handler

Parameters:

  | event | equals to SVCCNTRL as this is a svccntrl() ROUTESVC_NOTIFY callback
  | cbargs | passes resource back from svccntrl() ROUTESVC_NOTIFY call
  | context | passes context back from svccntrl() ROUTESVC_NOTIFY call

Returns:
  none

Here is the call graph for this function:

void setBlink | ( | uint8_t | count | ) |

this function sets LED_cnt and LED_limit

setBlink

LED_cnt = count

LED_limit = LED_cnt * 2

Parameters:

  | count | is the value of LED_cnt

Returns:
  none

Here is the call graph for this function:

void timer_handler | ( | event_t | event,
|  | void * | cbaargs,
|  | void * | context |
| ) |  |  |

this function is invoked when the timer is fired

timer_handler

Parameters:

  | event | equals to SETITIMER as this is a setitimer() callback
  | cbargs | passes resource back from setitimer() call
  | context | passes context back from setitimer() call

Returns:
  none

Here is the call graph for this function:

## Variable Documentation

net_device_info_t g_lpan0_info`[static]`

Network interface information from iwconfig.

int16_t g_timerfd`[static]`

timer descripter, used to hold the return value of timer()

uint8_t ieee154_channel = default_ieee154_channel

default 802.15.4 channel, defiend in ieee802154.h

uint16_t ieee154_panid = default_ieee154_panid

default 80215.4 PAN ID, defined in ieee802154.h

uint8_t LED_cnt = 0`[static]`

Current LED blink count, in units of 200ms epochs, initialized to 0.

uint8_t LED_limit = 0`[static]`

Current LED blink limit, in units of 200ms epochs, initialized to 0.