广告
返回顶部
首页 > 资讯 > 服务器 >PHP实现轻量级WEB服务器接收HTTP提交的RFID刷卡信息并回应驱动读卡器显示播报语音
  • 285
分享到

PHP实现轻量级WEB服务器接收HTTP提交的RFID刷卡信息并回应驱动读卡器显示播报语音

PHPHTTPPHPWEBPHPServerPHPRequestPHPResponse 2023-09-02 09:09:29 285人浏览 独家记忆
摘要

 本示例使用的读卡器:RFID网络WIFI无线TCP/UDP/HTTP可编程二次开发读卡器POE供电语音-淘宝网 (taobao.com)

 本示例使用的读卡器:RFID网络WIFI无线TCP/UDP/HTTP可编程二次开发读卡器POE供电语音-淘宝网 (taobao.com)

 0) {          //可以直接使用JSON来解板,此处统一替换成字符串处理                $request = str_replace("{", "", $request);                $request = str_replace("}", "", $request);                $request = str_replace("\"", "", $request);                $request = str_replace(":", "=", $request);                $request = str_replace(",", "&", $request);            }        }        $Fields = explode("&", $request);        $conuts = count($Fields);        for ($p = 0; $p < $conuts; $p++) {            $para = explode("=", $Fields[$p]);            switch ($para[0]) {                case "info":                    $info = $para[1];                    break;                case "jihao":                    $jihao = $para[1];                    break;                case "cardtype":                    $cardtype = $para[1];                    $typenum = hexdec($cardtype) % 16;                  //typenum=1 ID卡,2 HID卡,3 T5557卡,4 EM4305卡,5 IC卡,6 二代身份证,7 是15693卡,IClass"                    $pushortake = intval(hexdec($cardtype) / 128);  //pushortake=0 表示读卡,>0表示卡离开感应区                    break;                case "card":                    $card = $para[1];                    break;                case "data":                    $data = $para[1];                    break;                case "dn":                    $dn = $para[1];                    break;                case "status":                    $status = $para[1];                    break;            }        }        if(strlen($info)>0 and strlen($info)>0) {            if ($pushortake == 0)   //播报的中文语音,[v8]表示语音大小,取值v1 到 v16, TTS中文语音要转换编码                $ChineseVoice = "[v8]" . GetChineseCode("读取卡号[n1]") . $card;            else                $ChineseVoice = "[v8]" . GetChineseCode("卡号[n1]") . $card . GetChineseCode("离开感应区");            //此处可加入业务对数据库的查询、删除、增加、修改等操作,结果以文字、语音信息回应            $DisplayStr = "{" . GetChineseCode("卡号") . ":}";  //显示的文字,{}内文字可以高亮显示,中文必须转换编码,英文字符、数字等不需要转换            $DisplayStr = $DisplayStr . substr($card . "        ", 0, 12);            $DisplayStr = $DisplayStr . substr(date('Y-m-d H:i:s', time()), 2, 17);            //Response=1是固定的回应头信息+接收的包序号+显示文字+显示延时秒数+蜂鸣响声代码+TTS语音            $ResponseStr = "Response=1," . $info . "," . $DisplayStr . ",20,1," . $ChineseVoice;        }        return $ResponseStr;    }    catch (Exception $e1) {        echo "Request ERR:".$e1."\n";    }}//获取中文汉字GB2312编码,显示中文、TTS中文语音必须转换编码function GetChineseCode($inputstr){    if(mb_detect_encoding($inputstr, 'UTF-8', true) === true)        $gbkstr=iconv("UTF-8","GB2312",$inputstr);      //中文必段强制使用GB2312编码格式    else        $gbkstr=$inputstr;    $strlens=strlen($gbkstr);    $hexcode="";    for($i=0;$i<$strlens;$i++){        if($i % 2 ==0) {            $hexcode = $hexcode . "\\x";        }        $byte = ord($gbkstr[$i]);        $b=substr('00'.dechex($byte ),-2);        $hexcode=$hexcode.$b;    }    return $hexcode;}

来源地址:https://blog.csdn.net/zhangjin7422/article/details/132320048

--结束END--

本文标题: PHP实现轻量级WEB服务器接收HTTP提交的RFID刷卡信息并回应驱动读卡器显示播报语音

本文链接: https://www.lsjlt.com/news/390495.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作