TestController.php
6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
namespace console\controllers;
/**
* Created by PhpStorm.
* User: scott
* Date: 8/15/18
* Time: 11:32 AM
*/
use app\api\helpers\Aes;
use common\exts\Http;
use domain\device\Device;
use GuzzleHttp\Psr7;
use yii\console\Controller;
use GuzzleHttp\Psr7\Request;
use function chr;
use yii\helpers\ArrayHelper;
class TestController extends Controller
{
public function actionGen()
{
echo sprintf('%04x', 1);
}
public function actionCheckSign()
{
$str = '{"manufacture":"0001","device_id":"4705BF36C376","project":"0001","model":"0001","production":"0001","timestamp":"1500000000","sign":"f16b3f969714a400e155e04e0ea29938"}';
$arr = json_decode($str, true);
//md5($arr[''])
}
public function actionDeviceAuth()
{
//$url = 'http://kingb:8012/app-api/web/authDevice';
$url = 'http://47.107.95.101/app-api/web/authDevice';
$manufactureNo = '0003';
$device_id = '000000010108';
$projectNo = '0003';
$modelNo = '0002';
$productionNo = '0004';
$timestamp = time();
$salt = 13456;
$sign = md5($manufactureNo. $projectNo. $modelNo . $productionNo . $timestamp .$device_id. $salt);
$params = [
'manufacture' => $manufactureNo,
'device_id' => $device_id,
'project' => $projectNo,
'model' => $modelNo,
'production' => $productionNo,
'timestamp' => $timestamp,
'sign' => $sign,
];
$params = json_encode($params);
//$params = '{"manufacture":"0002","device_id":"6705BF36C37F","project":"0002","model":"0003","production":"0002","timestamp":"1500000000","sign":"2b67361ba972020496f1a1b3df388499"}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
public function actionUpgrade()
{
$url = 'http://kingb:8012/app-api/web/reportDeviceVersion';
$params = [
'barcode' => '00001',
'device_id' => 'DEVICE001',
'software_version' => 'V1.0.1',
'hardware_version' => 'V1.0.2',
'timestamp' => 1500000000
];
$postResult = Http::POST($url, $params);
echo $postResult;
}
public function actionAec()
{
$aes = new Aes('12345678');
$encrypted = $aes->encrypt('this is en AES testing');
echo '要加密的字符串:this is en AES testing<br>加密后的字符串:'. $encrypted. '<hr>';
$decrypted = $aes->decrypt($encrypted);
echo '要解密的字符串:'. $encrypted, '<br>解密后的字符串:'. $decrypted;
}
public function actionDeviceSt()
{
$url = 'http://kingb:8012/app-api/web/reportDeviceVersion';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DEVICE003',
'software_version' => 'V1.0.1',
'hardware_version' => 'V1.0.2',
'timestamp' => 1500000000
];
$postResult = Http::POST($url, json_encode($params));
echo $postResult;
}
public function actionCheckAppUpdate()
{
//actionCheckAppVersion
$url = 'http://47.107.95.101/app-api/web/checkAppVersion';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DEVICE000001',
'current_version' => 'V1.0.1',
'package_name' => 'V1.0.2安装包',
];
//$params = json_decode($params);
$params = '{"barcode":"0001000100010001","device_id":"DGDEVBICEID00001","package_name":"com.kingboard.settings","current_version":"1"}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
public function actionCheckOtaUpdate()
{
//actionCheckAppVersion
$url = 'http://47.107.95.101/app-api/web/checkOtaVersion';
//$url = 'http://kingb:8012/app-api/web/checkOtaVersion';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DGDEVBICEID00001',
'software_version' => 'V1.0.1',
'hardware_version' => 'V1.0.1',
];
$params = json_encode($params);
$params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","software_version":"V1.00.1A.20191002","hardware_version":""}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
//{"barcode":"0001000100010001","device_id":"DEVICEID00001","current_version":"V1.00.1A.20191022","target_version":"V1.00.1A.20191022","status":5,"timestamp":"1572759793"}
public function actionReportOtaEvent()
{
//actionCheckAppVersion
$url = 'http://47.107.95.101/app-api/web/reportOtaUpgradeEvent';
//$url = 'http://kingb:8012/app-api/web/reportOtaUpgradeEvent';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DGDEVBICEID00001',
'software_version' => 'V1.0.1',
'hardware_version' => 'V1.0.1',
];
$params = json_encode($params);
$params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","current_version":"V1.00.1A.20191022", "target_version":"V1.00.1A.20191022","status":5,"timestamp":"1572759793"}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
public function actionReportAppEvent()
{
//actionCheckAppVersion
//$url = 'http://47.107.95.101/app-api/web/reportAppUpgradeEvent';
$url = 'http://kingb:8012/app-api/web/reportAppUpgradeEvent';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DGDEVBICEID00001',
'current_version' => 'V1.0.1',
'target_version' => 'V1.0.1',
'package_name' => 'com.app.king.dd',
"status" => 0,
"error_code" => '',
"timestamp" => 1572767677
];
$params = json_encode($params);
//$params = '{"barcode":"0001000100010001","device_id":"DGDEVBICEID00001","current_version":"1","target_version":"2","status":"5","error_code":"0","timestamp":"1572767677"}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
}