~aleteoryx/muditaos

d5b0283a0c4c4f5118f1c027f10d1e43c42d2677 — Maciej Gibowicz 5 years ago 4929c07
[EGD-4038] handling incoming calls and sms in sleep mode (#819)

M changelog.md => changelog.md +1 -0
@@ 5,6 5,7 @@
### Added

* `[meditation]` Added basic meditation functionalities and settings
* `[cellular]` Handling incoming calls and sms in sleep mode

### Fixed
* `[audio]` Fix headphones autodetection.

M module-bsp/board/linux/cellular/linux_cellular.cpp => module-bsp/board/linux/cellular/linux_cellular.cpp +7 -0
@@ 271,5 271,12 @@ namespace bsp
            void sim_sel()
            {}
        } // namespace sim
        namespace ringIndicator
        {
            auto riIRQ_handler() -> BaseType_t
            {
                return BaseType_t();
            }
        } // namespace ringIndicator
    }     // namespace cellular
} // namespace bsp

M module-bsp/board/rt1051/bsp/cellular/rt1051_cellular.cpp => module-bsp/board/rt1051/bsp/cellular/rt1051_cellular.cpp +17 -2
@@ 326,7 326,7 @@ namespace bsp
                                .pin      = static_cast<uint32_t>(BoardDefinitions::CELLULAR_GPIO_1_STATUS_PIN)});

        gpio_2->ConfPin(DriverGPIOPinParams{.dir      = DriverGPIOPinParams::Direction::Input,
                                            .irqMode  = DriverGPIOPinParams::InterruptMode::IntRisingOrFallingEdge,
                                            .irqMode  = DriverGPIOPinParams::InterruptMode::IntFallingEdge,
                                            .defLogic = 1,
                                            .pin = static_cast<uint32_t>(BoardDefinitions::CELLULAR_GPIO_2_RI_PIN)});



@@ 401,7 401,8 @@ namespace bsp
        // ENABLE INTERRUPTS

        gpio_1->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::CELLULAR_GPIO_1_STATUS_PIN));
        gpio_2->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::CELLULAR_GPIO_2_SIM_TRAY_INSERTED_PIN));
        gpio_2->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::CELLULAR_GPIO_2_SIM_TRAY_INSERTED_PIN) |
                                1 << static_cast<uint32_t>(BoardDefinitions::CELLULAR_GPIO_2_RI_PIN));
    }

    void RT1051Cellular::MSPDeinit()


@@ 592,5 593,19 @@ namespace bsp
                }
            }
        } // namespace sim

        namespace ringIndicator
        {
            auto riIRQ_handler() -> BaseType_t
            {
                BaseType_t xHigherPriorityTaskWoken = pdFALSE;
                if (qhandle != NULL) {
                    uint8_t val = static_cast<uint8_t>(IRQsource::ringIndicatorPin);
                    xQueueSendFromISR(qhandle, &val, &xHigherPriorityTaskWoken);
                }
                return xHigherPriorityTaskWoken;
            }
        } // namespace ringIndicator

    }     // namespace cellular
} // namespace bsp

M module-bsp/board/rt1051/common/irq/irq_gpio.cpp => module-bsp/board/rt1051/common/irq/irq_gpio.cpp +1 -1
@@ 127,7 127,7 @@ namespace bsp
            }

            if (irq_mask & (1 << BSP_CELLULAR_RI_PIN)) {
                // TODO:M.P BSP_CellularUartRingIndicatorIrqHandler();
                bsp::cellular::ringIndicator::riIRQ_handler();
            }

            // Clear all IRQs

M module-bsp/bsp/cellular/bsp_cellular.hpp => module-bsp/bsp/cellular/bsp_cellular.hpp +8 -0
@@ 74,6 74,7 @@ namespace cellular
        enum IRQsource{
            statusPin,
            trayPin,
			ringIndicatorPin,
        };

        /// initialize SIM queue directed to EventWorker


@@ 119,6 120,13 @@ namespace cellular
            void hotswap_trigger();
            void sim_sel();
        } // namespace sim

        namespace ringIndicator
		{
        	// handling incoming calls and sms - RI pin
        	BaseType_t riIRQ_handler();
		} // namespace RingIndicator

    }     // namespace cellular
};        // namespace bsp


M module-cellular/Modem/TS0710/TS0710.cpp => module-cellular/Modem/TS0710/TS0710.cpp +15 -0
@@ 539,3 539,18 @@ void TS0710::ResetModem(void)
{
    return pv_cellular->Restart();
}

void TS0710::TurnOffModem(void)
{
    return pv_cellular->PowerDown();
}

void TS0710::EnterSleepMode(void)
{
    return pv_cellular->EnterSleep();
}

void TS0710::ExitSleepMode(void)
{
    return pv_cellular->ExitSleep();
}

M module-cellular/Modem/TS0710/TS0710.h => module-cellular/Modem/TS0710/TS0710.h +3 -0
@@ 444,6 444,9 @@ class TS0710
    bool IsModemActive(void);
    void TurnOnModem(void);
    void ResetModem(void);
    void TurnOffModem(void);
    void EnterSleepMode(void);
    void ExitSleepMode(void);
};

#endif //_TS0710_H

M module-cellular/at/Commands.hpp => module-cellular/at/Commands.hpp +8 -0
@@ 57,8 57,12 @@ namespace at
        FLOW_CTRL_ON,
        FLOW_CTRL_OFF,
        URC_NOTIF_CHANNEL,          /// Route URCs to second (Notifications) MUX channel
        RI_PIN_AUTO_CALL,           /// Turn on RI pin for incoming calls
        RI_PIN_OFF_CALL,            /// Turn off RI pin for incoming calls
        RI_PIN_PULSE_SMS,           /// Turn on RI pin for incoming sms
        RI_PIN_OFF_SMS,             /// Turn off RI pin for incoming sms
        RI_PIN_OFF_OTHER,           /// Turn off RI pin for other URCs
        URC_DELAY_ON,               /// Enable delay the output of URC indication until ring indicator pulse ends
        URC_UART1,                  /// Route URCs to UART1
        AT_PIN_READY_LOGIC,         /// Configure AP_Ready pin logic ( enable, logic level 1, 200ms )
        URC_NOTIF_SIGNAL,           /// Turn on signal strength change URC


@@ 126,8 130,12 @@ namespace at
            {AT::FLOW_CTRL_ON, {"AT+IFC=2,2\r\n", 500}},
            {AT::FLOW_CTRL_OFF, {"AT+IFC=0,0\r", 500}},
            {AT::URC_NOTIF_CHANNEL, {"AT+QCFG=\"cmux/urcport\",1\r"}},
            {AT::RI_PIN_AUTO_CALL, {"AT+QCFG=\"urc/ri/ring\",\"auto\"\r"}},
            {AT::RI_PIN_OFF_CALL, {"AT+QCFG=\"urc/ri/ring\",\"off\"\r"}},
            {AT::RI_PIN_PULSE_SMS, {"AT+QCFG=\"urc/ri/smsincoming\",\"pulse\",200\r"}},
            {AT::RI_PIN_OFF_SMS, {"AT+QCFG=\"urc/ri/smsincoming\",\"off\"\r"}},
            {AT::RI_PIN_OFF_OTHER, {"AT+QCFG=\"urc/ri/other\",\"off\"\r"}},
            {AT::URC_DELAY_ON, {"AT+QCFG=\"urc/delay\",1\r"}},
            {AT::URC_UART1, {"AT+QURCCFG=\"urcport\",\"uart1\"\r"}},
            {AT::AT_PIN_READY_LOGIC, {"AT+QCFG=\"apready\",1,1,200\r"}},
            {AT::URC_NOTIF_SIGNAL, {"AT+QINDCFG=\"csq\",1\r"}},

M module-cellular/at/src/Commands.cpp => module-cellular/at/src/Commands.cpp +4 -2
@@ 11,8 11,10 @@ namespace at
        switch (set) {
        case commadsSet::modemInit:
            ret.push_back(AT::URC_NOTIF_CHANNEL);
            ret.push_back(AT::RI_PIN_OFF_CALL);
            ret.push_back(AT::RI_PIN_OFF_SMS);
            ret.push_back(AT::RI_PIN_AUTO_CALL);
            ret.push_back(AT::RI_PIN_PULSE_SMS);
            ret.push_back(AT::RI_PIN_OFF_OTHER);
            ret.push_back(AT::URC_DELAY_ON);
            ret.push_back(AT::URC_UART1);
            ret.push_back(AT::AT_PIN_READY_LOGIC);
            ret.push_back(AT::URC_NOTIF_SIGNAL);

M module-services/service-cellular/ServiceCellular.cpp => module-services/service-cellular/ServiceCellular.cpp +2 -3
@@ 224,12 224,11 @@ sys::ReturnCodes ServiceCellular::SwitchPowerModeHandler(const sys::ServicePower

    switch (mode) {
    case sys::ServicePowerMode ::Active:
        // muxdaemon->ExitSleepMode();
        cmux->ExitSleepMode();
        break;
    case sys::ServicePowerMode ::SuspendToRAM:
    case sys::ServicePowerMode ::SuspendToNVM:
        LOG_FATAL("TEMPORARY DISABLED!!!!! UNCOMMENT WHEN READY.");
        //            muxdaemon->EnterSleepMode();
        cmux->EnterSleepMode();
        break;
    }


M module-services/service-evtmgr/EventManager.cpp => module-services/service-evtmgr/EventManager.cpp +4 -0
@@ 213,6 213,10 @@ sys::Message_t EventManager::DataReceivedHandler(sys::DataMessage *msgl, sys::Re
            sys::Bus::SendMulticast(notification, sys::BusChannels::ServiceEvtmgrNotifications, this);
        }
    }
    else if (msgl->messageType == MessageType::EVMRingIndicator) {
        sys::SystemManager::ResumeSystem(this);
    }

    if (handled)
        return std::make_shared<sys::ResponseMessage>();
    else

M module-services/service-evtmgr/WorkerEvent.cpp => module-services/service-evtmgr/WorkerEvent.cpp +5 -0
@@ 163,6 163,11 @@ bool WorkerEvent::handleMessage(uint32_t queueID)
            LOG_DEBUG("SIM state change: %d", static_cast<int>(pinstate));
            bsp::cellular::sim::hotswap_trigger();
        }

        if (notification == bsp::cellular::ringIndicatorPin) {
            auto message = std::make_shared<sevm::StatusStateMessage>(MessageType::EVMRingIndicator);
            sys::Bus::SendUnicast(message, "EventManager", this->service);
        }
    }

    return true;

M source/MessageType.hpp => source/MessageType.hpp +1 -0
@@ 178,6 178,7 @@ enum class MessageType
    // cellular messages
    EVMGetBoard,
    EVMModemStatus,
    EVMRingIndicator,

    // bluetooth messages
    BluetoothRequest,