# Modem事件上报开发指导
- [场景介绍](#section337mcpsimp)
- [接口说明](#section340mcpsimp)
- [开发步骤](#section183291958165215)
- [调测验证(可选)](#section405mcpsimp)
## 场景介绍
Modem事件上报是指在Modem设备节点读取线程循环读取到Modem主动上报的消息后,将读取到的消息解析为对应的Modem上报事件,然后上报给RIL Adapter。
## 接口说明
Modem事件上报接口。
**表 1** Modem事件上报接口功能介绍
接口名
|
描述
|
static void OnNotificationResponse(const char *s, const char *sms_pdu)
|
该接口对Modem上报的事件进行分发处理
|
## 开发步骤
在Modem设备节点读取线程s\_tid\_read里调用OnNotificationResponse\(\)解析具体的Modem上报事件,并调用OnRadioEventNotify\(\)把解析得到的事件上报给RIL Adapter。
```
bool IsCallStatusUpdated(const char *s)
{
return (StrBeginWith(s, "+CRING:")
|| StrBeginWith(s, "RING")
|| StrBeginWith(s, "NO CARRIER")
|| StrBeginWith(s, "+CCWA"));
}
bool IsSetRadioPower(const char *s)
{
return StrBeginWith(s, "+CFUN: 0");
}
static void OnNotificationResponse(const char *s, const char *sms_pdu)
{
if (IsCallStatusUpdated(s)) {
OnRadioEventNotify(HNOTI_CALL_STATUS, NULL, 0);
} else if (IsSetRadioPower(s)) {
SetRadioState(RADIO_OFF);
}
……
}
```
## 调测验证(可选)
1. 用hdc工具连接调试设备,把编译生成的libvendor.z.so库文件通过hdc file send推到/system/lib/目录下。
2. 执行hdc shell sync, hdc shell reboot重启设备。
3. hdc shell后输入hilog命令,查看OnNotificationResponse\(\)是否正确执行完成,根据日志信息判断是否成功。