paginate(); $pages = $data_list->render(); $this->assign('data_list', $data_list); $this->assign('pages', $pages); //所有的服务类型 $SetType=[ 1=>"读取模块信息", 2=>"读取参数", 3=>"设置IOT平台IP地址", 4=>"设置参数", 5=>"复位模块", 6=>"配置下行波特率", 7=>"读取下行波特率配置", 8=>"设置DTU自动采集指令", 9=>"读取DTU自动采集指令", 10=>"设置APN", 11=>"读取APN设置", 12=>"AT指令", /* [1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"], [7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"], [12,"AT指令"]*/ ]; $this->assign('SetType',$SetType); return $this->fetch(); } //下发命令 public function add(){ if ($this->request->isPost()) { $data=$_POST; //调用电信接口 $token=json_decode(gettoken(),true); $sendata=[ "appId"=>$this->appId, "deviceId"=>$data['deviceId'],// c448d5e3-2ec5-4e42-99d7-0ad27668614f 137effbe-4980-4719-a768-0ae301fc5000 "command"=>[ "serviceId"=>"SomkNotifiction", "method"=>"REPORT", ], "callbackUrl"=>"http://www.jd-ioe.com:80/ytapi/admin/Manage/status", ]; $header=[ "Content-Type:application/json", "app_key:".$this->appId, "Authorization:Bearer ".$token["accessToken"] ]; $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header); var_dump($rescurl); if($rescurl[0]==201){//成功 $res1=json_decode($rescurl[1],true); var_dump($res1); }else{//失败 // $res2=json_decode($res1[1],true); return $this->error($rescurl[1]); } //将请求的结果存入managelog中 $list=array(); $list['commandId']=$res1['commandId']; $list['deviceId']=$res1['deviceId']; $list['status']=$res1['status']; $list['command']= json_encode($res1['command'],320) ; $list['IMEI']=$data['IMEI']; $list['HexStr']=""; $list['settype']=""; $list['addtime']= date('Y-m-d H:i:s'); $res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表 if($res) { return $this->success('添加成功','index'); }else{ return $this->error("添加失败,请稍后再试"); } } if($this->request->isGet()){ $deviceId=input('deviceId'); $IMEI=input('IMEI'); //所有的服务类型 $SetType=[ [1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"], [7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"], [12,"AT指令"] ]; $this->assign('SetType',$SetType); $this->assign('deviceId',$deviceId); $this->assign('IMEI', $IMEI); return $this->fetch(); } } public function status(){ $data=input(''); if(is_array($data)){ $getdata= json_encode($data,320); $getdata=json_decode($getdata,true);//转成数组 $list['type']=1; }else{ $getdata=$data; $getdata=json_decode($getdata,true);//转成数组 $list['type']=2; } $list=array(); $list['deviceId']=$getdata['deviceId']; $list['commandId']=$getdata['commandId']; $list['resultCode']=$getdata['result']['resultCode']; $list['result']= json_encode($getdata['result'],320) ; $list['addtime']= date('Y-m-d H:i:s'); $res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表 echo 111; } public function delete(){ echo 111; } }