123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace App\Servers;
- use App\Maps\VideoMap;
- class NewBikeReportingServer extends BaseServer
- {
- public function main($body)
- {
- $data = $this->decode($body);
- self::log($data, 'NewBikeReportingServer', self::$LOG_MAJOR);
- return $this->response(self::RESPONSE_SUCCESS, VideoMap::VIDEO_FIND_BIKE);
- }
- const RESPONSE_SUCCESS = '00';
- const RESPONSE_FAI = '01';
-
- protected function response($response_status = self::RESPONSE_SUCCESS, $video_cmd = false)
- {
- $body = [
- $response_status,
- '00' . $video_cmd
- ];
- $body = str_split(implode('', $body), 2);
- return $body;
- }
-
- private function decode($body)
- {
- $i = 0;
-
- $time = self::stitching($body, $i, 4);
- $i += 4;
-
- $result = self::stitching($body, $i, 1);
- $i += 1;
-
- $voice_cmd = self::stitching($body, $i, 2);
- $i += 2;
-
- $msg_id = self::stitching($body, $i);
- $time = $this->decodeTime($time);
- return [
- 'time' => $time,
- 'result' => $result,
- 'voice_cmd' => $voice_cmd,
- 'msg_id' => $msg_id,
- ];
- }
- }
|