Please follow below steps to make an emergency call(eCall).
1. Get the PhoneFactory and PhoneManager instances.
auto &phoneFactory = PhoneFactory::getInstance();
auto phoneManager = phoneFactory.getPhoneManager();
2. Check if telephony subsystem is ready
bool subSystemsStatus = phoneManager->isSubsystemReady();
2.1 If telephony subsystem is not ready, wait for it to be ready
Telephony subsystems is to make sure that device is ready for services like Phone, SMS and others. if subsystems were not ready, wait for unconditionally.
if(!subSystemsStatus) {
std::future<bool> f = phoneManager->onSubsystemReady();
subSystemsStatus = f.get();
}
3. Instantiate Phone and call manager
auto phone = phoneManager->getPhone();
std::shared_ptr<ICallManager> callManager = phoneFactory.getCallManager();
5. Initialize phoneId with default value
int phoneId = DEFAULT_PHONE_ID;
6. Instantiate dial callback instance - this is optional
std::shared_ptr<DialCallback> dialCb = std::make_shared<DialCallback> ();
6.1. implement IMakeCallCallback interface to receive response for the dial request - optional
class DialCallback : public IMakeCallCallback {
public:
void makeCallResponse(ErrorCode error, std::shared_ptr<ICall> call) override;
};
void DialCallback::makeCallResponse(ErrorCode error, std::shared_ptr<ICall> call) {
}
7. Initialize the data required for eCall such as eCallMsdData,emergencyCategory and eCallVariant
ECallCategory emergencyCategory = ECallCategory::VOICE_EMER_CAT_AUTO_ECALL;
ECallVariant eCallVariant = ECallVariant::ECALL_TEST;
ECallMsdData eCallMsdData;
eCallMsdData.msdData.messageIdentifier = 1;
eCallMsdData.optionals.recentVehicleLocationN1Present = true;
eCallMsdData.optionals.recentVehicleLocationN2Present = true;
eCallMsdData.optionals.numberOfPassengersPresent = 2;
eCallMsdData.msdData.control.automaticAvtivation = true;
eCallMsdData.control.testCall = true;
eCallMsdData.control.positionCanBeTrusted = true;
eCallMsdData.control.vehicleType = ECallVehicleType::PASSENGER_VEHICLE_CLASS_M1;
eCallMsdData.msdData.vehicleIdentificationNumber.isowmi = "ECA";
eCallMsdData.msdData.vehicleIdentificationNumber.isovds = "LLEXAM";
eCallMsdData.msdData.vehicleIdentificationNumber.isovisModelyear = "P";
eCallMsdData.msdData.vehicleIdentificationNumber.isovisSeqPlant = "LE02013";
eCallMsdData.msdData.vehiclePropulsionStorage.gasolineTankPresent = true;
eCallMsdData.msdData.vehiclePropulsionStorage.dieselTankPresent = false;
eCallMsdData.vehiclePropulsionStorage.compressedNaturalGas = false;
eCallMsdData.vehiclePropulsionStorage.liquidPropaneGas = false;
eCallMsdData.vehiclePropulsionStorage.electricEnergyStorage = false;
eCallMsdData.vehiclePropulsionStorage.hydrogenStorage = false;
eCallMsdData.vehiclePropulsionStorage.otherStorage = false;
eCallMsdData.timestamp = 1367878452;
eCallMsdData.vehicleLocation.positionLatitude = 123;
eCallMsdData.vehicleLocation.positionLongitude = 1234;
eCallMsdData.msdData.vehicleDirection = 4;
eCallMsdData.recentVehicleLocationN1.latitudeDelta = false;
eCallMsdData.recentVehicleLocationN1.longitudeDelta = 0;
eCallMsdData.recentVehicleLocationN2.latitudeDelta = true;
eCallMsdData.recentVehicleLocationN2.
8. Send a eCall request
if(callManager) {
auto makeCallStatus = callManager->makeECall(phoneId, eCallMsdData, emergencyCategory,
eCallVariant, dialCb);
std::cout << "Dial ECall Status:" << (int)makeCallStatus << std::endl;
}