<?php /** * Created by PhpStorm. * User: jianlinz * Date: 2015/7/3 * Time: 11:33 */ include_once "config.php"; include_once "wechat.class.php"; include_once "wx_iot.class.php"; header("Content-type:text/html;charset=utf-8"); $db = new class_mysql_db(); $result = $db->db_EmcAccumulationInfo_save("aaa", "bbb"); ?> $a = '2015-05-19'; $b = strtotime($a); $c = date("ymd", $b); $tmp = 1455629400; $res = $db->db_EmcDataInfo_save("aaa", "bbb", $tmp, 155, 42433); $tmp = 1435629400; $res = $db->db_EmcDataInfo_save("aaa", "bbb", $tmp, 155, 42433); $res = $db->db_EmcDataInfo_delete_3monold("aaa", "bbb", 80); $t1 = date("ymd"); $t2 = date_create('2009-10-13');
$wxObj0 = new class_wechat_sdk($wx_options); $deviceid = $_POST["subscribe_deviceid"]; $openid = $_POST["subscribe_openid"]; echo "Input Device ID = " . $deviceid . "<br>"; echo "Input User ID = " . $openid . "<br>"; //Step1:刷新Token echo "<br><H2>微信硬件工作环境即将开始......<br></H2>"; $wxObj = new class_wx_IOT_sdk(WX_APPID, WX_APPSECRET); //实验Token是否已经被刷新 echo "<br>测试最新刷新的Token=<br>" . "{$wxObj->access_token}" . "<br>"; // Step2 设备状态查询 echo "<br>查询设备状态 <br>"; var_dump($wxObj->getstat_qrcodebyDeviceid($deviceid)); // Step3 用户绑定设备查询 echo "<br>查询用户绑定状态 <br>"; $result = $wxObj->getstat_qrcodebyOpenId($openid); var_dump($result); echo "<br>Device_List = <br>"; $devicetype = $result["device_list"][0]["device_type"]; var_dump($result["device_list"]); // Step4 微信云强制绑定设备 $result = $wxObj->compel_bind($deviceid, $openid); echo "<br>微信云强制绑定设备结果 <br>"; var_dump($result); // Step5 第三方数据库绑定 $wxDbObj = new class_mysql_db(); echo "<br>第三方云数据库查询设备结果 <br>"; var_dump($wxDbObj->db_BleBoundInfo_query($openid)); echo "<br>第三方云数据库强绑设备结果 <br>"; var_dump($wxDbObj->db_BleBoundInfo_save($openid, $deviceid, $openid, $devicetype)); //end of tool_main();
include_once "config.php"; include_once "wechat.class.php"; header("Content-type:text/html;charset=utf-8"); //如果运行在本地,以下地址存放二维码图片 static $imagePath = "D:/work/image/"; $wx_options = array('token' => WX_TOKEN, 'encodingaeskey' => WX_ENCODINGAESKEY, 'appid' => WX_APPID, 'appsecret' => WX_APPSECRET, 'debug' => WX_DEBUG, 'logcallback' => WX_LOGCALLBACK); $mac = $_POST["mac_address"]; echo "Input MAC ADDRESS = " . $mac . "<br>"; $wxObj = new class_wechat_sdk($wx_options); //Step1:刷新Token echo "<br><H2>微信硬件工作环境即将开始......<br></H2>"; $wxDevObj = new class_wx_IOT_sdk(WX_APPID, WX_APPSECRET); //实验Token是否已经被刷新 echo "<br>测试最新刷新的Token=<br>" . "{$wxDevObj->access_token}" . "<br>"; //Step2: 从数据库中取得有效的DEVICE_ID $wxDbObj = new class_mysql_db(); $result = $wxDbObj->db_DeviceQrcode_inqury(); if ($result == null) { echo "<br>没有空的MAC地址了,请联系管理员! <br>"; } else { $deviceIdBLE = $result["deviceid"]; $qrcode = $result["qrcode"]; var_dump($deviceIdBLE); var_dump($qrcode); //验证二维码 $qrcode_result = $wxDevObj->verify_qrcode($qrcode); echo "<br>二维码验证的结果<br>"; var_dump($qrcode_result); $deviceTypeBLE = $qrcode_result["device_type"]; //将二维码使用图像方式显示出来 var_dump($wxDevObj->create_qrcodeDisplay($qrcode));
public function L3_device_text_process($content, $fromuser, $deviceid) { //反系列化处理 $rev = $this->L3_msgParse($content); //进入不同数据内容处理阶段 $cmdid = ""; $resp = $rev["body"]; switch ($rev["head"]["head_cmdid"]) { case "CMDID_EMC_DATA_REQ": //取得数据结构体 $emc_value = hexdec(substr($rev["body"], 0, 4)) & 0xffff; $emc_time = hexdec(substr($rev["body"], 0, 4)) & 0xffff; //存入数据库中 $wxDbObj = new class_mysql_db(); $wxDbObj->db_EmcDataInfo_save($fromuser, $deviceid, $emc_time, $emc_value, 0); //GPS not yet exist today, could be add in future. $wxDbObj->db_EmcDataInfo_delete_3monold($fromuser, $deviceid, 90); //remove 90 days old data. $wxDbObj->db_EmcAccumulationInfo_save($fromuser, $deviceid); //累计值计算,如果不是初次接收数据,而且日期没有改变,则该过程将非常快 $cmdid = CMDID_EMC_DATA_RESP; $resp = ""; break; case "CMDID_EMC_DATA_REV": //不需要再回复消息,再考虑设计下这个工作流程设计 $cmdid = CMDID_SEND_TEXT_RESP; break; case "CMDID_OCH_DATA_REQ": $cmdid = CMDID_OCH_DATA_RESP; break; default: $cmdid = CMDID_SEND_TEXT_RESP; break; } //再进入真正的处理阶段, 系列化 $result = $this->L3_msgBuild($cmdid, $resp, $rev["head"]["head_seq"]); return $result; }