Request A Service
This section refers to the following sample application(s):
01-join
01-service
The 01-join
application uses the "base bandwith" to send data to the
SmartMesh manager
.For a discussion on base bandwidth, refer to the SmartMesh IP User's Guide.
In a real scenario, your application should request a service with the bandwidth corresponding to the amount of traffic if will actually send. This will cause the
SmartMesh manager
to install resources appropriate for the network's data requirements.It is important that your application requests the amount of bandwidth which corresponds to the amount of data it will produce:
- If you request too much bandwidth, the network will have a higher power consumption than needed.
- If you request too little bandwidth, a portion of your application's data packets will be denied by the
SmartMesh IP
stack when trying to send.
Requesting bandwidth consists in sending a request message to the
SmartMesh manager
, and waiting for aDN_API_LOC_EV_SVC_CHG
event from the stack. This is implemented in the loc_task
helper module.The 01-service
Sample Application
This application requests a 1000ms service after having joined the network. When it is granted, it queries the
SmartMesh IP
stack and prints the bandwidth which has actually been allocated by theSmartMesh manager
.As explained in the SmartMesh IP User's Guide, the
SmartMesh manager
rounds off the bandwidth your request. This is because of the periodic nature of the network's communication schedule. The bandwidth you are assigned may therefore be slightly larger than the bandwidth you requested. In the example below, your request 1000ms, and received 993ms (which is a more bandwidth).
The following is a capture of the CLI output of the 01-service
sample application:
service app, ver 1.0.0.1 SmartMeshIP stack, ver 1.2.1.3 23978 : Joining 24970 : Connected 31258 : Active Done joining! Service granted! Service: - dest: 0xfffe - type: 0 - status: 0 - value: 993 ms >
Implementation Details
The 01-service
sample application uses the Helper Modules to initialize the CLI Module and interaction with the local interface. In particular, it configures the loc_task
helper module to join the network and open a socket bound to UDP port 60000
.
It uses a single task (serviceTask
) which:
- waits for the
loc_task
helper module to have joined the network (by pending on thejoinedSem
semaphore); - waits for the
loc_task
helper module to be granted the requested service service (by pending on theserviceSem
semaphore); - every 10s, request the current service to the manager (by calling
dnm_loc_getAssignedServiceCmd()
), and print that over CLI.