# Using SAP APIs This sample application demonstrates how to use SAP APIs to transmit APDU and listen to SAP events. 1. Implement ResponseCallback interface to receive subsystem initialization status std::promise cbProm = std::promise(); void initResponseCb(telux::common::ServiceStatus status) { if(status == SERVICE_AVAILABLE) { std::cout << Phone Manager subsystem is ready << std::endl; } else if(status == SERVICE_FAILED) { std::cout << Phone Manager subsystem initialization failed << std::endl; } cbProm.set_value(status); } Copy to clipboard 2. Get the PhoneFactory instance and SapCardManager instance auto &phoneFactory = PhoneFactory::getInstance(); std::promise prom; auto sapCardMgr = phoneFactory.getSapCardManager( DEFAULT_SLOT_ID, [&](telux::common::ServiceStatus status) { prom.set_value(status); }); if (!sapCardMgr) { std::cout << "ERROR - Failed to get SapCardManager instance" << std::endl; return; } Copy to clipboard 3. Wait for the SapCardManager subsystem initialization telux::common::ServiceStatus sapCardMgrStatus = sapCardMgr->getServiceStatus(); if (sapCardMgrStatus != telux::common::ServiceStatus::SERVICE_AVAILABLE) { std::cout << "SapCardManager subsystem is not ready , Please wait" << std::endl; } sapCardMgrStatus = prom.get_future().get(); if (sapCardMgrStatus == telux::common::ServiceStatus::SERVICE_AVAILABLE) { std::cout << "SapCardManager subsystem is ready" << std::endl; } else { std::cout << "ERROR - Unable to initialize SapCardManager subsystem" << std::endl; return; } Copy to clipboard 4. Instantiate ICommandResponseCallback, IAtrResponseCallback and ISapCardCommandCallback auto mySapCmdResponseCb = std::make_shared(); auto myAtrCb = std::make_shared(); auto myTransmitApduResponseCb = std::make_shared(); Copy to clipboard 4.1 Implementation of ICommandResponseCallback interface for receiving notifications on SAP events like open connection and close connection class MySapCommandResponseCallback : public ICommandResponseCallback { public: void commandResponse(ErrorCode error); }; void MySapCommandResponseCallback::commandResponse(ErrorCode error) { std::cout << "commandResponse, error: " << (int)error << std::endl; } Copy to clipboard 4.2 Implementation of IAtrResponseCallback interface for receiving notification on SAP event like request answer to reset(ATR) class MyAtrResponseCallback : public IAtrResponseCallback { public: void atrResponse(std::vector responseAtr, ErrorCode error); }; void MyAtrResponseCallback::atrResponse(std::vector responseAtr, ErrorCode error) { std::cout << "atrResponse, error: " << (int)error << std::endl; } Copy to clipboard 4.3 Implementation of ISapCardCommandCallback interface for receiving notification on SAP event like transmit apdu class MySapTransmitApduResponseCallback : public ISapCardCommandCallback { public: void onResponse(IccResult result, ErrorCode error); }; void MySapTransmitApduResponseCallback::onResponse(IccResult result, ErrorCode error) { std::cout << "transmitApduResponse, error: " << (int)error << std::endl; } Copy to clipboard 5. Open SAP connection and wait for request to complete sapCardMgr->openConnection(SapCondition::SAP_CONDITION_BLOCK_VOICE_OR_DATA, mySapCmdResponseCb); std::cout << "Opening SAP connection to Transmit the APDU..." << std::endl; Copy to clipboard 6. Request SAP ATR and wait for complete sapCardMgr->requestAtr(myAtrCb); Copy to clipboard 7. Send SAP APDU and wait for the request to complete std::cout << "Transmit Sap APDU request made..." << std::endl; Status ret = sapCardMgr->transmitApdu(CLA, INSTRUCTION, P1, P2, LC, DATA, 0, myTransmitApduResponseCb); Copy to clipboard 8. Close SAP connection and wait for the request to complete sapCardMgr->closeConnection(mySapCmdResponseCb); Copy to clipboard Last Published: Nov 06, 2026 [Previous Topic Card service APIs to transmit APDU](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/card_services_app.md) [Next Topic Request network selection mode](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/network_selection.md)