You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.7 KiB
PHP

<?php
$keyMapper = array('i1服务器' => 'cma', '心跳间隔' => 'heartbeatDuration', 'i1' => 'i1Version', 'yw' => 'maintainVersion', '电池' => 'battery', '系统重启' => 'rebootTimes',
'重启' => 'rebootTimes', 'i1重启' => 'i1RebootTimes', 'i1启' => 'i1RebootTimes', '收' => 'recv', '拍' => 'photoTimes', '成' => 'success', '败' => 'failure',
'传' => 'uploads', '心跳累计' => 'numberOfHb', '心跳' => 'numberOfHb', '网络异常' => 'networkError', '网络' => 'networkError', '信号1' => 'signature1', '信号2' => 'signature2',
'卡1' => 'simcard1', '卡2' => 'simcard2', 'mcu' => 'mcu', 'ai' => 'aiVersion', 'cam' => 'cameraService', '主板温度' => 'mainBoardTmp', '电池温度' => 'batteryTmp');
function parseCmd($content)
{
global $keyMapper;
$msgs = array();
// "安徽欣影ds2-2x/4x,yw:0829_4.2.502, i1:ahxy_0829_4.2.502, cam:4.2.1, ai:1.1.0_1, i1服务器:47.96.238.157:6891 ,心跳间隔:1 ,
// 电池:6.3V\/0.2V\/87% ,系统重启:1 ,i1重启:13 ,收:10:52 ,拍:48\/44 ,成:44 ,败:0 ,传:44 ,心跳累计:142 ,网络异常:139 ,信号1:4\/99 ,信号2:4\/99 ,卡1:898604F5122380159566,卡2: ,mcu:MTK_MCU_V3.2.5 Aug 9 2023"
$items = explode(',', $content);
foreach ($items as $item)
{
$pos = strpos($item, ':');
if ($pos === false)
{
continue;
}
$key = trim(substr($item, 0, $pos));
if ($key == 'i1' && strpos($item, ':', $pos + 1) !== false)
{
$key = 'cma';
}
else if (isset($keyMapper[$key]))
{
$key = $keyMapper[$key];
}
$msgs[$key] = trim(substr($item, $pos + 1));
}
return $msgs;
}