This tutorial describes how to write the plug-ins for HWRM.
Symbian developers must implement the CHWRMPluginService in their plug-in. The HWRM plug-in must create a new instance of the CHWRMPluginServices using CHWRMPluginService::NewL() method. A string and a callback pointer are passed as the parameters. The common strings used to identify the plug-in are HWRMLight, HWRMVibra and HWRMPower. The callback pointer is provided by the MHWRMPluginCallback class.
The client APIs requests are forwarded to the plug-in using a CHWRMPluginServices::ProcessCommandL(). Command ID, transaction ID and command data are passed as parameters. The plug-in communicates with the hardware using proprietary software developed by the licensees and convert the client requests into hardware control commands. After processing a request, the plug-in acknowledges the server by calling the MHWRMPluginCallback::ProcessResponseL() callback function. The same command ID and transaction ID are passed as the parameters. An error code is also included in the acknowledgement message.
Every MHWRMPluginCallback::ProcessResponseL() is associated with an CHWRMPluginServices::ProcessCommandL() request. Both functions can use asynchronous calls and leave. The HWRM server can cancel a CHWRMPluginServices::ProcessCommandL() request by calling a CHWRMPluginService::CancelCommandL().
Configure HWRM plug-ins as an ECom plug-in. To load the plug-in correctly, the resource files must be configured carefully.
The following code illustrates a sample resource file for Light and Vibra plug-ins:
#include "RegistryInfoV2.rh" //Sample resource file for Light and Vibra plug-ins RESOURCE REGISTRY_INFO theInfo { resource_format_version = RESOURCE_FORMAT_VERSION_2; dll_uid = 0x12345678; interfaces = { INTERFACE_INFO { // UID of interface that is implemented interface_uid = 0x10205028; implementations = { IMPLEMENTATION_INFO { implementation_uid = 0x11223344; version_no = 1; display_name = "Light plugin stub"; default_data = "HWRMLight"; opaque_data = ""; rom_only = 1; }, IMPLEMENTATION_INFO { implementation_uid = 0x55667788; version_no = 1; display_name = "Vibra plugin stub"; default_data = "HWRMVibra"; opaque_data = ""; rom_only = 1; } }; } }; }
Note: The value of rom_only must always be 1. The default data must be HWRMLight, HWRMVibra, HWRMPower.
The following code snippet illustrates how a light plug-in is called by the HWRM server:
#include "HWRMpluginService.h" _LIT8( KHWRMLightApiEComMatch, "HWRMLight" ); iPlugin = CHWRMPluginService::NewL( KHWRMLightApiEComMatch, this ); iTransCounter = 0; . . . HWRMLightCommand::TLightsOnData pluginCommand; pluginCommand.iTarget = 0x00000001; // Set target to primary display pluginCommand.iIntensity = 50; pluginCommand.iFadeIn = EFalse; HWRMLightCommand::TLightsOnCmdPackage pckg( pluginCommand ); iPlugin->ProcessCommandL( HWRMLightCommand::ELightsOnCmdId, iTransCounter++, pckg ); //Example of how ProcessResponseL() or EventL() might be handled HWRMLightCommand::TErrorCodeResponsePackage errPckg; errPckg.Copy( aData ); TInt pluginErr = errPckg(); // Handle error here
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.