...
|
...
|
@@ -166,19 +166,19 @@ class AesController extends HomeBaseController{ |
|
|
* @url /portal/Aes/decryption
|
|
|
* @method GET
|
|
|
*
|
|
|
* @param name:MACAddress type:String require:1 default:无 other: desc:设备MAC地址
|
|
|
* @param name:name type:String require:1 default:无 other: desc:设备名称
|
|
|
* @param name:key type:String require:1 default:无 other: desc:设备返回状态(未加密)
|
|
|
* @param name:type type:String require:1 default:无 other:1开锁返回指令,2状态返回指令 desc:命令类型
|
|
|
*
|
|
|
* @return code:1锁已开,0位锁已关,2为数据异常
|
|
|
*/
|
|
|
public function state($MACAddress,$key,$type){
|
|
|
public function state($name,$key,$type){
|
|
|
if ($type==1){
|
|
|
if($key[0]=='0xff' && $key[4]=='0xef'){
|
|
|
if ($key[3]=='0x01'){
|
|
|
//修改数据库设备状态
|
|
|
try{
|
|
|
Db::name('equipment')->where('mac_address',$MACAddress)->update(['use'=>1]);
|
|
|
Db::name('equipment')->where('name',$name)->update(['use'=>1]);
|
|
|
}catch (\Exception $exception){
|
|
|
$this->apiResponse(301,'数据库状态更改失败,错误信息:'.$exception->getMessage());
|
|
|
}
|
...
|
...
|
@@ -192,7 +192,7 @@ class AesController extends HomeBaseController{ |
|
|
}else if($type==2){
|
|
|
if($key[0]=='0xff' && $key[7]=='0xef'){
|
|
|
if ($key[5]=='0x01'){
|
|
|
Db::name('equipment')->where('mac_address',$MACAddress)->update(['electricity'=>0]);
|
|
|
Db::name('equipment')->where('name',$name)->update(['electricity'=>0]);
|
|
|
}
|
|
|
if ($key[6]=='0x01'){
|
|
|
//修改数据库设备状态
|
...
|
...
|
@@ -200,7 +200,7 @@ class AesController extends HomeBaseController{ |
|
|
}else if($key[6]=='0x00'){
|
|
|
//修改数据库设备状态
|
|
|
try{
|
|
|
Db::name('equipment')->where('mac_address',$MACAddress)->update(['use'=>0]);
|
|
|
Db::name('equipment')->where('name',$name)->update(['use'=>0]);
|
|
|
}catch (\Exception $exception){
|
|
|
$this->apiResponse(301,'数据库状态更改失败,错误信息:'.$exception->getMessage());
|
|
|
}
|
...
|
...
|
|