# Using remote SIM manager APIs

This sample application demonstrates how to use remote SIM manager APIs for remote SIM card operations.

1. Implement ResponseCallback interface to receive subsystem initialization status

std::promise<telux::common::ServiceStatus> cbProm = std::promise<telux::common::ServiceStatus>();
    void initResponseCb(telux::common::ServiceStatus status) {
       if (subSystemsStatus == SERVICE_AVAILABLE) {
          std::cout << RemoteSim Manager subsystem is ready << std::endl;
       } else if(subSystemsStatus == SERVICE_FAILED) {
          std::cout << RemoteSim Manager subsystem initialization failed << std::endl;
       }
       cbProm.set_value(status);
    }
    Copy to clipboard

2. Get the PhoneFactory and RemoteSimManager instances

#include <telux/tel/PhoneFactory.hpp>
    
    using namespace telux::common;
    using namespace telux::tel;
    
    PhoneFactory &phoneFactory = PhoneFactory::getInstance();
    auto remoteSimMgr =
        phoneFactory.getRemoteSimManager(DEFAULT_SLOT_ID, initResponseCb);
     if (remoteSimMgr == NULL) {
       std::cout << " Failed to get RemoteSim Manager instance" << std::endl;
       return -1;
    }
    Copy to clipboard

3.Check if telephony subsystem is ready

telux::common::ServiceStatus status = remoteSimMgr.getServiceStatus();
    Copy to clipboard

3.1 Wait for the telephony subsystem initialization

telux::common::ServiceStatus status = cbProm.get_future().get();
    if (status != SERVICE_AVAILABLE) {
       std::cout << Unable to initialize Card Manager subsystem << std::endl;
       return -1;
    }
    Copy to clipboard

4. Instantiate and register RemoteSimListener

std::shared_ptr<IRemoteSimListener> listener = std::make_shared<RemoteSimListener>();
    remoteSimMgr.registerListener(listener);
    Copy to clipboard

4.1 Implementation of IRemoteSimListener interface for receiving Remote SIM notifications

class RemoteSimListener : public IRemoteSimListener {
    public:
        void onApduTransfer(const unsigned int id, const std::vector<uint8_t> &apdu) override {
            // Send APDU to SIM card
        }
        void onCardConnect() override {
            // Connect to SIM card and request AtR
        }
        void onCardDisconnect() override {
            // Disconnect from SIM card
        }
        void onCardPowerUp() override {
            // Power up SIM card and request AtR
        }
        void onCardPowerDown() override {
            // Power down SIM card
        }
        void onCardReset() override {
            // Reset SIM card
        }
        void onServiceStatusChange(ServiceStatus status) {
            // Handle case where modem goes down or comes up
        }
    };
    Copy to clipboard

4.2 Implementation of event callback for asynchronous requests

void eventCallback(ErrorCode errorCode) {
        std::cout << "Received event response with errorcode " << static_cast<int>(errorCode)
            << std::endl;
    }
    Copy to clipboard

5. Send connection available event request

    When the remote card is available and ready, make it available to the modem by sending a
connection available request.

if (remoteSimMgr->sendConnectionAvailable(eventCallback) != Status::SUCCESS) {
        std::cout << "Failed to send connection available request!" << std::endl;
    }
    Copy to clipboard

6. Send card reset request after receiving onCardConnect() notification from listener

    You will receive an onCardConnect notification on the listener when the modem accepts the
connection.

// After connecting to SIM card, requesting AtR, and receiving response with AtR bytes
    
    if (remoteSimMgr->sendCardReset(atr, eventCallback) != Status::SUCCESS) {
        std::cout << "Failed to send card reset request!" << std::endl;
    }
    Copy to clipboard

7. Send response APDU after receiving onTransmitApdu() notification from listener

// After sending command APDU to SIM and receiving the response
    
    if (remoteSimMgr->sendApdu(id, apdu, true, apdu.size(), 0, eventCallback) != Status::SUCCESS) {
        std::cout << "Failed to send response APDU!" << std::endl;
    }
    Copy to clipboard

8. Send connection unavailable request before exiting

    When the card becomes unavailable (or before you exit), tear down the connection with the modem.

if (remoteSimMgr->sendConnectionUnavailable() != Status::SUCCESS) {
        std::cout << "Failed to send connection unavailable request!" << std::endl;
    }
    Copy to clipboard

Last Published: Apr 14, 2026

[Previous Topic
Smart network selection](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/smart_network_selection.md) [Next Topic
Using remote SIM reference apps](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/remote_sim_reference_apps.md)