瀏覽代碼

Support MEIDs in processor

Closes #28
tags/SensorLogger/0.2.0
Chris Smith 14 年之前
父節點
當前提交
56ecedd4cf
共有 2 個檔案被更改,包括 17 行新增1 行删除
  1. 10
    0
      website/common.php
  2. 7
    1
      website/process.php

+ 10
- 0
website/common.php 查看文件

@@ -9,6 +9,16 @@
9 9
 	return mysql_real_escape_string($sql);
10 10
  }
11 11
 
12
+ function bchexdec($hex) {
13
+	$len = strlen($hex);
14
+
15
+	for ($i = 1; $i <= $len; $i++) {
16
+		$dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i))));
17
+	}
18
+
19
+	return $dec;
20
+ }
21
+
12 22
  function Oblong($message) {
13 23
         $key = trim(file_get_contents('/home/chris/oblong.key'));
14 24
         $chan = '#MD87.highvol';

+ 7
- 1
website/process.php 查看文件

@@ -2,7 +2,7 @@
2 2
 
3 3
  require_once('common.php');
4 4
 
5
- define('VERSION', 24);
5
+ define('VERSION', 25);
6 6
 
7 7
  function processSensorLogger($records = true) {
8 8
   $sql = $records ? 'SELECT record_id, record_ip, record_headers, record_data FROM unprocessed'
@@ -28,6 +28,12 @@
28 28
    }
29 29
 
30 30
    $imei = isset($headers['IMEI']) ? $headers['IMEI'] : '';
31
+
32
+   if (!ctype_digit($imei) && !empty($imei)) {
33
+    // It's probably an MEID not an IMEI number
34
+    $imei = bchexdec($headers['IMEI']);
35
+   }
36
+
31 37
    $activity = isset($headers['ACTIVITY']) ? $headers['ACTIVITY'] : '';
32 38
    $version = isset($headers['VERSION']) ? $headers['VERSION'] : '';
33 39
   

Loading…
取消
儲存