Feature

Overview

Related Modules:

Samgr

Description:

Defines the base class of a feature.

You need to implement the pointer to the feature.

Since:

1.0

Version:

1.0

Summary

Data Fields

Variable Name

Description

GetName )(Featurefeature)

const char ( 

Obtains a feature name.

OnInitialize )(Feature feature, Serviceparent, Identity identity)

void( 

Initializes a feature.

OnStop )(Featurefeature, Identity identity)

void( 

Stops a feature.

OnMessage )(Featurefeature, Requestrequest)

BOOL(* 

Processes a feature message.

Details

Field Documentation

GetName

  1. constchar*(*Feature::GetName)([Feature]($api-api-LinkIoT-Feature.md)*feature)

Description:

Obtains a feature name.

This function is implemented by developers and called by Samgr during feature registration and startup.

Parameters:

Name

Description

featureIndicates the pointer to the feature.

Returns:

Returns a constant character string less than 16 bytes if the operation is successful; returns NULL if the operation fails.

OnInitialize

  1. void(*Feature::OnInitialize)([Feature]($api-api-LinkIoT-Feature.md)*feature,[Service]($api-api-LinkIoT-Service.md)*parent,[Identity]($api-api-LinkIoT-Identity.md) identity)

Description:

Initializes a feature.

This function is implemented by developers. After Samgr dispatches tasks to a service, the service calls this function in its own tasks.

Parameters:

Name

Description

featureIndicates the pointer to the feature.
parentIndicates the pointer to the Service to which the feature belongs.
identityIndicates the identity of a feature dispatched by the system.

OnMessage

  1. BOOL(*Feature::OnMessage)([Feature]($api-api-LinkIoT-Feature.md)*feature,[Request]($api-api-LinkIoT-Request.md)*request)

Description:

Processes a feature message.

This function is implemented by developers to process requests sent by callers through IUnknown.

Parameters:

Name

Description

featureIndicates the pointer to the feature.
requestIndicates the request message.

Returns:

Returns TRUE if the processing is successful; returns FALSE if the processing fails.

OnStop

  1. void(*Feature::OnStop)([Feature]($api-api-LinkIoT-Feature.md)*feature,[Identity]($api-api-LinkIoT-Identity.md) identity)

Description:

Stops a feature.

This function is implemented by developers and is called by Samgr when a feature is deregistered to stop running services.

Parameters:

Name

Description

featureIndicates the pointer to the feature.
identityIndicates the Identity of the feature to be stopped.