# svcs.h File Reference

`#include <platform.h>`
`#include <event.h>`

Include dependency graph for svcs.h:

This graph shows which files directly or indirectly include this file:

## Defines
#define | _SVCS_H 1
## Enumerations
enum | SystemSvcsEnum { REBOOT_CNTL = 1, CPUPOWER_CNTL, ROUTESVC_CNTL, SWUPDATE_CNTL, CNTL_COUNT, REBOOT_NOTIFY, ROUTESVC_NOTIFY, SWUPDATE_NOTIFY, NOTIFY_COUNT }
enum | SvcCmdsEnum { START = 10, STOP }
enum | RouterSvcCmdsEnum { HOST = 20, ROUTER }
enum | RouteFlagsEnum { F_NETWORK_JOINED = 1, F_LEFT_NETWORK }
enum | SwUpdateCmdsEnum { DOWNLOAD_UPDATE = 50, PROBE_UPDATE, REPROGRAM }
enum | RebootFlagsEnum { F_REBOOT_BY_GW = 0x1, F_REPROGRAM_BY_GW }
## Functions
int16_t | svccntl (int16_t svc_enum, uint16_t cmd, void(*svc_handler)(event_t event, void *cbargs, void *context), void *resource, void *context)

## Define Documentation

#define _SVCS_H 1

## Enumeration Type Documentation

enum RebootFlagsEnum

Reboot Service flags in event_t on the callback notification.

Enumerator:

  F_REBOOT_BY_GW |
  F_REPROGRAM_BY_GW |

enum RouteFlagsEnum

Enumerator:

  F_NETWORK_JOINED | Node has joined a 6LoWPAN Mesh Network.
  F_LEFT_NETWORK | Node has is not connected to a 6LoWPAN Mesh Network

enum RouterSvcCmdsEnum

Router service commands

Enumerator:

  HOST |
  ROUTER |

enum SvcCmdsEnum

Kernel service commands

Enumerator:

  START |
  STOP |

enum SwUpdateCmdsEnum

Software Update command Enum

Enumerator:

  DOWNLOAD_UPDATE |
  PROBE_UPDATE |
  REPROGRAM |

enum SystemSvcsEnum

Kernel services.

Enumerator:

  REBOOT_CNTL | Reboot Control. Execute directly. No callback is required. Supported commands: START and STOP.
  CPUPOWER_CNTL | CPU Sleep Control. Execute directly. No callback is required. Supported commands: START and STOP.
  ROUTESVC_CNTL | Route Control to configure if the node should be a router or just a host which does not route traffic from other nodes. Execute directly. No callback is required. Supported commands: HOST and ROUTER.
  SWUPDATE_CNTL | Software Update control. Not supported. Potential commands: PROBE_UPDATE, DOWNLOAD_UPDATE, and REPROGRAM.
  CNTL_COUNT |
  REBOOT_NOTIFY | Note: The following notifications will use the subtype field in event_t. Reboot Notification. Bind callback handler to kernel when started. Handler will be fired before node goes to reboot. Stopping the service removes the handler binding. Supported commands: START and STOP.
  ROUTESVC_NOTIFY | Route Changes Notification. Bind callback handler to kernel when started. Handler will be fire whenver route changes. The nature of the change is stored in flags field in event_t with values defined in RouteFlagsEnum. Stopping the service removes the handler binding. Supported commands: START and STOP.
  SWUPDATE_NOTIFY | Software Update service. Not supported. Supported commands: PROBE_UPDATE, DOWNLOAD_UPDATE, REPROGRAM,
  NOTIFY_COUNT |

## Function Documentation

int16_t svccntl | ( | int16_t | svc_enum,
|  | uint16_t | cmd,
|  | void(*)(event_t event, void *cbargs, void *context) | svc_handler,
|  | void * | resource,
|  | void * | context |
| ) |  |  |

Invoke kernel services or listen for kernel notifications.

Parameters:

  `[in]` | svc_enum | kernel service enumeration name. See SystemSvcsEnum.
  `[in]` | cmd | commands to invoke the service
  `[in]` | svc_handler | the continuation callback handler for notification. If NULL is passed here, the call will fail unless cmd is for control and does not require notification.
  `[in]` | resource | no requirement here.
  `[in]` | context | user context

Returns:
  0 if succeed or -1 if fail and errno is set appropriately.

Errors:
  EBUSY if the underlying system is busy

  EINVAL if invalid parameters are passed

## Callback Descriptions

### svc_handler

Parameters:

  `[in]` | event | type is SVCCNTL in EventsEnum. subtype is set to cmd. flags field may contain extra information, depending on nature of the cmd.
  `[in]` | cbargs | return resource in svncntl()
  `[in]` | context | return context in svncntl()

Returns:
  None.