zte's code,first commit
Change-Id: I9a04da59e459a9bc0d67f101f700d9d7dc8d681b
diff --git a/ap/app/zte_amt/2k_8000.h b/ap/app/zte_amt/2k_8000.h
new file mode 100644
index 0000000..57feb3c
--- /dev/null
+++ b/ap/app/zte_amt/2k_8000.h
@@ -0,0 +1,387 @@
+
+static char buffer2k8000[]=
+{
+0x00, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x82, 0x5A, 0x01, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7F, 0xA5,
+0x00, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x82, 0x5A, 0xFF, 0xFF, 0x7E, 0xA5, 0x00, 0x80, 0x7E, 0xA5,
+0x01, 0x00, 0x81, 0x5A, 0xFF, 0x7F, 0x81, 0x5A, 0x00, 0x00, 0x7F, 0xA5, 0x01, 0x80, 0x7E, 0xA5,
+0x01, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x81, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7D, 0xA5,
+0x00, 0x00, 0x82, 0x5A, 0xFE, 0x7F, 0x82, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7F, 0xA5,
+0xFF, 0xFF, 0x82, 0x5A, 0xFF, 0x7F, 0x82, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7E, 0xA5,
+0x00, 0x00, 0x81, 0x5A, 0xFF, 0x7F, 0x81, 0x5A, 0x00, 0x00, 0x7F, 0xA5, 0x01, 0x80, 0x7E, 0xA5,
+0x00, 0x00, 0x82, 0x5A, 0xFE, 0x7F, 0x82, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7E, 0xA5,
+0xFF, 0xFF, 0x81, 0x5A, 0xFF, 0x7F, 0x81, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7E, 0xA5,
+0x00, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x82, 0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x7F, 0x82, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x02, 0x80, 0x7E, 0xA5,
+0x00, 0x00, 0x81, 0x5A, 0xFE, 0x7F, 0x82, 0x5A, 0xFF, 0xFF, 0x7E, 0xA5, 0x01, 0x80, 0x7E, 0xA5,
+0x00, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x82, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7E, 0xA5,
+0x00, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x82, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7E, 0xA5,
+0x01, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x82, 0x5A, 0x01, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7F, 0xA5,
+0x00, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x82, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7F, 0xA5,
+0x00, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x81, 0x5A, 0x00, 0x00, 0x7E, 0xA5, 0x00, 0x80, 0x7E, 0xA5,
+0x01, 0x00, 0x82, 0x5A, 0xFF, 0x7F, 0x82, 0x5A, 0x01, 0x00, 0x7E, 0xA5, 0x01, 0x80, 0x7F, 0xA5,
+};
+#if 0
+{
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40, 0xFF, 0xFF, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x01, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xD9, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x27, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x27, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x27, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x25, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDB, 0xBF, 0x00, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x01, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDB, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0xFF, 0xFF, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x25, 0x40, 0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x27, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0xFF, 0xFF, 0xD9, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x01, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x01, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0xFF, 0xFF, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0xFF, 0xFF, 0xDA, 0xBF, 0xFF, 0xFF, 0x26, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x01, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x01, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x27, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xD9, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x27, 0x40, 0x00, 0x00, 0xDA, 0xBF, 0x00, 0x00, 0x26, 0x40,
+};
+#endif
+
diff --git a/ap/app/zte_amt/Makefile b/ap/app/zte_amt/Makefile
new file mode 100755
index 0000000..fbca610
--- /dev/null
+++ b/ap/app/zte_amt/Makefile
@@ -0,0 +1,62 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(zte_app_mak)
+
+##############USER COMIZE BEGIN################
+EXEC = zte_amt
+C_SOURCE = $(wildcard ./*.c)
+OBJS = $(subst .c,.o,$(C_SOURCE))
+
+CFLAGS += -I$(zte_app_path)/include
+CFLAGS += -I$(zte_lib_path)/libnvram
+CFLAGS += -I$(zte_lib_path)/libsqlite
+CFLAGS += -I$(zte_lib_path)/libnetapi
+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/pal/dm
+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/zCore/gui
+CFLAGS += -g
+CFLAGS += -Wextra -Wall
+#CFLAGS += -I../../../linux-3.4.x
+CFLAGS += -I$(LINUX_DIR)/include
+CFLAGS += -I/$(TOPDIR)/pub/project/$(CHIP_NAME)/include/nv
+CFLAGS += -I$(zte_lib_path)/libamt
+ifeq ($(USE_VOICE_SUPPORT),yes)
+CFLAGS += -I$(zte_lib_path)/libtinyalsa/include
+endif
+LDLIBS = -lpthread -lm
+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram
+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap
+LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+LDLIBS += -lcpnv -L$(zte_lib_path)/libcpnv
+LDLIBS += -lamt -L$(zte_lib_path)/libamt
+ifeq ($(USE_VOICE_SUPPORT),yes)
+LDLIBS += -ltinyalsa -L$(zte_lib_path)/libtinyalsa
+endif
+
+ifeq ($(USE_VOICE_SUPPORT),yes)
+CFLAGS += -D_USE_VOICE_SUPPORT
+endif
+
+#wifi
+ifeq ($(CONFIG_WIFI_MODULE),ssv6x5x)
+CFLAGS += -D__SSV_6X5X_CHIP__
+else ifeq ($(CONFIG_WIFI_MODULE),aic8800)
+CFLAGS += -D__AIC_8800DW_CHIP__
+endif
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
diff --git a/ap/app/zte_amt/amt.c b/ap/app/zte_amt/amt.c
new file mode 100755
index 0000000..37ebef2
--- /dev/null
+++ b/ap/app/zte_amt/amt.c
@@ -0,0 +1,1919 @@
+/**
+ *
+ * @file amt.c
+ * @brief
+ * This file is part of FTM.
+ * AMT´úÀíÓ¦Óòã
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2015/04/28 1.0 lu.xieji Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/msg.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "linux/rpmsg_zx29.h"
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <linux/netlink.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <signal.h>
+#include <errno.h>
+#include "port_com.h"
+#include "amt.h"
+#include "os_type_def.h"
+#include "softap_api.h"
+#include "other_msg.h"
+#include "message.h"
+#include "amt_agent_devicetest.h"
+#include "kwatch_msg.h"
+#include "amtnv.h"
+#include "libcpnv.h"
+#include <sys/prctl.h>
+#include "sys/wait.h"
+#include "ref_nv_def.h"
+#include "nv_api.h"
+
+
+
+
+/**
+ * Íⲿº¯ÊýÒýÓÃ
+ */
+extern int Amt_Wifi_Init(void);
+extern int Amt_Wifi_ProcessMsg(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len);
+extern int Amt_Gps_ProcessMsg(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len);
+extern int Amt_DeviceTest_ProcessMsg(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len);
+extern int Amt_Process_Gps_Rsp(MSG_BUF *msg,unsigned int msg_id);
+extern int Amt_FuncTest_ProcessMsg(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len);
+extern int wifi_ioctl_handle(int cmd);
+
+
+/**
+ * È«¾Ö±äÁ¿ÉùÃ÷
+ */
+static int g_amt_fd_cp = -1;
+static int g_amt_fd_usb = -1;
+static int g_amt_fd_usb_hotplug = -1;
+static int g_amt_fd_socket_client = -1;
+static int g_amt_fd_socket_server = -1;
+static fd_set g_amt_fdsread;
+static int g_amt_fd_max = 0;
+static volatile int *g_amt_fd_current = NULL;
+static int g_amt_iMsgHandle = 0;
+unsigned int g_amt_at_mode = 0;
+
+
+
+/**
+ * @brief AMTÏûÏ¢·¢Ë͸øPC
+ * @param[in] fd ÎļþÃèÊö·û
+ * @param[in] buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] buf_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ·µ»Ø·¢Ë͵ÄÊý¾Ý³¤¶È
+ * @note
+ * @see
+ */
+static int Amt_SendData(int fd, unsigned char* buf, unsigned int buf_len)
+{
+ int write_len = PortSend(fd, (unsigned char*)&buf_len, sizeof(unsigned int), WAIT_ALL);
+
+ //if (write_len > 0)
+ {
+ write_len = PortSend(fd, buf, buf_len, WAIT_ALL);
+
+ if (write_len <= 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: PortSend 'data' to device(fd = %d): write_len(%d) is wrong.\n", __FUNCTION__, fd, write_len);
+ }
+ }
+ /*
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: PortSend 'length' to device(fd = %d): write_len(%d) is wrong.\n", __FUNCTION__, fd, write_len);
+ }
+ */
+
+ return write_len;
+}
+
+/**
+ * @brief AMTÏûÏ¢·¢ËÍ
+ * @param[in] fd ÎļþÃèÊö·û
+ * @param[in] buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] buf_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ·µ»Ø·¢Ë͵ÄÊý¾Ý³¤¶È
+ * @note
+ * @see
+ */
+static int Amt_SendDataToAmtagent(int fd, unsigned char* buf, unsigned int buf_len)
+{
+ int write_len = PortSend(fd, buf, buf_len, NO_WAIT);
+
+ if (write_len <= 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: PortSend 'data' to device(fd = %d): write_len(%d) is wrong.\n", __FUNCTION__, fd, write_len);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: PortSend 'data' to device(fd = %d): write_len(%d),buf_len(%d) \n", __FUNCTION__, fd, write_len,buf_len);
+ }
+ return write_len;
+}
+
+
+/**
+ * @brief AMTÏûÏ¢½ÓÊÕ
+ * @param[in] fd ÎļþÃèÊö·û
+ * @param[in] buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] buf_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ·µ»Ø½ÓÊÕµ½µÄÊý¾Ý³¤¶È
+ * @note
+ * @see
+ */
+static int Amt_ReceiveData(int fd, unsigned char* buf, unsigned int buf_len)
+{
+ int read_len = PortRecv(fd, buf, sizeof(unsigned int), WAIT_ALL);
+
+ if (read_len > 0)
+ {
+ unsigned int packet_len = *((unsigned int *)buf);
+ if (packet_len > 0 && packet_len <= buf_len)
+ {
+ read_len = PortRecv(fd, buf, packet_len, WAIT_ALL);
+
+ if (read_len <= 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: PortRecv 'data' from device(fd = %d): read_len(%d) is wrong.\n", __FUNCTION__, fd, read_len);
+ }
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: fd = %d, packet_len(%d) is wrong.\n", __FUNCTION__, fd, packet_len);
+ read_len = -1;
+ assert(0);
+ }
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: PortRecv 'length' from device(fd = %d): read_len(%d) is wrong.\n", __FUNCTION__, fd, read_len);
+ }
+
+ return read_len;
+}
+
+#if 0
+static void str_to_int( int *data, char *str )
+{
+ int Lc = 0;
+ int Len = 0;
+ char *Begb = NULL;
+ char *Endb = NULL;
+ char *ptr = NULL;
+ char s1[100] = "";
+ char s2[50] = "";
+ memset(s1, 0, sizeof(s1));
+ strcpy(s1, str);
+ strcat(s1, ",");
+ Begb = s1; //ÆðʼµØÖ·
+ Endb = strchr(s1,','); //µÚÒ»¸ö¶ººÅλÖÃ
+ if (Endb == NULL)
+ return;
+ Lc = 0;
+ do
+ {
+ Len = 0;
+ Len = Endb - Begb; //³¤¶È
+ memset(s2, 0, sizeof(s2)); //½ØÈ¡Á½¸ö¶ººÅ¼äµÄ×Ö·û´®
+ strncpy(s2, Begb, Len); //½ØÈ¡Á½¸ö¶ººÅ¼äµÄ×Ö·û´®
+ data[Lc] = atoi(s2); //string to int
+ ptr = Endb + 1; //Ö¸ÏòϸöÊýµÄÆðʼµØÖ·
+ strcpy(s1, ptr); //È¥µôÒÑת»¯µÄ×Ö·û´®
+ Begb = s1; //ÆðʼµØÖ·¸üÐÂ
+ Endb = strchr(s1,','); //ϸö¶ººÅλÖÃ
+ Lc++;
+ }while(Endb!=NULL);
+}
+#endif
+
+static void str_to_double( double *data, char *str )
+{
+ int Lc = 0;
+ int Len = 0;
+ char *Begb = NULL;
+ char *Endb = NULL;
+ char *ptr = NULL;
+ char s1[100] = "";
+ char s2[50] = "";
+ memset(s1, 0, sizeof(s1));
+ strncpy(s1, str,sizeof(s1) - 1);
+ strcat(s1, ",");
+ Begb = s1; //ÆðʼµØÖ·
+ Endb = strchr(s1,','); //µÚÒ»¸ö¶ººÅλÖÃ
+ if (Endb == NULL)
+ return;
+ Lc = 0;
+ do
+ {
+ Len = 0;
+ Len = Endb - Begb; //³¤¶È
+ memset(s2, 0, sizeof(s2)); //½ØÈ¡Á½¸ö¶ººÅ¼äµÄ×Ö·û´®
+ strncpy(s2, Begb, sizeof(s2) - 1); //½ØÈ¡Á½¸ö¶ººÅ¼äµÄ×Ö·û´®
+ data[Lc] = atof(s2); //string to int
+ ptr = Endb + 1; //Ö¸ÏòϸöÊýµÄÆðʼµØÖ·
+ strncpy(s1, ptr, sizeof(s1) - 1); //È¥µôÒÑת»¯µÄ×Ö·û´®
+ Begb = s1; //ÆðʼµØÖ·¸üÐÂ
+ Endb = strchr(s1,','); //ϸö¶ººÅλÖÃ
+ Lc++;
+ }while(Endb!=NULL);
+}
+
+/**
+ * @brief ¶ÁÈ¡cp²àµÄ·´À¡ÏûÏ¢Ï̺߳¯Êý
+ * @param[in] args Ï̺߳¯Êý²ÎÊý
+ * @return N/A
+ * @note
+ * @see
+ */
+static void* ReadFromCPThread(void* args)
+{
+ // Read from AP-CP channel
+ char *receive_buffer = NULL;
+
+ UNUSED(args);
+
+ receive_buffer = malloc(MAX_PACKET_LENGTH);
+ if (receive_buffer == NULL)
+ {
+ return NULL;
+ }
+
+ prctl(PR_SET_NAME, "AmtReadFromCP");
+
+ while (1)
+ {
+ int read_len = Amt_ReceiveData(g_amt_fd_cp, (unsigned char *)receive_buffer, MAX_PACKET_LENGTH);
+
+ if (read_len > 0)
+ {
+ AmtPrintf(AMT_INFO "%s: Receive cp data, read_len = %d!.\n", __FUNCTION__, read_len);
+
+ if (g_amt_fd_current && *g_amt_fd_current >= 0)
+ {
+ if(g_amt_at_mode != 1)
+ {
+ Amt_SendData(*g_amt_fd_current, (unsigned char *)receive_buffer, read_len);
+ }
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: Current fd is wrong.\n", __FUNCTION__);
+ }
+
+
+ unsigned int status = cpnv_FsGcWait(FS_NVROFS);
+ if(status != CPNV_OK)
+ AmtPrintf(AMT_INFO "%s: cpnv_FsGcWait fail, err = %d.\n", __FUNCTION__, status);
+ }
+ }
+
+ free(receive_buffer);
+ return NULL;
+}
+
+
+/**
+ * @brief ¶ÁÈ¡ÆäËûappµÄÏûÏ¢Ï̺߳¯Êý
+ * @param[in] args Ï̺߳¯Êý²ÎÊý
+ * @return N/A
+ * @note
+ * @see
+ */
+static void* RecvMsgFromAppThread(void* args)
+{
+ int iRet ;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ UNUSED(args);
+
+ prctl(PR_SET_NAME, "AmtRecvAppMsg");
+ while(1)
+ {
+ iRet = 0;
+ memset(&stMsg, 0x00, sizeof(MSG_BUF));
+
+ iRet = msgrcv(g_amt_iMsgHandle, &stMsg, msgSize, 0, 0);
+ if(iRet >= 0)
+ {
+ AmtPrintf(AMT_INFO "%s: msgcmd = 0x%x,datalen=%d.\n", __FUNCTION__,stMsg.usMsgCmd,stMsg.usDataLen);
+
+ switch (stMsg.usMsgCmd)
+ {
+ case MSG_CMD_AMT_BATTERY_VOLTAGE_TEST_RSP:
+ {
+ AmtPrintf(AMT_INFO "%s: recv MSG_CMD_AMT_BATTERY_VOLTAGE_TEST_RSP.\n", __FUNCTION__);
+ int result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_BATTERY_VOLTAGE, result, (unsigned char *)stMsg.aucDataBuf, stMsg.usDataLen);
+ break;
+ }
+
+ case MSG_CMD_AMT_KEY_TEST_START_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: KEY_TEST_START fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_KEYBOARD_START, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_KEY_TEST_STOP_RSP:
+ {
+ int result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_KEYBOARD_STOP, result, (unsigned char *)stMsg.aucDataBuf, stMsg.usDataLen);
+ break;
+ }
+
+ case MSG_CMD_AMT_LCD_TEST_START_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: LCD_TEST_START fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_LCD_START, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_LCD_TEST_STOP_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ AmtPrintf(AMT_INFO "%s: LCD_TEST_STOP result=%d\n", __FUNCTION__,result);
+ if (result == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: LCD_TEST_STOP fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_LCD_STOP, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_LCD_BACKLIGHT_TEST_START_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 1)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: LCD_BACKLIGHT_TEST_START fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_LCDBACKLIGHT_START, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_LCD_BACKLIGHT_TEST_STOP_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: LCD_BACKLIGHT_TEST_STOP fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_LCDBACKLIGHT_STOP, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_VIBRATOR_TEST_START_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 1)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: VIBRATOR_TEST_START fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_VIBRATOR_START, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_VIBRATOR_TEST_STOP_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: VIBRATOR_TEST_STOP fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_VIBRATOR_STOP, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_CAMERA_TEST_START_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 1)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: CAMERA_TEST_START fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_CAMERA_BACK_START, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_CAMERA_TEST_STOP_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: CAMERA_TEST_STOP fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_CAMERA_BACK_STOP, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_SPEAKER_TEST_RSP:
+ {
+ AmtPrintf(AMT_INFO "%s: recv MSG_CMD_AMT_SPEAKER_TEST_RSP.\n", __FUNCTION__);
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 1)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: SPEAKER_TEST fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_AUDIO_MIC_SPEAKER, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_SPEAKER_TEST_STOP_RSP:
+ {
+ AmtPrintf(AMT_INFO "%s: recv MSG_CMD_AMT_SPEAKER_TEST_STOP_RSP.\n", __FUNCTION__);
+ int result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_AUDIO_MIC_SPEAKER_STOP, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_RECEIVER_TEST_RSP:
+ {
+ AmtPrintf(AMT_INFO "%s: recv MSG_CMD_AMT_RECEIVER_TEST_RSP.\n", __FUNCTION__);
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 1)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: RECEIVER_TEST fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_AUDIO_MIC_RECEIVER, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_RECEIVER_TEST_STOP_RSP:
+ {
+ AmtPrintf(AMT_INFO "%s: recv MSG_CMD_AMT_RECEIVER_TEST_STOP_RSP.\n", __FUNCTION__);
+ int result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_AUDIO_MIC_RECEIVER_STOP, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_TP_TEST_START_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 1)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: TP_TEST_START fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_TP_START, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_TP_TEST_STOP_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: TP_TEST_STOP fail.", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_TP_STOP, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_GSENSOR_TEST_START_RSP:
+ {
+ break;
+ }
+
+ case MSG_CMD_AMT_GSENSOR_TEST_STOP_RSP:
+ {
+ break;
+ }
+
+ case MSG_CMD_AMT_WIFI_TEST_START_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 1)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: Wifi test fail!", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_WIFI, result, NULL, 0);
+ break;
+ }
+
+ case MSG_CMD_AMT_FLASHLIGHT_START_RSP:
+ {
+ int result = AMT_ERROR_RET;
+ int* pAucDataBuf = (int*)stMsg.aucDataBuf;
+ result = *pAucDataBuf;
+ if (result == 1)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ AmtPrintf(AMT_INFO "%s: flashlight test fail!", __FUNCTION__);
+ }
+
+ Amt_DeviceTest_SendMsg(MSG_DEVICETEST_FLASHLIGHT_START, result, NULL, 0);
+ break;
+ }
+ //gps²âÊÔÏûÏ¢»ØÓ¦
+ case KWATCH_MSG_GPS_RSP:
+ {
+ Amt_Process_Gps_Rsp(&stMsg,FID_GPS_MODULE_TEST);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ return NULL;
+}
+
+
+/**
+ * @brief ¼ÓÔØ°®¿ÆÎ¢WIFI¹Ì¼þ
+ * @param[in] args Ï̺߳¯Êý²ÎÊý
+ * @return N/A
+ * @note
+ * @see
+ */
+static void* LoadWifiFirmwareThread(void* args)
+{
+ int ret = -1;
+ UNUSED(args);
+
+ prctl(PR_SET_NAME, "LoadWifiFirmwareThread");
+
+ #if (defined(__AIC_8800DW_CHIP__))
+ ret = wifi_ioctl_handle(3); //¼ÓÔØ²âÊԹ̼þ
+ if(ret < 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: load AIC_8800DW firmware fail! ret=%d.\n", __FUNCTION__, ret);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: load AIC_8800DW firmware success! ret=%d.\n", __FUNCTION__, ret);
+ }
+ #endif
+
+ return NULL;
+}
+
+
+/**
+ * @brief AMTÏûÏ¢´ò°ü·¢¸øCP
+ * @param[in] fd ÎļþÃèÊö·û
+ * @param[in] msg_id FID
+ * @param[in] buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] buf_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0
+ * @note
+ * @see
+ */
+static int Amt_SendMessageToAmtagent(int fd, unsigned int msg_id, unsigned char* buf, unsigned int buf_len)
+{
+ // STX TID FID Data Check ETX
+ unsigned int CmdCount = 1 + 1 + 1 + buf_len + 1 + 1;
+ unsigned char *pRsp = NULL;
+ unsigned char *pSTX = NULL;
+ unsigned char *pETX = NULL;
+ unsigned char *pTID = NULL;
+ unsigned char *pFID = NULL;
+ unsigned char *pCheck = NULL;
+ unsigned char *pData = NULL;
+ unsigned char CheckSum = 0;
+ unsigned int i = 0;
+
+ pRsp = malloc(CmdCount);
+ if(pRsp == NULL)
+ return -1;
+ memset(pRsp, 0, CmdCount);
+
+ pSTX = &pRsp[0];
+ pETX = &pRsp[1 + 1 + 1 + buf_len + 1];
+ pTID = &pRsp[1];
+ pFID = &pRsp[1 + 1];
+ pCheck = &pRsp[1 + 1 + 1 + buf_len];
+ pData = &pRsp[1 + 1 + 1];
+
+ *pSTX = 0x02;
+ *pETX = 0x02;
+ *pTID = (msg_id & 0xFF00) >> 8;
+ *pFID = (msg_id & 0xFF);
+
+ if (buf != NULL && buf_len > 0)
+ {
+ memcpy(pData, buf, buf_len);
+ }
+
+ CheckSum = 0;
+
+ for (i = 0; i < (1 + 1 + buf_len); i++)
+ CheckSum ^= pRsp[1 + i];
+
+ *pCheck = CheckSum;
+
+ Amt_SendDataToAmtagent(fd, pRsp, CmdCount);
+
+ free(pRsp);
+ return 0;
+}
+
+
+/**
+ * @brief AMTÏûÏ¢´ò°ü·¢¸øPC
+ * @param[in] fd ÎļþÃèÊö·û
+ * @param[in] msg_id FID
+ * @param[in] buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] buf_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0
+ * @note
+ * @see
+ */
+static int Amt_SendMessage(int fd, unsigned int msg_id, unsigned char* buf, unsigned int buf_len)
+{
+ // STX TID FID Data Check ETX
+ unsigned int CmdCount = 1 + 1 + 1 + buf_len + 1 + 1;
+ unsigned char *pRsp = NULL;
+ unsigned char *pSTX = NULL;
+ unsigned char *pETX = NULL;
+ unsigned char *pTID = NULL;
+ unsigned char *pFID = NULL;
+ unsigned char *pCheck = NULL;
+ unsigned char *pData = NULL;
+ unsigned char CheckSum = 0;
+ unsigned int i = 0;
+
+ pRsp = malloc(CmdCount);
+ if(pRsp == NULL)
+ return -1;
+ memset(pRsp, 0, CmdCount);
+
+ pSTX = &pRsp[0];
+ pETX = &pRsp[1 + 1 + 1 + buf_len + 1];
+ pTID = &pRsp[1];
+ pFID = &pRsp[1 + 1];
+ pCheck = &pRsp[1 + 1 + 1 + buf_len];
+ pData = &pRsp[1 + 1 + 1];
+
+ *pSTX = 0x02;
+ *pETX = 0x02;
+ *pTID = (msg_id & 0xFF00) >> 8;
+ *pFID = (msg_id & 0xFF);
+
+ if (buf != NULL && buf_len > 0)
+ {
+ memcpy(pData, buf, buf_len);
+ }
+
+ CheckSum = 0;
+
+ for (i = 0; i < (1 + 1 + buf_len); i++)
+ CheckSum ^= pRsp[1 + i];
+
+ *pCheck = CheckSum;
+
+ Amt_SendData(fd, pRsp, CmdCount);
+
+ free(pRsp);
+ return 0;
+}
+
+
+/**
+ * @brief AMTÏûÏ¢´¦Àíº¯Êý
+ * @param[in] msg_id FID
+ * @param[in] buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] buf_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0
+ * @note
+ * @see
+ */
+static int Amt_ProcessMessage(unsigned int msg_id, unsigned char* buf, unsigned int buf_len)
+{
+ if (msg_id >= FID_WIFI_CMD_NORTN && msg_id <= FID_WIFI_CMD_END) // wifi test
+ {
+ Amt_Wifi_ProcessMsg(msg_id, buf, buf_len);
+ }
+ else if (msg_id == FID_GET_CHIP_PLATFORM)
+ {
+ //
+ if(is_amt_mode())
+ {
+ AmtPrintf(AMT_ERROR "AMT MODE!\n");
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "Normal MODE!\n");
+ }
+ unsigned char chipType = 0;
+ AmtPrintf(AMT_INFO "%s: Get chip platform msg_id = %#04x, buf_len = %d.\n",
+ __FUNCTION__, msg_id, buf_len);
+ chipType = 1; /*1:7520V3 2:7100*/
+
+ if (Amt_CreateResponse(msg_id, &chipType, sizeof(unsigned char)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else if (msg_id >= FID_GPS_MODULE_TEST && msg_id <= FID_GPS_CMD_END) // gps test
+ {
+ Amt_Gps_ProcessMsg(msg_id, buf, buf_len);
+ }
+ else if (msg_id >= MSG_DEVICETEST_START && msg_id <= MSG_DEVICETEST_END)
+ {
+ Amt_DeviceTest_ProcessMsg(msg_id, buf, buf_len);
+ }
+ else if (msg_id == FID_AMT_END)
+ {
+ unsigned int status = CPNV_OK;//cpnv_ChangeFsPartitionAttr(FS_NVROFS, 1);
+ /*
+ if(status != CPNV_OK)
+ {
+ AmtPrintf(AMT_ERROR "%s: cpnv_ChangeFsPartitionAttr RW nvrofs failed!\n", __FUNCTION__);
+ return -1;
+ }*/
+
+ status = cpnv_FsGcWait(FS_NVROFS);
+ if(status == CPNV_OK)
+ AmtPrintf(AMT_INFO "%s: cpnv_FsGcWait ok.\n", __FUNCTION__);
+ else
+ AmtPrintf(AMT_INFO "%s: cpnv_FsGcWait fail, err = %d.\n", __FUNCTION__, status);
+
+ if (Amt_CreateResponse(msg_id, (unsigned char*)&status, sizeof(unsigned int)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else if (msg_id == FID_AMT_EXIT)
+ {
+ unsigned int status = 0;
+ if (Amt_CreateResponse(msg_id, (unsigned char*)&status, sizeof(unsigned int)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else if (msg_id == FID_EX_COMMON_SETBOOTMODE)
+ {
+ // set normal mode
+ unsigned char bootmode[] = {0xFF, 0xFF};
+ unsigned int dwRet = CPNV_OK;
+
+ //struct timespec ts;
+ //clock_gettime(CLOCK_MONOTONIC, &ts);
+ //AmtPrintf(AMT_INFO "[%8d.%03d] %s: cpnv_FsGcWait start.\n", ts.tv_sec, ts.tv_nsec / 1000000,__FUNCTION__);
+ unsigned char mode = 4;
+ if(buf_len == sizeof(mode))
+ {
+ memcpy(&mode, buf, sizeof(mode));
+ }
+ AmtPrintf(AMT_INFO "%s: boot mode=%d\n", __FUNCTION__,mode);
+ switch(mode)
+ {
+ case 0: //user mode
+ {
+ nv_set_item(NV_RO, "usb_modetype", "user", 1);
+ nv_commit(NV_RO);
+ bootmode[0] =0x54;
+ bootmode[1] =0x00;
+ break;
+ }
+ case 1://debug mode
+ {
+ nv_set_item(NV_RO, "usb_modetype", "debug", 1);
+ nv_commit(NV_RO);
+ bootmode[0] =0x54;
+ bootmode[1] =0x01;
+ break;
+ }
+ case 2://factory mode
+ {
+ nv_set_item(NV_RO, "usb_modetype", "factory", 1);
+ nv_commit(NV_RO);
+ bootmode[0] =0x54;
+ bootmode[1] =0x02;
+ break;
+ }
+ case 3://amt mode
+ {
+ //nv_set_item(NV_RO, "usb_modetype", "amt", 1);
+ //nv_commit(NV_RO);
+ bootmode[0] =0x54;
+ bootmode[1] =0x4D;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ dwRet = amt_set_bootmode(bootmode);
+ if (dwRet == CPNV_OK)
+ {
+ AmtPrintf(AMT_INFO "%s: set boot mode: sucess.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: set boot mode: failed.\n", __FUNCTION__);
+ }
+ //clock_gettime(CLOCK_MONOTONIC, &ts);
+ //AmtPrintf(AMT_INFO "[%8d.%03d] %s: cpnv_FsGcWait ok.\n", ts.tv_sec, ts.tv_nsec / 1000000, __FUNCTION__);
+
+ if (Amt_CreateResponse(msg_id, (unsigned char*)&dwRet, sizeof(unsigned int)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else if(msg_id == FID_CHECK_SOFTDOG_CIPHER_TEXT)
+ {
+ UINT8 softdog_cipher_texts[OS_FLASH_AMT_COMM_RO_SOFTDOG_CIPHER_TEXT_SIZE] = {0};
+ if(!amt_read_nv_item(ABSOFTDOG_CIPHER_TEXT_NVPARAM,softdog_cipher_texts,sizeof(softdog_cipher_texts)))
+ {
+ if (Amt_CreateResponse(msg_id, softdog_cipher_texts, sizeof(softdog_cipher_texts)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: read softdog cipher text in address:0x%x failure.\n", __FUNCTION__,OS_FLASH_AMT_COMM_RO_SOFTDOG_CIPHER_TEXT_ADDRESS);
+ }
+ }
+ else if(msg_id == FID_SET_BAT_DET_FLAG)
+ {
+ unsigned int retCode = CPNV_ERROR;
+ int bat_value = -1;
+ memcpy(&bat_value, buf, sizeof(int));
+ retCode =amt_set_batdet_flag(bat_value);
+
+ if (retCode == CPNV_OK)
+ {
+ AmtPrintf(AMT_INFO "%s: amt_set_batdet_flag success.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: amt_set_batdet_flag fail.\n", __FUNCTION__);
+ }
+ if (Amt_CreateResponse(msg_id, (unsigned char*)&retCode, sizeof(retCode)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else if(msg_id == FID_GET_BAT_DET_FLAG)
+ {
+ unsigned int retCode = CPNV_ERROR;
+ int bat_value = 0;
+ retCode =amt_get_batdet_flag(&bat_value);
+
+ if (retCode == CPNV_OK)
+ {
+ AmtPrintf(AMT_INFO "%s: amt_get_batdet_flag success.bat_value=%d\n", __FUNCTION__,bat_value);
+ if (Amt_CreateResponse(msg_id, (unsigned char*)&bat_value, sizeof(bat_value)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: amt_get_batdet_flag fail.\n", __FUNCTION__);
+ }
+ }
+ else if(msg_id == FID_RINISOFTVERSION)
+ {
+ unsigned int retCode = CPNV_ERROR;
+ char TmpSoftVersion[ZPS_REF_MSINFO_MAX_SOFTVERSION_INT_LEN+1]={0};
+
+ retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_SOFTVERSION_INT_BASE_ADDR, (unsigned char*)TmpSoftVersion, ZPS_REF_MSINFO_MAX_SOFTVERSION_INT_LEN);
+ if (retCode == CPNV_OK)
+ {
+ TmpSoftVersion[ZPS_REF_MSINFO_MAX_SOFTVERSION_INT_LEN] = '\0';
+ AmtPrintf(AMT_INFO "%s: inner version=%s\n", __FUNCTION__,TmpSoftVersion);
+ if (Amt_CreateResponse(msg_id, (unsigned char*)TmpSoftVersion, sizeof(TmpSoftVersion)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: get inner version fail!\n", __FUNCTION__);
+ }
+ }
+ else if(msg_id == FID_ROUTSOFTVERSION)
+ {
+ unsigned int retCode = CPNV_ERROR;
+ char TmpExtcgmr[ZPS_REF_MSINFO_MAX_SOFTVERSION_EXT_LEN+1]={0};
+
+ retCode =cpnv_NvItemRead(ZPS_REF_MSINFO_SOFTVERSION_EXT_BASE_ADDR, (unsigned char *)TmpExtcgmr, ZPS_REF_MSINFO_MAX_SOFTVERSION_EXT_LEN);
+ if (retCode == CPNV_OK)
+ {
+ TmpExtcgmr[ZPS_REF_MSINFO_MAX_SOFTVERSION_EXT_LEN] = '\0';
+ AmtPrintf(AMT_INFO "%s: outer version=%s\n", __FUNCTION__,TmpExtcgmr);
+ if (Amt_CreateResponse(msg_id, (unsigned char*)TmpExtcgmr, sizeof(TmpExtcgmr)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: get outer version fail!\n", __FUNCTION__);
+ }
+ }
+ else if((msg_id >= FID_FUN_TEST_START)&&(msg_id <= FID_FUN_TEST_END))
+ {
+ Amt_FuncTest_ProcessMsg(msg_id, buf, buf_len);
+ }
+ else // CP message
+ {
+ AmtPrintf(AMT_INFO "%s: receive old cp msg.\n", __FUNCTION__);
+ // Send message to CP
+ if (Amt_SendMessageToAmtagent(g_amt_fd_cp, msg_id, buf, buf_len) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Failed to send data to cp, msg_id = %#04x, buf_len = %d.\n",
+ __FUNCTION__, msg_id, buf_len);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data to cp, msg_id = %#04x, buf_len = %d.\n",
+ __FUNCTION__, msg_id, buf_len);
+ }
+ }
+
+ return 0;
+}
+
+
+/**
+ * @brief AMTÏûÏ¢½â°ü
+ * @param[in] buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] buf_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return N/A
+ * @note
+ * @see
+ */
+static void Amt_ComposeAndProcess(unsigned char *buf, unsigned int buf_len)
+{
+ unsigned char *pSTX = NULL;
+ unsigned char *pETX = NULL;
+ unsigned char *pTID = NULL;
+ unsigned char *pFID = NULL;
+ unsigned char *pCheck = NULL;
+ unsigned char *pData = NULL;
+ unsigned char CheckSum = 0;
+ unsigned int msg_id;
+ unsigned int i = 0;
+ pTID = pTID;
+ pCheck = pCheck;
+ pData = pData;
+
+ pSTX = &buf[0];
+ pETX = &buf[buf_len - 1];
+ pTID = &buf[1];
+ pFID = &buf[1 + 1];
+ pCheck = &buf[buf_len - 2];
+ pData = &buf[1 + 1 + 1];
+
+ if (!((0x02 == *pSTX) && (0x02 == *pETX)))
+ {
+ return;
+ }
+
+ CheckSum = 0;
+
+ for (i = 0; i < (buf_len - 2); i++)
+ CheckSum ^= buf[1 + i];
+
+ if (CheckSum != 0)
+ {
+ return;
+ }
+
+ // TIDÓëFID×éºÏʹÓÃÒÑÀ©Õ¹¹¦ÄܺÅ
+ msg_id = (*pTID << 8) | *pFID;
+
+ AmtPrintf(AMT_INFO "%s: msg_id = %#04x, buf_len = %d.\n", __FUNCTION__, msg_id, buf_len);
+ Amt_ProcessMessage(msg_id, pFID + 1, (buf_len - 1 - 1 - 1 - 1 - 1));
+}
+
+
+/**
+ * @brief AMTÏûÏ¢·´À¡
+ * @param[in] msg_id FID
+ * @param[in] buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] buf_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_CreateResponse(unsigned int msg_id, unsigned char* buf, unsigned int buf_len)
+{
+ if (g_amt_fd_current && *g_amt_fd_current >= 0)
+ {
+ return Amt_SendMessage(*g_amt_fd_current, msg_id, buf, buf_len);
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: Current fd is wrong.\n", __FUNCTION__);
+ return -1;
+ }
+}
+
+int wfsystem(const char * cmd)
+{
+ pid_t ret = 0 ;
+ ret = soft_system(cmd);
+ AmtPrintf (AMT_ERROR "[%s]ret = %d, WIFEXITED(ret)=%d, WEXITSTATUS(ret) =%d",cmd, ret , WIFEXITED (ret), WEXITSTATUS (ret));
+ if (! (-1 != ret && WIFEXITED (ret) && 0 == WEXITSTATUS (ret))) {
+ return -1;
+ }
+ return 0;
+}
+
+int check_wlan (void)
+{
+ int find_wlan = -1;
+ int i = 0, sum = 0;
+
+ while (-1 == find_wlan) {
+ AmtPrintf (AMT_ERROR "finding wlan i=%d, %d s...", i , sum);
+ find_wlan = wfsystem ("ifconfig wlan0");
+ if (-1==find_wlan) {
+ if (sum >= 60)
+ return -1;
+ sum += 2 * i;
+ sleep (2 * i++);
+ }
+ }
+ return 0;
+}
+int Amt_ExecuteCmd(char *pcmd, char *pbuffer, int len)
+{
+ FILE *pPipe;
+ static int wifi_init = 0;
+ AmtPrintf(AMT_INFO "%s: execute \"%s\"!\n", __FUNCTION__, pcmd);
+ if(0 == wifi_init)
+ {
+ if(0 == strcmp(pcmd, "ifconfig wlan0 up")){
+ check_wlan();
+ wifi_init = 1;
+ }
+ }
+ if ((pPipe = popen(pcmd, "rb")) == NULL)
+ {
+ AmtPrintf(AMT_ERROR "popen \"%s\" failure.\n", pcmd);
+ return -1;
+ }
+
+ int read_len = fread(pbuffer, 1, len, pPipe);
+ //AmtPrintf(AMT_INFO "fread, read_len = %d, pbuffer = %s.\n", read_len, pbuffer);
+
+ pclose(pPipe);
+ return read_len;
+}
+
+static int init_cp_channel(void)
+{
+ int fd = open(AMT_CP_CHANNEL, O_RDWR);
+
+ if (fd < 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to open \"%s\"!\n", AMT_CP_CHANNEL);
+ return -1;
+ }
+
+ if(ioctl(fd, RPMSG_CREATE_CHANNEL, (8*1024))!= 0) // ´´½¨Í¨µÀ´óС8K
+ {
+ AmtPrintf(AMT_ERROR "ioctrl:RPMSG_CREATE_CHANNEL fail!\n");
+ }
+ if(ioctl(fd, RPMSG_SET_INT_FLAG, NULL)!= 0) // ·¢ËÍÏûϢʱ£¬´¥·¢ÖжÏ
+ {
+ AmtPrintf(AMT_ERROR "ioctrl:RPMSG_SET_INT_FLAG fail!\n");
+ }
+ if(ioctl(fd, RPMSG_CLEAR_POLL_FLAG, NULL)!= 0) // ×èÈûµÄ·½Ê½¶Á
+ {
+ AmtPrintf(AMT_ERROR "ioctrl:RPMSG_CLEAR_POLL_FLAG fail!\n");
+ }
+ return fd;
+}
+
+static int init_usb_device(void)
+{
+ int fd = open(AMT_USB_DEV, O_RDWR);
+
+ if (fd < 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to open \"%s\"!\n", AMT_USB_DEV);
+ return -1;
+ }
+
+ PortSet(fd);
+ return fd;
+}
+
+static int init_hotplug_nl(void)
+{
+ struct sockaddr_nl snl;
+ bzero(&snl, sizeof(snl));
+ snl.nl_family = AF_NETLINK;
+ snl.nl_pid = getpid();
+ snl.nl_groups = 1;
+
+ int s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
+ if (s == -1)
+ {
+ AmtPrintf(AMT_ERROR "Can't create hotplug socket!\n");
+ return -1;
+ }
+
+ if (bind(s, (struct sockaddr *)&snl, sizeof(snl)) < 0)
+ {
+ AmtPrintf(AMT_ERROR "Can't bind hotplug socket!\n");
+ close(s);
+ return -1;
+ }
+
+ return s;
+}
+
+static int init_socket(int port)
+{
+ struct sockaddr_in seraddr;
+ int sockfd = -1;
+
+ AmtPrintf(AMT_INFO "port = %d.\n", port);
+
+ sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (sockfd == -1)
+ {
+ AmtPrintf(AMT_ERROR "Can't create socket!\n");
+ return -1;
+ }
+
+ memset(&seraddr,0,sizeof(seraddr));
+ seraddr.sin_family = AF_INET;
+ seraddr.sin_addr.s_addr = 0;
+ seraddr.sin_port = htons(port);
+
+ if (bind(sockfd, (struct sockaddr*)(&seraddr), sizeof(seraddr)) < 0)
+ {
+ AmtPrintf(AMT_ERROR "Can't bind port %d!\n", port);
+ close(sockfd);
+ return -1;
+ }
+
+ if (listen(sockfd, 1) == -1)
+ {
+ AmtPrintf(AMT_ERROR "Socket listen failed!\n");
+ close(sockfd);
+ return -1;
+ }
+
+ return sockfd;
+}
+
+static void set_fd(int fd)
+{
+ FD_SET(fd, &g_amt_fdsread);
+ if (fd >= g_amt_fd_max)
+ {
+ g_amt_fd_max = fd + 1;
+ }
+}
+
+static void clr_fd(int fd)
+{
+ FD_CLR(fd, &g_amt_fdsread);
+}
+
+static int CreateSendPacket(unsigned short fid, unsigned char *data_buf, int data_len, unsigned char*packet_buf)
+{
+ int bRet = 0;
+ BYTE *pSTX = NULL;
+ BYTE *pETX = NULL;
+ //FIDµÄ¸ß×Ö½Ú
+ BYTE *pHFID = NULL;
+ //FIDµÄµÍ×Ö½Ú
+ BYTE *pLFID = NULL;
+ BYTE *pCheck = NULL;
+ BYTE *pData = NULL;
+ BYTE CheckSum = 0;
+ int i = 0;
+
+ // STX FID Data Check ETX
+ int CmdCount = 1 + 2 + data_len + 1 + 1;
+
+ if ((data_len != 0) && (NULL == data_buf))
+ {
+ return bRet;
+ }
+
+ pSTX = &packet_buf[0];
+ pETX = &packet_buf[1 + 2 + data_len + 1];
+ pHFID = &packet_buf[1];
+ pLFID = &packet_buf[1+1];
+ pCheck = &packet_buf[1 + 2 + data_len];
+ pData = &packet_buf[1 + 2];
+
+ *pSTX = 0x02;
+ *pETX = 0x02;
+ *pHFID = (fid>>8)&0x00FF;
+ *pLFID = fid&0x00FF;
+ memcpy(pData, data_buf, data_len);
+ CheckSum = 0;
+ //CheckSumÊÇFIDºÍDATA×ֶεÄУÑé
+ for (i = 0; i < (2 + data_len); i++)
+ CheckSum ^= packet_buf[1 + i];
+ *pCheck = CheckSum;
+ bRet = 1;
+ return bRet;
+}
+
+static void send_enter_amt_mode_packet()
+{
+ u32 enter_amt_req[5] = {0};
+ enter_amt_req[0] = 0x0100;
+ enter_amt_req[1] = 1;
+ enter_amt_req[2] = 1;
+ enter_amt_req[3] = 0;
+ enter_amt_req[4] = 0;
+
+ unsigned char enter_amt_packet[25] = {0};
+ unsigned short fid = 0x005f;
+ CreateSendPacket(fid,(unsigned char*)enter_amt_req,sizeof(enter_amt_req),enter_amt_packet);
+ Amt_ComposeAndProcess(enter_amt_packet, sizeof(enter_amt_packet));
+}
+
+static void send_exit_amt_mode_packet()
+{
+ u32 exit_amt_req[5] = {0};
+ exit_amt_req[0] = 0x0100;
+ exit_amt_req[1] = 0;
+ exit_amt_req[2] = 1;
+ exit_amt_req[3] = 0;
+ exit_amt_req[4] = 0;
+
+ unsigned char exit_amt_packet[25] = {0};
+ unsigned short fid = 0x005f;
+ CreateSendPacket(fid,(unsigned char*)exit_amt_req,sizeof(exit_amt_req),exit_amt_packet);
+ Amt_ComposeAndProcess(exit_amt_packet, sizeof(exit_amt_packet));
+
+}
+
+
+static void send_tx_start_packet(unsigned int band,unsigned int channel,short int_power,short dec_power)
+{
+ typedef struct
+ {
+ UINT32 MsgId;
+ UINT32 wBandNum; // Ƶ¶Î
+ UINT32 dwEarfcn;
+ UINT32 wFreq; // ÖÐÐÄÆµµã£¬100kHzΪµ¥Î»
+ UINT32 wBandWidth; // ´ø¿í£¬100kHzΪµ¥Î»
+ UINT32 wAntennaPort; // ÌìÏß¶Ë¿Ú £¿£¿£¿
+ UINT32 wModulation; // µ÷ÖÆ·½Ê½£¬0£ºQPSK£¬1£º16QAM£¬2£º64QAM
+ UINT32 wRBNum; // RB¸öÊý
+ UINT32 wRBStartPosition; // RBÆðÊ¼Æ«ÒÆ
+ UINT32 wSingleWave; // ÊÇ·ñΪµ¥Ôز¨
+ SINT16 swRfIntPower; //¹¦ÂÊÕûÊý
+ SINT16 swRfDecPower; //¹¦ÂÊСÊý,[-2 -1 0 1 2 ]´ú±í[-0.5 -0.25 0 0.25 0.5]
+ }T_zAMT_LTEA_SetTxInit_Req;
+
+ T_zAMT_LTEA_SetTxInit_Req stTxInitReq = {0};
+ stTxInitReq.MsgId = 0x0700;
+ stTxInitReq.wBandNum = band;
+ stTxInitReq.dwEarfcn = channel;
+ stTxInitReq.wFreq = 0;
+ stTxInitReq.wBandWidth = 9;
+ stTxInitReq.wAntennaPort = 0;
+ stTxInitReq.wModulation = 0;
+ stTxInitReq.wRBNum = 50;
+ stTxInitReq.wRBStartPosition = 0;
+ stTxInitReq.wSingleWave = 0;
+ stTxInitReq.swRfIntPower = int_power;
+ stTxInitReq.swRfDecPower = dec_power;
+
+ unsigned char tx_start_packet[sizeof(stTxInitReq)+5] = {0};
+ unsigned short fid = 0x005f;
+ CreateSendPacket(fid,(unsigned char*)&stTxInitReq,sizeof(stTxInitReq),tx_start_packet);
+ Amt_ComposeAndProcess(tx_start_packet, sizeof(tx_start_packet));
+
+}
+
+static void send_tx_stop_packet()
+{
+ u32 tx_close_req[1] = {0};
+ tx_close_req[0] = 0x0201;
+ unsigned char tx_stop_packet[1*4+5] = {0};
+ unsigned short fid = 0x005f;
+ CreateSendPacket(fid,(unsigned char*)tx_close_req,sizeof(tx_close_req),tx_stop_packet);
+ Amt_ComposeAndProcess(tx_stop_packet, sizeof(tx_stop_packet));
+
+}
+
+static void send_switch_to_user_mode_packet()
+{
+ unsigned char bootmode[] = {0x54, 0x00};
+ unsigned char atmode[] = {0xFF, 0xFF};
+ nv_set_item(NV_RO, "usb_modetype", "user", 1);
+ nv_commit(NV_RO);
+ amt_set_amt_atmode(bootmode,atmode);
+}
+
+static void send_ok(int fd)
+{
+ char rep_ok[] = "OK\r\n";
+ PortSend(fd, (unsigned char*)rep_ok, strlen(rep_ok), WAIT_ALL);
+}
+
+/**
+ * @brief ATÃüÁî½ÓÊÕ
+ * @param[in] fd ÎļþÃèÊö·û
+ * @param[in] buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] buf_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ·µ»Ø½ÓÊÕµ½µÄÊý¾Ý³¤¶È
+ * @note
+ * @see
+ */
+static int At_ReceiveData(int fd, char* buf, unsigned int buf_len)
+{
+ int read_len = 0;
+ int i = 0;
+ read_len = PortRecv(fd, buf, 100, NO_WAIT);
+ AmtPrintf(AMT_INFO "%s: read_len=%d.\n", __FUNCTION__, read_len);
+ if (read_len > 0)
+ {
+ buf[read_len] = '\0';
+ AmtPrintf(AMT_INFO "%s: receive [%s]\n", __FUNCTION__, buf);
+ //ת»»ÎªÐ¡Ð´
+ for(i = 0; i < read_len; i++)
+ {
+ char at = tolower(buf[i]);
+ buf[i] = at;
+ }
+ AmtPrintf(AMT_INFO "%s: after tolower [%s]\n", __FUNCTION__, buf);
+ //at+txstart=band,channel,power
+ if(strstr(buf,"at+txstart") != NULL)
+ {
+ AmtPrintf(AMT_INFO "%s: receive at+txstart\n", __FUNCTION__);
+ double data[3] = {0.0};
+ unsigned int band = 0;
+ unsigned int channel = 0;
+ short int_power = 0;
+ short idec_power = 0;
+ double dec_power = 0.0;
+ //»ñÈ¡²ÎÊý
+ buf = buf + strlen("at+txstart=");
+ if(buf != NULL)
+ {
+ str_to_double(data,buf);
+ band = data[0];
+ channel = data[1];
+ int_power = data[2];
+ dec_power = data[2] - int_power;
+ idec_power = dec_power*4;
+ AmtPrintf(AMT_INFO "%s: band=%d,channel=%d,int_power=%d,dec_power=%f,idec_power=%d\n", __FUNCTION__, band,channel,int_power,dec_power,idec_power);
+ if(band == 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: invalid band!\n", __FUNCTION__);
+ return read_len;
+
+ }
+ if(channel == 0 )
+ {
+ AmtPrintf(AMT_ERROR "%s: invalid channel!\n", __FUNCTION__);
+ return read_len;
+ }
+ }
+ //ת»¯Îª½øÈëamtģʽºÍtxinitÁ½ÌõAMTÖ¸Áî
+ send_enter_amt_mode_packet();
+ sleep(1);
+ send_tx_start_packet(band,channel,int_power,idec_power);
+ send_ok(fd); //Ö±½Ó¸øATÃüÁî·¢ËÍÕ߻ظ´ok
+
+ }
+ else if(strstr(buf,"at+txstop") != NULL)
+ {
+ //ת»¯Îª¹Ø±Õ·¢Éä»úºÍÍ˳öamtģʽÁ½ÌõAMTÖ¸Áî
+ send_tx_stop_packet();
+ sleep(1);
+ send_exit_amt_mode_packet();
+ send_ok(fd);
+ }
+ else if(strstr(buf,"at+zversiontype=3") != NULL)
+ {
+ send_switch_to_user_mode_packet();
+ send_ok(fd);
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: unknown at %s.\n", __FUNCTION__, buf);
+ }
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: PortRecv from device(fd = %d): read_len(%d) is wrong.\n", __FUNCTION__, fd, read_len);
+ }
+
+ return read_len;
+}
+
+/**
+ * Main Function
+ */
+int main (int argc, char *argv[])
+{
+ extern char *optarg;
+ extern int optind;
+ int c;
+ int socket_port = -1;
+
+ /********************** Get arguments ********************/
+ while ((c = getopt(argc,argv,"p:r:")) != EOF)
+ {
+ switch (c)
+ {
+ case 'p':
+ socket_port = atoi(optarg);
+ break;
+ case '?':
+ AmtPrintf(AMT_INFO "Usage: zte_amt [options]\n");
+ AmtPrintf(AMT_INFO "-p ipport - Set IP port number to listen on\n");
+ exit(1);
+ }
+ }
+
+ AmtPrintf(AMT_INFO "start AMT!\n");
+
+ FD_ZERO(&g_amt_fdsread);
+
+ /********************** Init AP-CP channel ********************/
+ g_amt_fd_cp = init_cp_channel();
+ if (g_amt_fd_cp < 0)
+ {
+ return -1;
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "g_amt_fd_cp = %d.\n", g_amt_fd_cp);
+ }
+
+ /********************** Init USB device ***********************/
+ g_amt_fd_usb = init_usb_device();
+ if (g_amt_fd_usb >= 0)
+ {
+ AmtPrintf(AMT_INFO "g_amt_fd_usb = %d.\n", g_amt_fd_usb);
+ set_fd(g_amt_fd_usb);
+
+ //Init hotplug netlink
+ g_amt_fd_usb_hotplug = init_hotplug_nl();
+ if (g_amt_fd_usb_hotplug >= 0)
+ {
+ AmtPrintf(AMT_INFO "g_amt_fd_usb_hotplug = %d.\n", g_amt_fd_usb_hotplug);
+ set_fd(g_amt_fd_usb_hotplug);
+ }
+ }
+
+ /*********************** Create socket ***********************/
+ if (socket_port > 0)
+ {
+ g_amt_fd_socket_server = init_socket(socket_port);
+ if (g_amt_fd_socket_server >= 0)
+ {
+ AmtPrintf(AMT_INFO "g_amt_fd_socket_server = %d.\n", g_amt_fd_socket_server);
+ set_fd(g_amt_fd_socket_server);
+ }
+ }
+
+ // Create CP read thread
+ pthread_t cp_read_thread;
+ if (pthread_create(&cp_read_thread, NULL, ReadFromCPThread, NULL) != 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to create CP read thread!\n");
+ return -1;
+ }
+
+ // Wifi init
+ Amt_Wifi_Init();
+ g_amt_iMsgHandle = msgget(MODULE_ID_AMT, IPC_CREAT|0600);
+ if(-1 == g_amt_iMsgHandle)
+ {
+ AmtPrintf(AMT_ERROR "%s: can not create msg queue for AMT!\n", __FUNCTION__);
+ return -1;
+ }
+
+ pthread_t msg_recv_thread;
+ if (pthread_create(&msg_recv_thread, NULL, RecvMsgFromAppThread, NULL) != 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to create RecvMsgFromAppThread thread!\n");
+ return -1;
+ }
+ // malloc receive buffer
+ char *receive_buffer = malloc(MAX_PACKET_LENGTH);
+ if (receive_buffer == NULL)
+ {
+ return -1;
+ }
+
+ int ret = -1;
+ int read_len = 0;
+ fd_set tmpfds;
+
+ ret = cpnv_ChangeFsPartitionAttr(FS_NVROFS, 1);
+ if(ret != CPNV_OK)
+ {
+ AmtPrintf(AMT_ERROR "%s: cpnv_ChangeFsPartitionAttr RW nvrofs failed!\n", __FUNCTION__);
+ return -1;
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO"%s: cpnv_ChangeFsPartitionAttr RW nvrofs ok!\n", __FUNCTION__);
+ }
+
+ //¼ÓÔØaic8800¹Ì¼þ
+ // Create load wifi firmware thread
+ pthread_t load_wifi_firmware_thread;
+ if (pthread_create(&load_wifi_firmware_thread, NULL, LoadWifiFirmwareThread, NULL) != 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to create load wifi firmware thread!\n");
+ free(receive_buffer);
+ return -1;
+ }
+
+ #if 0
+ #if (defined(__AIC_8800DW_CHIP__))
+ ret = wifi_ioctl_handle(3); //¼ÓÔØ²âÊԹ̼þ
+ if(ret < 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: load AIC_8800DW firmware fail! ret=%d.\n", __FUNCTION__, ret);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: load AIC_8800DW firmware success! ret=%d.\n", __FUNCTION__, ret);
+ }
+ #endif
+ #endif
+
+ g_amt_at_mode = is_amt_atmode();
+ AmtPrintf(AMT_INFO"%s: g_amt_at_mode=%d\n", __FUNCTION__,g_amt_at_mode);
+
+ while (1)
+ {
+ tmpfds = g_amt_fdsread;
+ ret = select(g_amt_fd_max, &tmpfds, NULL, NULL, NULL);
+ if (ret <= 0)
+ {
+ AmtPrintf(AMT_ERROR "select error: %s!\n", strerror(errno));
+ continue;
+ }
+
+ if (g_amt_fd_usb_hotplug >= 0 && FD_ISSET(g_amt_fd_usb_hotplug, &tmpfds))
+ {
+ read_len = PortRecv(g_amt_fd_usb_hotplug, (unsigned char *)receive_buffer, MAX_PACKET_LENGTH - 1, NO_WAIT);
+ if(read_len >= 0)
+ receive_buffer[read_len] = '\0';
+
+ // Ç¿ÖÆÔö¼Ó½áÊø·û, read_len < MAX_PACKET_LENGTH
+ receive_buffer[MAX_PACKET_LENGTH - 1] = '\0';
+
+ if (strstr(receive_buffer, AMT_DETECT_USB_HOTREMOVE))
+ {
+ AmtPrintf(AMT_INFO "USB remove!\n");
+ system("poweroff");
+ break;
+ }
+
+ if (strstr(receive_buffer, AMT_DETECT_USB_OFFLINE))
+ {
+ AmtPrintf(AMT_INFO "USB offline!\n");
+
+ if (g_amt_fd_usb >= 0)
+ {
+ close(g_amt_fd_usb);
+ clr_fd(g_amt_fd_usb);
+ g_amt_fd_usb = -1;
+ }
+ }
+
+ if (strstr(receive_buffer, AMT_DETECT_USB_ONLINE))
+ {
+ AmtPrintf(AMT_INFO "USB online!\n");
+
+ if (g_amt_fd_usb >= 0)
+ {
+ AmtPrintf(AMT_INFO "amt already open usb,do nothing\n");
+ //close(g_amt_fd_usb);
+ //clr_fd(g_amt_fd_usb);
+ //g_amt_fd_usb = -1;
+ }
+ else
+ {
+ g_amt_fd_usb = init_usb_device();
+ if (g_amt_fd_usb >= 0)
+ {
+ AmtPrintf(AMT_INFO "g_amt_fd_usb = %d.\n", g_amt_fd_usb);
+ set_fd(g_amt_fd_usb);
+ }
+ }
+ }
+ }
+
+ if (g_amt_fd_socket_server >= 0 && FD_ISSET(g_amt_fd_socket_server, &tmpfds))
+ {
+ struct sockaddr_in cliaddr;
+ int addrlen = sizeof(cliaddr);
+
+ if (g_amt_fd_socket_client >= 0)
+ {
+ close(g_amt_fd_socket_client);
+ clr_fd(g_amt_fd_socket_client);
+ g_amt_fd_socket_client = -1;
+ }
+
+ if ((g_amt_fd_socket_client = accept(g_amt_fd_socket_server, (struct sockaddr*)&cliaddr, (socklen_t *)&addrlen)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "Accept failed!\n");
+ }
+ else
+ {
+ unsigned long ip = ntohl(cliaddr.sin_addr.s_addr);
+ AmtPrintf(AMT_INFO "Connect from %lu.%lu.%lu.%lu\n", (ip>>24)&0xff, (ip>>16)&0xff, (ip>>8)&0xff, (ip>>0)&0xff);
+ set_fd(g_amt_fd_socket_client);
+ }
+ }
+
+ if (g_amt_fd_usb >= 0 && FD_ISSET(g_amt_fd_usb, &tmpfds))
+ {
+ g_amt_fd_current = &g_amt_fd_usb;
+ }
+ else if (g_amt_fd_socket_client >= 0 && FD_ISSET(g_amt_fd_socket_client, &tmpfds))
+ {
+ g_amt_fd_current = &g_amt_fd_socket_client;
+ }
+ else
+ {
+ continue;
+ }
+
+ //¶ÁNVÅжÏÊÇ·ñÊǽâÎöATÃüÁʽ
+ if(g_amt_at_mode == 1)
+ {
+ //½âÎö²¢´¦ÀíATÃüÁî
+ At_ReceiveData(*g_amt_fd_current, receive_buffer, MAX_PACKET_LENGTH);
+ continue;
+ }
+
+ read_len = Amt_ReceiveData(*g_amt_fd_current, (unsigned char *)receive_buffer, MAX_PACKET_LENGTH);
+
+ if (read_len > 0)
+ {
+ Amt_ComposeAndProcess((unsigned char *)receive_buffer, read_len);
+ }
+ else if (read_len == 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: read_len = 0, close fd(%d)\n", __FUNCTION__, *g_amt_fd_current);
+ close(*g_amt_fd_current);
+ clr_fd(*g_amt_fd_current);
+ *g_amt_fd_current = -1;
+ g_amt_fd_current = NULL;
+ }
+
+
+ //struct timespec ts;
+ //clock_gettime(CLOCK_MONOTONIC, &ts);
+ //AmtPrintf(AMT_INFO "[%8d.%03d] %s: cpnv_FsGcWait start.\n", ts.tv_sec, ts.tv_nsec / 1000000,__FUNCTION__);
+ //unsigned int status = cpnv_FsGcWait(FS_NVROFS);
+ //if(status != CPNV_OK)
+ // AmtPrintf(AMT_INFO "%s: cpnv_FsGcWait fail, err = %d.\n", __FUNCTION__, status);
+ //else
+ //{
+ // clock_gettime(CLOCK_MONOTONIC, &ts);
+ // AmtPrintf(AMT_INFO "[%8d.%03d] %s: cpnv_FsGcWait ok.\n", ts.tv_sec, ts.tv_nsec / 1000000, __FUNCTION__);
+ //}
+
+ }
+
+ free(receive_buffer);
+ pthread_join(cp_read_thread, NULL);
+#if 1
+ cpnv_FsGcWait(FS_NVROFS);
+ AmtPrintf(AMT_INFO "%s: cpnv_FsGcWait return.\n", __FUNCTION__);
+
+ ret = cpnv_ChangeFsPartitionAttr(FS_NVROFS, 0);
+ if(ret != CPNV_OK)
+ {
+ AmtPrintf(AMT_ERROR "%s: cpnv_ChangeFsPartitionAttr RO nvrofs failed!\n", __FUNCTION__);
+ return -1;
+ }
+#endif
+ close(g_amt_fd_cp);
+
+ if (g_amt_fd_usb >= 0)
+ {
+ close(g_amt_fd_usb);
+ }
+
+ //if (g_amt_fd_usb_hotplug >= 0)
+ {
+ close(g_amt_fd_usb_hotplug);
+ }
+
+ if (g_amt_fd_socket_client >= 0)
+ {
+ close(g_amt_fd_socket_client);
+ }
+
+ if (g_amt_fd_socket_server >= 0)
+ {
+ close(g_amt_fd_socket_server);
+ }
+
+ AmtPrintf(AMT_INFO "AMT exit!\n");
+ return 0;
+}
+
diff --git a/ap/app/zte_amt/amt.h b/ap/app/zte_amt/amt.h
new file mode 100755
index 0000000..5dce06d
--- /dev/null
+++ b/ap/app/zte_amt/amt.h
@@ -0,0 +1,108 @@
+/**
+ *
+ * @file amt.h
+ * @brief
+ * This file is part of FTM.
+ * AMT´úÀíÓ¦Óòã
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2015/04/28 1.0 lu.xieji Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+#ifndef _AMT_H
+#define _AMT_H
+
+
+#define AMT_INFO "<AMT><INFO>"
+#define AMT_ERROR "<AMT><ERROR>"
+#define AmtPrintf(...) fprintf(stderr, __VA_ARGS__)
+//#define AmtPrintf(...) printf(__VA_ARGS__)
+
+#define AMT_USB_DEV "/dev/ttyGS0"
+#define AMT_CP_CHANNEL "/dev/rpm9"
+
+
+#define AMT_DETECT_USB_OFFLINE "offline@/devices/platform/zx29_hsotg.0/gadget/tty/ttyGS0"
+#define AMT_DETECT_USB_ONLINE "online@/devices/platform/zx29_hsotg.0/gadget/tty/ttyGS0"
+#define AMT_DETECT_USB_HOTREMOVE "remove@/dwc_usb/usbconfig"
+
+
+#define MAX_PACKET_LENGTH (128 * 1024)
+
+/**
+ * ºê¶¨Òå
+ */
+#define FID_WIFI_CMD_NORTN (0xC0 + 1)
+#define FID_WIFI_CMD_RTN (0xC0 + 2)
+#define FID_WIFI_CMD_GETVERSION (0xC0 + 3)
+#define FID_WIFI_CMD_GETCOUNTERS (0xC0 + 4)
+#define FID_WIFI_CMD_END (0xC0 + 7)
+
+#define MSG_DEVICETEST_START (0x0500)
+#define MSG_DEVICETEST_END (0x0FFF)
+#define FID_EX_COMMON_SETBOOTMODE (0x1000)
+#define FID_GET_CHIP_PLATFORM (0x1004)
+#define FID_GPS_MODULE_TEST (0x100d)
+#define FID_GPS_MODULE_CLOSE (0x100e)
+#define FID_GPS_CMD_END (0x1015)
+//¼ì²é¶ùͯÊÖ±íÈí¼þ¹·¼ÓÃÜÇøÊý¾ÝÊÇ·ñΪȫ0»òÈ«F
+#define FID_CHECK_SOFTDOG_CIPHER_TEXT (0x1080)
+//ÉèÖÃµç³Ø¼ì²â±ê־λ
+#define FID_SET_BAT_DET_FLAG (0x1081)
+//¶Áµç³Ø¼ì²â±ê־λ
+#define FID_GET_BAT_DET_FLAG (0x1082)
+#define FID_AMT_SYN (0x00C0)
+#define FID_AMT_START (0x00C0)
+#define FID_AMT_END (0x1FFE)
+#define FID_AMT_EXIT (0x1FFF)
+
+#define FID_CUSTOM_START (0x8000)
+#define FID_CUSTOM_END (0xFFFF)
+//¶ÁдÄÚ²¿ºÍÍⲿ°æ±¾ºÅ
+#define FID_RINISOFTVERSION (0xd1)
+#define FID_ROUTSOFTVERSION (0xd3)
+//´®¿Ú²âÊÔ
+#define FID_FUN_TEST_START 0x1016
+#define FID_FUN_TEST_END 0x107F
+#define FID_OPEN_UART (FID_FUN_TEST_START + 6)
+#define FID_CLOSE_UART (FID_FUN_TEST_START + 7)
+
+
+
+#define min(X, Y) \
+ ({ typeof (X) __x = (X); \
+ typeof (Y) __y = (Y); \
+ (__x < __y) ? __x : __y; })
+
+#define max(X, Y) \
+ ({ typeof (X) __x = (X); \
+ typeof (Y) __y = (Y); \
+ (__x > __y) ? __x : __y; })
+
+#ifndef UNUSED
+#define UNUSED(x) (void)(x)
+#endif
+
+int Amt_CreateResponse(unsigned int msg_id, unsigned char* buf, unsigned int buf_len);
+int Amt_ExecuteCmd(char *pcmd, char *pbuffer, int len);
+
+#endif
+
diff --git a/ap/app/zte_amt/amt_agent_devicetest.c b/ap/app/zte_amt/amt_agent_devicetest.c
new file mode 100755
index 0000000..38839eb
--- /dev/null
+++ b/ap/app/zte_amt/amt_agent_devicetest.c
@@ -0,0 +1,1542 @@
+/**
+ *
+ * @file amt_agent_devicetest.c
+ * @brief
+ * This file is part of FTM.
+ * AMT´úÀíÓ¦Óòã
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2018/10/12 1.0 liu.xin Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+
+//#include "oss_api.h"
+#include "amt_agent_devicetest.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/msg.h>
+#include "amt.h"
+#include "softap_api.h"
+#include "other_msg.h"
+//#include "os_type.h"
+#include "battery.h"
+#ifdef _USE_VOICE_SUPPORT
+#include <tinyalsa/asoundlib.h>
+#include <tinyalsa/audio_mixer_ctrl.h>
+#endif
+#include <stdint.h>
+#include <errno.h>
+#include "2k_8000.h"
+#include <pthread.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <math.h>
+
+
+#ifdef FILE
+#undef FILE
+#endif
+#define FILE VOID
+//#define NULL 0
+typedef unsigned int size_t ;
+
+////test
+typedef struct
+{
+ double freqValue;
+ double freqAmp;
+}zDrvVp_Freqfft;
+
+extern int cal_freq_fft(short *data,zDrvVp_Freqfft *freqfft,unsigned short n, int fs);
+extern int get_audioloop_result(FILE* file, int sampfs);
+
+#ifdef _USE_VOICE_SUPPORT
+
+static pthread_t ca_thread_tid;
+static pthread_t pb_thread_tid;
+static int cap_running = 0;
+static FILE *file = NULL;
+static struct pcm *cap_pcm, *pb_pcm;
+
+void* audio_ca_thread(void* arg)
+{
+ struct mixer *mixer;
+ struct pcm_config config;
+ // struct pcm *cap_pcm, *pb_pcm;
+ char *buffer;
+ unsigned int size;
+ unsigned int bytes_read = 0;
+ // FILE *file;
+ //int num_read;
+
+ UNUSED(arg);
+
+ mixer = mixer_open(0);
+ mix_set_input_path(mixer, T_INPUT_MICLP);
+ mix_set_input_vol(mixer, T_AUDIO_INPUT_VOL_LEVEL_11);
+ mixer_close(mixer);
+
+ memset(&config, 0, sizeof(config));
+ config.channels = 1;
+ config.rate = 8000;
+ config.period_size = 320;
+ config.period_count = 3;
+ config.format = PCM_FORMAT_S16_LE;
+ config.start_threshold = 0;
+ config.stop_threshold = 0;
+ config.silence_threshold = 0;
+
+ file = fopen("/mnt/userdata/cache/cap.bin", "wb+");
+ if (!file) {
+ AmtPrintf(AMT_ERROR "Unable to create file cap.bin\n");
+ return NULL;
+ }
+
+ cap_pcm = pcm_open(0, 0, PCM_IN, &config);
+ if (/*!cap_pcm || */!pcm_is_ready(cap_pcm)) {
+ AmtPrintf(AMT_ERROR "Unable to open PCM device (%s)\n",
+ pcm_get_error(cap_pcm));
+ return NULL;
+ }
+
+ size = pcm_frames_to_bytes(cap_pcm, pcm_get_buffer_size(cap_pcm));
+ buffer = malloc(size);
+ if (!buffer) {
+ AmtPrintf(AMT_ERROR "Unable to allocate %d bytes\n", size);
+ //free(buffer);
+ pcm_close(cap_pcm);
+ return NULL;
+ }
+
+ while (!pcm_read(cap_pcm, buffer, size)) {
+ if (fwrite(buffer, 1, size, file) != size) {
+ AmtPrintf(AMT_ERROR "Error capturing sample\n");
+ break;
+ }
+ bytes_read += size;
+ if (bytes_read >= 50000)
+ break;
+ }
+
+ cap_running = 0;
+ free(buffer);
+ // fclose(file);
+ printf("ca_thread\n");
+ AmtPrintf(AMT_INFO "ca_thread\n");
+ pthread_exit(0);
+}
+
+static void* audio_pb_thread(void *arg)
+{
+ struct mixer *mixer;
+ struct pcm_config config;
+ // struct pcm *cap_pcm, *pb_pcm;
+ char *buffer;
+ unsigned int size;
+ //unsigned int bytes_read = 0;
+ //int num_read;
+
+ UNUSED(arg);
+
+ mixer = mixer_open(0);
+ mix_set_output_path(mixer, T_OUTPUT_SPEAKER);
+ mix_set_output_vol(mixer, T_AUDIO_OUTPUT_VOL_LEVEL_11);
+ mixer_close(mixer);
+
+ memset(&config, 0, sizeof(config));
+ config.channels = 1;
+ config.rate = 8000;
+ config.period_size = 320;
+ config.period_count = 3;
+ config.format = PCM_FORMAT_S16_LE;
+ config.start_threshold = 0;
+ config.stop_threshold = 0;
+ config.silence_threshold = 0;
+
+ pb_pcm = pcm_open(0, 0, PCM_OUT, &config);
+ if (/*!pb_pcm ||*/ !pcm_is_ready(pb_pcm)) {
+ AmtPrintf(AMT_ERROR "Unable to open PCM device (%s)\n",
+ pcm_get_error(pb_pcm));
+ return NULL;
+ }
+
+ size = pcm_frames_to_bytes(pb_pcm, pcm_get_buffer_size(pb_pcm));
+ buffer = malloc(size);
+ if (!buffer) {
+ AmtPrintf(AMT_ERROR "Unable to allocate %d bytes\n", size);
+ // free(buffer);
+ pcm_close(cap_pcm);
+ return NULL;
+ }
+
+ memcpy(buffer, buffer2k8000, size);
+ if (pcm_write(pb_pcm, buffer, size)) {
+ AmtPrintf(AMT_ERROR "Error playing sample\n");
+ free(buffer);
+ return NULL;
+ }
+
+ do {
+ memcpy(buffer, buffer2k8000, size);
+ if (pcm_write(pb_pcm, buffer, size)) {
+ AmtPrintf(AMT_ERROR "Error playing sample\n");
+ break;
+ }
+
+ } while (cap_running > 0);
+
+ free(buffer);
+
+ printf("pb_thread\n");
+ AmtPrintf(AMT_INFO "pb_thread\n");
+ pthread_exit(0);
+
+ return NULL;
+}
+#endif
+
+int get_audioloop_result(FILE* file, int sampfs)
+{
+ int ret = -1, i = 0, num_read;
+ unsigned char testCount = 0, testSucessCount = 0;
+ zDrvVp_Freqfft temp = { 0,0 };
+ double freq[20] = {0};
+ double freqAmp[20] = {0};
+ double toneRealFreq = 1000; //2000
+ testCount = 20;
+ char *buffer = NULL;
+
+ buffer = malloc(2048);
+ if (!buffer)
+ {
+ AmtPrintf(AMT_ERROR "Unable to allocate %d bytes\n", 2048);
+ return -1;
+ }
+
+ if(fseek(file, 3200, SEEK_SET)!= 0)
+ {
+ free(buffer);
+ return -1;
+ }
+
+ while (testCount > 0)
+ {
+ //todo
+// zOss_Memcpy(audioPra->dest, audioPra->src, 2048); //2048byte
+// fseek(file, 0, SEEK_SET);
+ num_read = fread(buffer, 1, 2048, file);
+ if (num_read <= 0) {
+ printf("file end\n");
+ AmtPrintf(AMT_ERROR "file end\n");
+ free(buffer);
+ return -1;
+ }
+ cal_freq_fft((short *)buffer, &temp, 1024, sampfs);//1024 point fft//xiu
+
+ freq[testCount - 1] = temp.freqValue;
+ freqAmp[testCount - 1] = temp.freqAmp;
+ if (((fabs(freq[testCount - 1] - toneRealFreq)) < 50) && (freqAmp[testCount - 1] > 300))
+ {
+ testSucessCount++;
+ if (testSucessCount >= 5)
+ {
+ printf("testSucessCount=%d!\n", testSucessCount);
+ AmtPrintf(AMT_INFO "testSucessCount=%d!\n", testSucessCount);
+ ret = 0;
+ testCount--;
+ break;
+ }
+ }
+
+ testCount--;
+
+ }
+
+
+ for (i = 19; i >= testCount; i--)
+ {
+ printf("get_audioloop_result freq[%d]=%f freqAmp =%f!\n", i, freq[i], freqAmp[i]);
+ AmtPrintf(AMT_INFO "get_audioloop_result freq[%d]=%f freqAmp =%f!\n", i, freq[i], freqAmp[i]);
+ }
+
+ free(buffer);
+ return ret;
+}
+/**************************************************Íⲿ½Ó¿Ú****************************************************/
+#if 0
+extern int MMI_Test_TestInfo(unsigned char *msg_buf, unsigned int *msg_len);
+extern int MMI_Test_Keyboard_Start(VOID);
+extern int MMI_Test_Keyboard_Stop(unsigned char *msg_buf, unsigned int *msg_len);
+extern int MMI_Test_KP_Read(char *msg_buf, unsigned int *msg_len);
+extern int MMI_Test_LCD_Start(int color);
+extern int MMI_Test_LCD_Stop(VOID);
+extern int MMI_Test_LCDBacklight_Start(int value);
+extern int MMI_Test_LCDBacklight_Stop(VOID);
+extern int MMI_Test_Vibrator_Start(int timeout);
+extern int MMI_Test_Vibrator_Stop(VOID);
+extern int MMI_Test_SIM_Read(int index, char* msg_buf, unsigned int *msg_len);
+extern int MMI_Test_Battery_Voltage(char* msg_buf, unsigned int* msg_len);
+extern int MMI_Test_KeyBacklight_Start(VOID);
+extern int MMI_Test_KeyBacklight_Stop(VOID);
+extern int MMI_Test_Camera_Back_Start(VOID);
+extern int MMI_Test_Camera_Back_Stop(VOID);
+extern int MMI_Test_Camera_Back_Snapshot(unsigned char *msg_buf, unsigned int msg_len);
+extern int MMI_Test_SD_Read(int index, char *msg_buf, unsigned int *msg_len);
+extern int MMI_Test_Audio_Mic_Speaker(unsigned char *msg_buf, unsigned int msg_len);
+extern int MMI_Test_Audio_Mic_Receiver(unsigned char *msg_buf, unsigned int msg_len);
+extern int MMI_Test_Audio_Headset_Headset(unsigned char *msg_buf, unsigned int msg_len);
+extern int MMI_Test_SetIdle(VOID);
+
+extern FILE* tp_fopen (const char *file_name, const char *mode);
+extern int tp_flength(FILE *stream);
+extern size_t tp_fread (void *data, size_t size, size_t count, FILE *stream);
+extern int tp_fclose(FILE *stream);
+
+
+/**************************************************²âÊÔ½Ó¿Ú****************************************************/
+static int Amt_Test_Status_Idle(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ if (MMI_Test_SetIdle() == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+
+static int Amt_Test_Init(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ unsigned int ret = 0;
+#if 0
+ ZOSS_S_TIMEVAL tv = {0};
+
+ /* Initialize OS Time */
+ if (ZOSS_SUCCESS == zOss_Gettimeofday(&tv, NULL))
+ {
+ settimeofday(&tv, NULL);
+ }
+
+ /* Initialize CFG */
+ zCfg_Init();
+
+ ret = zOss_MountDynamicDisk("C:", "/c", "cpfs", "yaffs");
+ zOss_ASSERT(ret == ZOSS_SUCCESS);
+
+ zApp_Init();
+
+#ifdef _CONFIG_USE_VOICE
+ ret = zDrvVoiceConfig_Init();
+ if (ret != ZOSS_SUCCESS)
+ {
+ result = AMT_ERROR;
+ }
+ else
+#endif
+ {
+ result = AMT_SUCCESS;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+#endif
+ return result;
+}
+
+static int Amt_Test_TestInfo(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ unsigned int nSize = 0;
+ unsigned char *pBuf = NULL;
+
+ MMI_Test_TestInfo(NULL, &nSize);
+
+ if (nSize > 0)
+ {
+ pBuf = (unsigned char *)malloc(nSize);
+ memset(pBuf, 0, nSize);
+
+ if (MMI_Test_TestInfo(pBuf, &nSize) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(msg_id, result, pBuf, nSize);
+ free(pBuf);
+ return result;
+ }
+
+ free(pBuf);
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+#endif
+static int Amt_Test_Keyboard_Start(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ //ÏòMMI·¢ËÍ¿ªÊ¼°´¼ü²âÊÔÇëÇó
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_KEY_TEST_START_REQ, 0, NULL);
+
+ #if 0
+ if (MMI_Test_Keyboard_Start() == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+
+static int Amt_Test_Keyboard_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ #if 0
+ unsigned int nSize = 0;
+ unsigned char *pBuf = NULL;
+
+ nSize = 2*sizeof(T_ZWndEm_CheckKey);
+ pBuf = (char *)malloc(nSize);
+ memset(pBuf, 0, nSize);
+ #endif
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_KEY_TEST_STOP_REQ, 0, NULL);
+ #if 0
+ MMI_Test_Keyboard_Stop(NULL, &nSize);
+
+ if (nSize > 0)
+ {
+ pBuf = (unsigned char *)malloc(nSize);
+ memset(pBuf, 0, nSize);
+
+ if (MMI_Test_Keyboard_Stop(pBuf, &nSize) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(msg_id, result, pBuf, nSize);
+ free(pBuf);
+ return result;
+ }
+
+ free(pBuf);
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+#if 0
+static int Amt_Test_Keyboard_Read(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ unsigned int nSize = 0;
+ unsigned char *pBuf = NULL;
+
+ MMI_Test_KP_Read(NULL, &nSize);
+
+ if (nSize > 0)
+ {
+ pBuf = (unsigned char *)malloc(nSize);
+ memset(pBuf, 0, nSize);
+
+ if (MMI_Test_KP_Read((char *)pBuf, &nSize) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(msg_id, result, pBuf, nSize);
+ free(pBuf);
+ return result;
+ }
+
+ free(pBuf);
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+#endif
+static int Amt_Test_LCD_Start(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ int color;
+
+ UNUSED(msg_id);
+ UNUSED(msg_len);
+
+ memcpy(&color, msg_buf, sizeof(int));
+
+ if (color >= 0 && color < MAX_LCD_COLOR_NUM)
+ {
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_LCD_TEST_START_REQ, sizeof(int), (unsigned char*)&color);
+ #if 0
+ if (MMI_Test_LCD_Start(color) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ #endif
+ }
+
+ //Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+
+ return result;
+}
+
+static int Amt_Test_LCD_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_LCD_TEST_STOP_REQ, 0, NULL);
+ #if 0
+ if (MMI_Test_LCD_Stop() == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+
+static int Amt_Test_LCDBacklight_Start(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ int value;
+
+ UNUSED(msg_id);
+ UNUSED(msg_len);
+
+ memcpy(&value, msg_buf, sizeof(int));
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_LCD_BACKLIGHT_TEST_START_REQ, sizeof(int), (unsigned char*)&value);
+ #if 0
+ if (MMI_Test_LCDBacklight_Start(value) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+
+static int Amt_Test_LCDBacklight_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_LCD_BACKLIGHT_TEST_STOP_REQ, 0, NULL);
+ #if 0
+ if (MMI_Test_LCDBacklight_Stop() == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+
+static int Amt_Test_Vibrator_Start(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ int timeout = -1;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_VIBRATOR_TEST_START_REQ, sizeof(int), (unsigned char*)&timeout);
+ #if 0
+ if (MMI_Test_Vibrator_Start(-1) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+
+static int Amt_Test_Vibrator_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_VIBRATOR_TEST_STOP_REQ, 0, NULL);
+ #if 0
+ if (MMI_Test_Vibrator_Stop() == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+
+#if 0
+static int Amt_Test_SIM_Read(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ unsigned int nSize = 0;
+ char *pBuf = NULL;
+ int index = 0;
+ memcpy(&index, msg_buf, sizeof(int));
+
+ MMI_Test_SIM_Read(index, NULL, &nSize);
+
+ if (nSize > 0)
+ {
+ pBuf = (char *)malloc(nSize);
+ memset(pBuf, 0, nSize);
+
+ if (MMI_Test_SIM_Read(index, pBuf, &nSize) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(msg_id, result, (unsigned char *)pBuf, nSize);
+ free(pBuf);
+ return result;
+ }
+
+ free(pBuf);
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+
+static int Amt_Test_SD_Read(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ unsigned int nSize = 0;
+ char *pBuf = NULL;
+ int index = 0;
+ memcpy(&index, msg_buf, sizeof(int));
+
+ MMI_Test_SD_Read(index, NULL, &nSize);
+
+ if (nSize > 0)
+ {
+ pBuf = (char *)malloc(nSize);
+ memset(pBuf, 0, nSize);
+
+ if (MMI_Test_SD_Read(index, pBuf, &nSize) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(msg_id, result, (unsigned char *)pBuf, nSize);
+ free(pBuf);
+ return result;
+ }
+
+ free(pBuf);
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+#endif
+static int Amt_Test_Battery_Voltage(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ #if 0
+ unsigned int nSize = 0;
+ char *pBuf = NULL;
+
+ //ÏòMMI·¢ËÍµç³Øµçѹ²âÊÔÇëÇó
+ nSize = sizeof(MAN_BATTERY_STATUS);
+ pBuf = (char *)malloc(nSize);
+ memset(pBuf, 0, nSize);
+ #endif
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_BATTERY_VOLTAGE_TEST_REQ, 0, NULL);
+ #if 0
+ MMI_Test_Battery_Voltage(NULL, &nSize);
+
+ if (nSize > 0)
+ {
+ pBuf = (char *)malloc(nSize);
+ memset(pBuf, 0, nSize);
+
+ if (MMI_Test_Battery_Voltage(pBuf, &nSize) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(msg_id, result, (unsigned char *)pBuf, nSize);
+ free(pBuf);
+ return result;
+ }
+
+ free(pBuf);
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+
+static int Amt_Test_Battery_Temperature(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ FILE* batteryTempFd = NULL;
+ char buf[10] = {0};
+ int read_len = 0;
+ int battery_temperature = 0; //µç³ØÎ¶È(µ¥Î»ºÁ·ü)
+
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ batteryTempFd = fopen(BATTERY_TEMPERATURE_PATH, "r");
+ //AmtPrintf(AMT_INFO "%s: batteryTempFd =0x%08x\n", __FUNCTION__, batteryTempFd);
+ if(batteryTempFd == NULL)
+ {
+ AmtPrintf(AMT_ERROR "%s:battery temperature open error,path is \"%s\"!\n",__FUNCTION__, BATTERY_TEMPERATURE_PATH);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+ }
+ else
+ {
+ read_len = fread(buf, 1, sizeof(buf) - 1, batteryTempFd);
+ AmtPrintf(AMT_INFO "%s:battery temperature read_len=%d\n",__FUNCTION__, read_len);
+ if(read_len > 0)
+ {
+ AmtPrintf(AMT_INFO "%s:battery temperature read:%s\n",__FUNCTION__, buf);
+ battery_temperature = atoi(buf);
+ AmtPrintf(AMT_INFO "%s:battery temperature = %d\n",__FUNCTION__, battery_temperature);
+ result = AMT_SUCCESS_RET;
+ }
+ fclose(batteryTempFd);
+ }
+ Amt_DeviceTest_SendMsg(msg_id, result, (unsigned char *)&battery_temperature, sizeof(battery_temperature));
+ return result;
+}
+
+static int Amt_Test_Charger_Status(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ FILE* chargerStatusFd = NULL;
+ char buf[50] = {0};
+ int read_len = 0;
+
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ chargerStatusFd = fopen(CHARGER_STATUS_PATH, "r");
+ //AmtPrintf(AMT_INFO "%s: chargerStatusFd =0x%08x\n", __FUNCTION__, chargerStatusFd);
+ if(chargerStatusFd == NULL)
+ {
+ AmtPrintf(AMT_ERROR "%s:charger status open error,path is \"%s\"!\n",__FUNCTION__, CHARGER_STATUS_PATH);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+ }
+ else
+ {
+ read_len = fread(buf, 1, sizeof(buf) - 1 , chargerStatusFd);
+ AmtPrintf(AMT_INFO "%s:charger status read_len=%d\n",__FUNCTION__, read_len);
+ if(read_len > 0)
+ {
+ AmtPrintf(AMT_INFO "%s:charger status read:%s\n",__FUNCTION__, buf);
+ if(!strncmp(buf,"Charging",strlen("Charging")) || !strncmp(buf,"Full",strlen("Full")))
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ }
+
+ fclose(chargerStatusFd);
+ }
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+
+#if 0
+static int Amt_Test_KeyBacklight_Start(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result;
+
+ if (MMI_Test_KeyBacklight_Start() == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+
+static int Amt_Test_KeyBacklight_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result;
+
+ if (MMI_Test_KeyBacklight_Stop() == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+#endif
+static int Amt_Test_Camera_Back_Start(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_CAMERA_TEST_START_REQ, 0, NULL);
+ #if 0
+ if (MMI_Test_Camera_Back_Start() == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+#if 0
+static int Amt_Test_Camera_Back_Snapshot(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ char PicPath[260] = {0};
+ int nSize = 0;
+ unsigned char *pBuf = NULL;
+ FILE *pFile = NULL;
+
+ if (MMI_Test_Camera_Back_Snapshot((unsigned char *)PicPath, 260) != 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: MMI_Test_Camera_Back_Snapshot return error!", __FUNCTION__);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return -1;
+ }
+
+ if (PicPath[0] == '\0')
+ {
+ AmtPrintf(AMT_ERROR "%s: PicPath is empty!", __FUNCTION__);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return -1;
+ }
+
+ if ((pFile = tp_fopen(PicPath, "rb")) == NULL)
+ {
+ AmtPrintf(AMT_ERROR "%s: Open \"%s\" fail!", __FUNCTION__, PicPath);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return -1;
+ }
+
+ // »ñÈ¡Îļþ´óС
+ if ((nSize = tp_flength(pFile)) <= 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: nSize(%d) < = 0!", __FUNCTION__, nSize);
+ tp_fclose(pFile);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return -1;
+ }
+
+ // ÉêÇ뻺³åÇø
+ pBuf = malloc(nSize);
+
+ // ¶ÁÈ¡ÎļþÊý¾Ý
+ if (tp_fread(pBuf, 1, nSize, pFile) == nSize)
+ {
+ result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(msg_id, result, pBuf, nSize);
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: tp_fread error!", __FUNCTION__);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ }
+
+ free(pBuf);
+ tp_fclose(pFile);
+
+ return result;
+}
+#endif
+static int Amt_Test_Camera_Back_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_CAMERA_TEST_STOP_REQ, 0, NULL);
+ #if 0
+ if (MMI_Test_Camera_Back_Stop() == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+
+#ifdef _USE_VOICE_SUPPORT
+static int Amt_Test_Audio_Mic_Receiver(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_RECEIVER_TEST_REQ, 0, NULL);
+ #if 0
+ if (MMI_Test_Audio_Mic_Receiver(msg_buf, msg_len) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ return result;
+}
+
+static int Amt_Test_Audio_Mic_Receiver_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_RECEIVER_TEST_STOP_REQ, 0, NULL);
+ return result;
+}
+
+static int Amt_Test_Audio_Mic_Speaker(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ //platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_SPEAKER_TEST_REQ, 0, NULL);
+ #if 0
+ if (MMI_Test_Audio_Mic_Speaker(msg_buf, msg_len) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ #endif
+ #if 0
+ //µ÷ÓÃÇý¶¯µÄ½Ó¿Ú¼Òô²¢²¥·Å
+ struct mixer *mixer;
+ struct pcm_config config;
+ struct pcm *cap_pcm, *pb_pcm;
+ char *buffer;
+ unsigned int size;
+ unsigned int bytes_read = 0;
+ FILE *file;
+ int num_read;
+ int errNum = 0;
+
+ mixer = mixer_open(0);
+ mix_set_input_path(mixer, T_INPUT_MICLP);
+ mix_set_input_vol(mixer, T_AUDIO_INPUT_VOL_LEVEL_11);
+ mixer_close(mixer);
+
+ memset(&config, 0, sizeof(config));
+ config.channels = 1;
+ config.rate = 8000;
+ config.period_size = 320;
+ config.period_count = 3;
+ config.format = PCM_FORMAT_S16_LE;
+ config.start_threshold = 0;
+ config.stop_threshold = 0;
+ config.silence_threshold = 0;
+
+ file = fopen("/mnt/userdata/cache/cap.bin", "wb+");
+ if (!file) {
+ errNum = errno;
+ AmtPrintf(AMT_ERROR "%s:Unable to create file cap.bin,errNum=%d,reason=%s\n",\
+ __FUNCTION__,errNum,strerror(errNum));
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+ }
+
+ cap_pcm = pcm_open(0, 0, PCM_IN, &config);
+ if (!cap_pcm || !pcm_is_ready(cap_pcm)) {
+ AmtPrintf(AMT_ERROR "Unable to open PCM device (%s)\n",
+ pcm_get_error(cap_pcm));
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+ }
+
+ size = pcm_frames_to_bytes(cap_pcm, pcm_get_buffer_size(cap_pcm));
+ buffer = malloc(size);
+ if (!buffer) {
+ AmtPrintf(AMT_ERROR "Unable to allocate %d bytes\n", size);
+ free(buffer);
+ pcm_close(cap_pcm);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+ }
+
+ while (!pcm_read(cap_pcm, buffer, size)) {
+ if (fwrite(buffer, 1, size, file) != size) {
+ AmtPrintf(AMT_ERROR "Error capturing sample\n");
+ break;
+ }
+ bytes_read += size;
+ if (bytes_read >= 80000)
+ break;
+ }
+
+ pcm_close(cap_pcm);
+
+ mixer = mixer_open(0);
+ mix_set_output_path(mixer, T_OUTPUT_SPEAKER);
+ mix_set_output_vol(mixer, T_AUDIO_OUTPUT_VOL_LEVEL_11);
+ mixer_close(mixer);
+
+ pb_pcm = pcm_open(0, 0, PCM_OUT, &config);
+ if (!pb_pcm || !pcm_is_ready(pb_pcm)) {
+ AmtPrintf(AMT_ERROR "Unable to open PCM device (%s)\n",
+ pcm_get_error(pb_pcm));
+ free(buffer);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+ }
+
+ fseek(file, 0, SEEK_SET);
+
+ do {
+ num_read = fread(buffer, 1, size, file);
+ if (num_read > 0) {
+ if (pcm_write(pb_pcm, buffer, num_read)) {
+ AmtPrintf(AMT_ERROR "Error playing sample\n");
+ break;
+ }
+ }
+ } while (num_read > 0);
+
+ free(buffer);
+ pcm_close(pb_pcm);
+ fclose(file);
+
+ remove("/mnt/userdata/cache/cap.bin");
+ result = AMT_SUCCESS_RET;
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+#endif
+ int ret;
+
+#if 1
+ cap_running = 1;
+
+ ret = pthread_create(&pb_thread_tid, NULL, audio_pb_thread, NULL);
+ if(ret != 0){
+ printf ("Create pb_thread error!\n");
+ AmtPrintf(AMT_ERROR "Create pb_thread error!\n");
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+ }
+ ret = pthread_create(&ca_thread_tid, NULL, audio_ca_thread, NULL);
+ if(ret != 0){
+ printf ("Create ca_thread error!\n");
+ AmtPrintf(AMT_ERROR "Create ca_thread error!\n");
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+ }
+
+ pthread_join(ca_thread_tid, NULL);
+ pthread_join(pb_thread_tid, NULL);
+ printf("AmtAgent_Test_Audio_Mic_Speaker\n");
+ AmtPrintf(AMT_INFO "AmtAgent_Test_Audio_Mic_Speaker\n");
+#endif
+
+ pcm_close(pb_pcm);
+ pcm_close(cap_pcm);
+ printf("cap 1 stop\n");
+ AmtPrintf(AMT_INFO "cap 1 stop\n");
+
+ ret = get_audioloop_result(file, 8000);
+
+ fclose(file);
+
+ AmtPrintf(AMT_INFO "ret = %d\n",ret);
+ Amt_DeviceTest_SendMsg(msg_id, ret , NULL, 0);
+ if(remove("/mnt/userdata/cache/cap.bin") != 0)
+ {
+ AmtPrintf(AMT_INFO "remove \"/mnt/userdata/cache/cap.bin\" error! errno=%d(%s)\n",errno,strerror(errno));
+ }
+ return result;
+}
+
+static int Amt_Test_Audio_Mic_Speaker_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_SPEAKER_TEST_STOP_REQ, 0, NULL);
+ return result;
+}
+
+
+#if 0
+static int Amt_Test_Audio_Headset_Headset(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result;
+
+ if (MMI_Test_Audio_Headset_Headset(msg_buf, msg_len) == 0)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ else
+ {
+ result = AMT_ERROR_RET;
+ }
+
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+#endif
+#endif
+
+static int Amt_Test_TP_Start(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_TP_TEST_START_REQ, 0, NULL);
+ return result;
+}
+
+static int Amt_Test_TP_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_TP_TEST_STOP_REQ, 0, NULL);
+ return result;
+}
+
+static int Amt_Test_TP_Board(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ FILE* tpFd = NULL;
+ char buf[10] = {0};
+ int read_len = 0;
+ int tp_result = 0;
+
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ tpFd = fopen(TP_MODE_PATH, "r");
+ //AmtPrintf(AMT_INFO "%s: tpFd =0x%08x\n", __FUNCTION__, tpFd);
+ if(tpFd == NULL)
+ {
+ AmtPrintf(AMT_ERROR "%s:tp device open error,path is \"%s\"!\n",__FUNCTION__, TP_MODE_PATH);
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+ }
+ else
+ {
+ read_len = fread(buf, 1, sizeof(buf) - 1, tpFd);
+ AmtPrintf(AMT_INFO "%s:tp read_len=%d\n",__FUNCTION__, read_len);
+ if(read_len > 0)
+ {
+ AmtPrintf(AMT_INFO "%s:tp read:%s\n",__FUNCTION__, buf);
+ tp_result = atoi(buf);
+ AmtPrintf(AMT_INFO "%s:tp mode = %d\n",__FUNCTION__, tp_result);
+ if(tp_result != 0xff)
+ {
+ result = AMT_SUCCESS_RET;
+ }
+ }
+ fclose(tpFd);
+ }
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+
+static int Amt_Test_GSensor_Board(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ int fd_gsensor = open(DEVICE_GSENSOR, O_RDWR);
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ if (fd_gsensor < 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to open \"%s\"!\n", DEVICE_GSENSOR);
+ }
+ else
+ {
+ close(fd_gsensor);
+ result = AMT_SUCCESS_RET;
+ }
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+
+static int Amt_Test_Camera_Board(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ int fd_camera = open(DEVICE_CAMERA, O_RDWR);
+
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ if (fd_camera < 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to open \"%s\"!\n", DEVICE_CAMERA);
+ }
+ else
+ {
+ close(fd_camera);
+ result = AMT_SUCCESS_RET;
+ }
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+
+static int Amt_Test_LCD_Board(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+ int fd_LCD = open(DEVICE_LCD, O_RDWR);
+
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ if (fd_LCD < 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to open \"%s\"!\n", DEVICE_LCD);
+ }
+ else
+ {
+ close(fd_LCD);
+ result = AMT_SUCCESS_RET;
+ }
+ Amt_DeviceTest_SendMsg(msg_id, result, NULL, 0);
+ return result;
+}
+
+static int Amt_Test_GSensor_Start(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_GSENSOR_TEST_START_REQ, 0, NULL);
+ return result;
+}
+
+static int Amt_Test_GSensor_Stop(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_GSENSOR_TEST_STOP_REQ, 0, NULL);
+ return result;
+}
+
+static int Amt_Test_Flashlight_Start(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_FLASHLIGHT_START_REQ, 0, NULL);
+ return result;
+}
+
+static int Amt_Test_Wifi(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ int result = AMT_ERROR_RET;
+
+ UNUSED(msg_id);
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ platform_send_msg(MODULE_ID_AMT, MODULE_ID_MMI_SVR, MSG_CMD_AMT_WIFI_TEST_START_REQ, 0, NULL);
+ return result;
+}
+/**
+ *
+ */
+static const T_COMMAND g_CmdTable[] =
+{
+ #if 0
+ // Common
+ {TEST_COMMON, MSG_DEVICETEST_STATUS_IDLE, Amt_Test_Status_Idle, "Set idle status"},
+ {TEST_COMMON, MSG_DEVICETEST_TESTINIT, Amt_Test_Init, "Test init"},
+ // TestInfo
+ {TEST_INFO, MSG_DEVICETEST_TESTINFO, Amt_Test_TestInfo, "Get test information"},
+ #endif
+ //Keyboard
+ {TEST_KEYBOARD, MSG_DEVICETEST_KEYBOARD_START, Amt_Test_Keyboard_Start, "Start Keyboard test"},
+ {TEST_KEYBOARD, MSG_DEVICETEST_KEYBOARD_STOP, Amt_Test_Keyboard_Stop, "Stop Keyboard test"},
+ //{TEST_KEYBOARD, MSG_DEVICETEST_KEYBOARD_READ, Amt_Test_Keyboard_Read, "Read Keyboard state"},
+ //LCD
+ {TEST_LCD, MSG_DEVICETEST_LCD_START, Amt_Test_LCD_Start, "Start LCD test"},
+ {TEST_LCD, MSG_DEVICETEST_LCD_STOP, Amt_Test_LCD_Stop, "Stop LCD test"},
+ {TEST_LCD, MSG_DEVICETEST_LCD_BOARD, Amt_Test_LCD_Board, "Board LCD test"},
+ //LCD backlight
+ {TEST_LCDBACKLIGHT, MSG_DEVICETEST_LCDBACKLIGHT_START, Amt_Test_LCDBacklight_Start, "Start LCD backlight test"},
+ {TEST_LCDBACKLIGHT, MSG_DEVICETEST_LCDBACKLIGHT_STOP, Amt_Test_LCDBacklight_Stop, "Stop LCD backlight test"},
+ // Vibrator
+ {TEST_VIBRATOR, MSG_DEVICETEST_VIBRATOR_START, Amt_Test_Vibrator_Start, "Start vibrator test"},
+ {TEST_VIBRATOR, MSG_DEVICETEST_VIBRATOR_STOP, Amt_Test_Vibrator_Stop, "Stop vibrator test"},
+ // SIM
+ //{TEST_SIM, MSG_DEVICETEST_SIM_READ, Amt_Test_SIM_Read, "SIM card test"},
+ // SD
+ //{TEST_SD, MSG_DEVICETEST_SD_READ, Amt_Test_SD_Read, "SD card test"},
+
+ //Battery
+ {TEST_BATTERY, MSG_DEVICETEST_BATTERY_VOLTAGE, Amt_Test_Battery_Voltage, "Battery voltage test"},
+ {TEST_BATTERY, MSG_DEVICETEST_BATTERY_TEMPERATURE, Amt_Test_Battery_Temperature, "Battery temperature test"},
+ //Charger
+ {TEST_CHARGER, MSG_DEVICETEST_CHARGER_STATUS, Amt_Test_Charger_Status, "Charger status test"},
+ #if 0
+ // Keybacklight
+ {TEST_KEYBACKLIGHT, MSG_DEVICETEST_KEYBACKLIGHT_START, Amt_Test_KeyBacklight_Start, "Start Key backlight test"},
+ {TEST_KEYBACKLIGHT, MSG_DEVICETEST_KEYBACKLIGHT_STOP, Amt_Test_KeyBacklight_Stop, "Stop Key backlight test"},
+ #endif
+ // Camera
+ {TEST_CAMERA_BACK, MSG_DEVICETEST_CAMERA_BACK_START, Amt_Test_Camera_Back_Start, "Start back camera test"},
+ //{TEST_CAMERA_BACK, MSG_DEVICETEST_CAMERA_BACK_SNAPSHOT, Amt_Test_Camera_Back_Snapshot, "Back camera snapshot test"},
+ {TEST_CAMERA_BACK, MSG_DEVICETEST_CAMERA_BACK_STOP, Amt_Test_Camera_Back_Stop, "Stop back camera test"},
+ {TEST_CAMERA_BACK, MSG_DEVICETEST_CAMERA_BOARD, Amt_Test_Camera_Board, "Board camera test"},
+ // Audio
+ // Audio
+#ifdef _USE_VOICE_SUPPORT
+ {TEST_AUDIO, MSG_DEVICETEST_AUDIO_MIC_RECEIVER, Amt_Test_Audio_Mic_Receiver, "Mic-Receiver test"},
+ {TEST_AUDIO, MSG_DEVICETEST_AUDIO_MIC_RECEIVER_STOP, Amt_Test_Audio_Mic_Receiver_Stop, "Stop Mic-Receiver test"},
+ {TEST_AUDIO, MSG_DEVICETEST_AUDIO_MIC_SPEAKER, Amt_Test_Audio_Mic_Speaker, "Mic-Speaker test"},
+ {TEST_AUDIO, MSG_DEVICETEST_AUDIO_MIC_SPEAKER_STOP, Amt_Test_Audio_Mic_Speaker_Stop, "Stop Mic-Speaker test"},
+ //{TEST_AUDIO, MSG_DEVICETEST_AUDIO_HEADSET_HEADSET, Amt_Test_Audio_Headset_Headset, "Headset test"},
+#endif
+ // TP
+ {TEST_TP, MSG_DEVICETEST_TP_START, Amt_Test_TP_Start, "Start TP test"},
+ {TEST_TP, MSG_DEVICETEST_TP_STOP, Amt_Test_TP_Stop, "Stop TP test"},
+ {TEST_TP, MSG_DEVICETEST_TP_BOARD, Amt_Test_TP_Board, "Board TP test"},
+ // G-Sensor
+ {TEST_GSENSOR, MSG_DEVICETEST_GSENSOR_START, Amt_Test_GSensor_Start, "Start G-Sensor test"},
+ {TEST_GSENSOR, MSG_DEVICETEST_GSENSOR_STOP, Amt_Test_GSensor_Stop, "Stop G-Sensor test"},
+ {TEST_GSENSOR, MSG_DEVICETEST_GSENSOR_BOARD, Amt_Test_GSensor_Board, "Board G-Sensor test"},
+ // flashlight
+ {TEST_FLASH_LIGHT, MSG_DEVICETEST_FLASHLIGHT_START, Amt_Test_Flashlight_Start, "Flashlight test"},
+ // wifi
+ {TEST_WIFI, MSG_DEVICETEST_WIFI, Amt_Test_Wifi, "wifi test"}
+};
+
+static const int g_CmdTableCount = sizeof(g_CmdTable) / sizeof(T_COMMAND);
+
+/**
+ * @brief AMTÍâÉè²âÊÔ³õʼ»¯
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_DeviceTest_Init(void)
+{
+ AmtPrintf(AMT_INFO "%s", __FUNCTION__);
+ return 0;
+}
+
+
+/**
+ * @brief AMTÍâÉèÏûÏ¢´¦Àíº¯Êý
+ * @param[in] msg_id FID
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_DeviceTest_ProcessMsg(unsigned int msg_id, unsigned char* msg_buf, unsigned int msg_len)
+{
+ int i;
+
+ AmtPrintf(AMT_INFO "%s: Device test message: %#04x.\n", __FUNCTION__, msg_id);
+
+ for (i = 0; i < g_CmdTableCount; i++)
+ {
+ if (msg_id == g_CmdTable[i].msg_id)
+ {
+ if (g_CmdTable[i].fun != NULL)
+ {
+ AmtPrintf(AMT_INFO "%s: %s.\n", __FUNCTION__, g_CmdTable[i].test_name);
+ if (g_CmdTable[i].fun(msg_id, msg_buf, msg_len) == AMT_SUCCESS_RET)
+ {
+ //AmtPrintf(AMT_INFO "%s: %s success.\n", __FUNCTION__, g_CmdTable[i].test_name);
+ return 0;
+ }
+ else
+ {
+ //AmtPrintf(AMT_ERROR "%s: %s fail.\n", __FUNCTION__, g_CmdTable[i].test_name);
+ return -1;
+ }
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ }
+
+ AmtPrintf(AMT_ERROR "%s: Can't find the message: %#04x.\n", __FUNCTION__, msg_id);
+ return -1;
+}
+
+
+/**
+ * @brief AMTÍâÉèÏûÏ¢·´À¡¸øPC
+ * @param[in] msg_id FID
+ * @param[in] result ״̬Âë
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_DeviceTest_SendMsg(unsigned int msg_id, int result, unsigned char* msg_buf, unsigned int msg_len)
+{
+ unsigned int nRspLen = sizeof(T_DeviceTest_Header) + msg_len;
+ T_DeviceTest_Header *pHeader = (T_DeviceTest_Header *)malloc(nRspLen);
+
+ if (pHeader != NULL)
+ {
+ pHeader->result = result;
+ pHeader->length = msg_len;
+
+ if (msg_buf != NULL && msg_len > 0)
+ {
+ memcpy(pHeader + 1, msg_buf, msg_len);
+ }
+
+ if(Amt_CreateResponse(msg_id, (unsigned char *)pHeader, nRspLen) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ free(pHeader);
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+
diff --git a/ap/app/zte_amt/amt_agent_devicetest.h b/ap/app/zte_amt/amt_agent_devicetest.h
new file mode 100755
index 0000000..11f7e72
--- /dev/null
+++ b/ap/app/zte_amt/amt_agent_devicetest.h
@@ -0,0 +1,204 @@
+/**
+ *
+ * @file amt_agent_devicetest.h
+ * @brief
+ * This file is part of FTM.
+ * AMT´úÀíÓ¦Óòã
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2016/12/12 1.0 lu.xieji Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+#ifndef _AMT_AGENT_DEVICETEST_H
+#define _AMT_AGENT_DEVICETEST_H
+//#include "zcore_type.h"
+
+
+
+//#include "amt_agent_ref.h"
+
+// TestItem: 1~100
+#define TEST_COMMON 0
+#define TEST_INFO 1
+#define TEST_KEYBOARD 2
+#define TEST_LCD 3
+#define TEST_LCDBACKLIGHT 4
+#define TEST_VIBRATOR 5
+#define TEST_SIM 6
+#define TEST_SD 7
+#define TEST_BATTERY 8
+#define TEST_KEYBACKLIGHT 9
+#define TEST_CAMERA_BACK 10
+#define TEST_CAMERA_FRONT 11
+#define TEST_AUDIO 12
+#define TEST_TP 13
+#define TEST_GSENSOR 14
+#define TEST_CHARGER 15
+#define TEST_FLASH_LIGHT 16
+#define TEST_WIFI 17
+
+
+// Common
+#define MSG_DEVICETEST_STATUS_IDLE (MSG_DEVICETEST_START + 0x00)
+#define MSG_DEVICETEST_TESTINIT (MSG_DEVICETEST_START + 0x01)
+
+// Test info
+#define MSG_DEVICETEST_TESTINFO (MSG_DEVICETEST_START + 0x20)
+// Keyboard
+#define MSG_DEVICETEST_KEYBOARD_START (MSG_DEVICETEST_START + 0x30)
+#define MSG_DEVICETEST_KEYBOARD_STOP (MSG_DEVICETEST_START + 0x31)
+#define MSG_DEVICETEST_KEYBOARD_READ (MSG_DEVICETEST_START + 0x32)
+
+// LCD
+#define MSG_DEVICETEST_LCD_START (MSG_DEVICETEST_START + 0x40)
+#define MSG_DEVICETEST_LCD_STOP (MSG_DEVICETEST_START + 0x41)
+//µ¥°åLCD²âÊÔ
+#define MSG_DEVICETEST_LCD_BOARD (MSG_DEVICETEST_START + 0x42)
+
+// LCD backlight
+#define MSG_DEVICETEST_LCDBACKLIGHT_START (MSG_DEVICETEST_START + 0x50)
+#define MSG_DEVICETEST_LCDBACKLIGHT_STOP (MSG_DEVICETEST_START + 0x51)
+// Vibrator
+#define MSG_DEVICETEST_VIBRATOR_START (MSG_DEVICETEST_START + 0x60)
+#define MSG_DEVICETEST_VIBRATOR_STOP (MSG_DEVICETEST_START + 0x61)
+// SIM
+#define MSG_DEVICETEST_SIM_READ (MSG_DEVICETEST_START + 0x70)
+// SD
+#define MSG_DEVICETEST_SD_READ (MSG_DEVICETEST_START + 0x80)
+// Battery&charger
+#define MSG_DEVICETEST_BATTERY_VOLTAGE (MSG_DEVICETEST_START + 0x90)
+#define MSG_DEVICETEST_BATTERY_TEMPERATURE (MSG_DEVICETEST_START + 0x91)
+#define MSG_DEVICETEST_CHARGER_STATUS (MSG_DEVICETEST_START + 0x92)
+// Keybacklight
+#define MSG_DEVICETEST_KEYBACKLIGHT_START (MSG_DEVICETEST_START + 0xA0)
+#define MSG_DEVICETEST_KEYBACKLIGHT_STOP (MSG_DEVICETEST_START + 0xA1)
+// Camera
+#define MSG_DEVICETEST_CAMERA_BACK_START (MSG_DEVICETEST_START + 0xB0)
+#define MSG_DEVICETEST_CAMERA_BACK_SNAPSHOT (MSG_DEVICETEST_START + 0xB1)
+#define MSG_DEVICETEST_CAMERA_BACK_STOP (MSG_DEVICETEST_START + 0xB2)
+//µ¥°åÉãÏñÍ·²âÊÔ
+#define MSG_DEVICETEST_CAMERA_BOARD (MSG_DEVICETEST_START + 0xB3)
+// Audio
+#define MSG_DEVICETEST_AUDIO_MIC_RECEIVER (MSG_DEVICETEST_START + 0xC0)
+#define MSG_DEVICETEST_AUDIO_MIC_SPEAKER (MSG_DEVICETEST_START + 0xC1)
+#define MSG_DEVICETEST_AUDIO_HEADSET_HEADSET (MSG_DEVICETEST_START + 0xC2)
+//È˹¤²âÊÔÀ®°ÈºÍÂó¿ËÌí¼ÓÍ£Ö¹²âÊÔÏûÏ¢
+#define MSG_DEVICETEST_AUDIO_MIC_RECEIVER_STOP (MSG_DEVICETEST_START + 0xC3)
+#define MSG_DEVICETEST_AUDIO_MIC_SPEAKER_STOP (MSG_DEVICETEST_START + 0xC4)
+// Flashlight
+#define MSG_DEVICETEST_FLASHLIGHT_START (MSG_DEVICETEST_START + 0xD0)
+#define MSG_DEVICETEST_FLASHLIGHT_STOP (MSG_DEVICETEST_START + 0xD1)
+// TP´¥ÃþÆÁ
+#define MSG_DEVICETEST_TP_START (MSG_DEVICETEST_START + 0xE0)
+#define MSG_DEVICETEST_TP_STOP (MSG_DEVICETEST_START + 0xE1)
+//µ¥°åTP²âÊÔ
+#define MSG_DEVICETEST_TP_BOARD (MSG_DEVICETEST_START + 0xE2)
+// G-Sensor
+#define MSG_DEVICETEST_GSENSOR_START (MSG_DEVICETEST_START + 0xF0)
+#define MSG_DEVICETEST_GSENSOR_STOP (MSG_DEVICETEST_START + 0xF1)
+//µ¥°åG-Sensor²âÊÔ
+#define MSG_DEVICETEST_GSENSOR_BOARD (MSG_DEVICETEST_START + 0xF2)
+//WiFi²âÊÔ(ËÑÈȵã)
+#define MSG_DEVICETEST_WIFI (MSG_DEVICETEST_START + 0x100)
+
+
+
+#define AMT_SUCCESS_RET (0)
+#define AMT_ERROR_RET (-1)
+
+//µ¥°å¹¦ÄܲâÊÔʹÓõÄһЩÉ豸·¾¶
+#define TP_MODE_PATH "/sys/class/input/input2/tp_mode"
+#define DEVICE_GSENSOR "/dev/mir3da"
+#define DEVICE_CAMERA "/dev/camera_device"
+#define BATTERY_TEMPERATURE_PATH "/sys/class/power_supply/battery/temp"
+#define CHARGER_STATUS_PATH "/sys/class/power_supply/charger/status"
+#define DEVICE_LCD "/dev/fb0"
+
+
+
+
+typedef int (*process_func)(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len);
+
+typedef struct
+{
+ unsigned int item_id;
+ unsigned int msg_id;
+ process_func fun;
+ char *test_name;
+} T_COMMAND;
+
+enum
+{
+ LCD_COLOR_WHITE = 0,
+ LCD_COLOR_RED,
+ LCD_COLOR_GREEN,
+ LCD_COLOR_BLUE,
+ LCD_COLOR_BLACK,
+ MAX_LCD_COLOR_NUM
+};
+
+typedef struct
+{
+ int result;
+ int length;
+} T_DeviceTest_Header;
+/*
+typedef struct
+{
+ SINT32 keyValue;
+ BOOL keyFlag;
+ SINT32 staticID;
+}T_ZWndEm_CheckKey;
+*/
+
+/**
+ * @brief AMTÍâÉè²âÊÔ³õʼ»¯
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_DeviceTest_Init(void);
+
+/**
+ * @brief AMTÍâÉèÏûÏ¢´¦Àíº¯Êý
+ * @param[in] msg_id FID
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_DeviceTest_ProcessMsg(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len);
+
+/**
+ * @brief AMTÍâÉèÏûÏ¢·´À¡¸øPC
+ * @param[in] msg_id FID
+ * @param[in] result ״̬Âë
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_DeviceTest_SendMsg(unsigned int msg_id, int result, unsigned char *msg_buf, unsigned int msg_len);
+
+#endif
+
diff --git a/ap/app/zte_amt/amt_custom_test.c b/ap/app/zte_amt/amt_custom_test.c
new file mode 100644
index 0000000..bf9f296
--- /dev/null
+++ b/ap/app/zte_amt/amt_custom_test.c
@@ -0,0 +1,69 @@
+/**
+ *
+ * @file amt_custom_test.c
+ * @brief
+ * This file is part of FTM.
+ * AMT´úÀíÓ¦Óòã
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2015/04/28 1.0 lu.xieji Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include "amt.h"
+
+/**
+ * @brief AMT×Ô¶¨Òå²âÊÔ³õʼ»¯
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_Custom_Init(void)
+{
+ return 0;
+}
+
+
+/**
+ * @brief AMT×Ô¶¨ÒåÏûÏ¢´¦Àíº¯Êý
+ * @param[in] msg_id FID
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_Custom_ProcessMsg(unsigned int msg_id, unsigned char* msg_buf, unsigned int msg_len)
+{
+ UNUSED(msg_buf);
+ UNUSED(msg_len);
+
+ AmtPrintf(AMT_INFO "%s: Custom message: %#04x.\n", __FUNCTION__, msg_id);
+ //Amt_CreateResponse(msg_id, NULL, 0);
+ return 0;
+}
+
+
diff --git a/ap/app/zte_amt/amt_func_test.c b/ap/app/zte_amt/amt_func_test.c
new file mode 100755
index 0000000..f4626e2
--- /dev/null
+++ b/ap/app/zte_amt/amt_func_test.c
@@ -0,0 +1,319 @@
+/**
+ *
+ * @file amt_func_test.c
+ * @brief
+ * This file is part of FTM.
+ * AMT´úÀíÓ¦Óòã
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2020/11/25
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2020/11/25 1.0 liu.xin Create file
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+
+#include <sys/msg.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/types.h>
+#include <semaphore.h>
+#include <time.h>
+#include <sys/stat.h>
+#include "softap_api.h"
+#include "kwatch_msg.h"
+#include "amt.h"
+#include "amt_func_test.h"
+#include "port_com.h"
+
+
+
+
+
+static fd_set g_uart_fdsread;
+static int g_uart_fd_max = 0;
+static int g_fd_uart0 = -1;
+static int g_fd_uart1 = -1;
+static int g_fd_uart2 = -1;
+static int g_close_uart = 0;
+
+
+
+
+
+static void set_fd(int fd)
+{
+ FD_SET(fd, &g_uart_fdsread);
+ if (fd >= g_uart_fd_max)
+ {
+ g_uart_fd_max = fd + 1;
+ }
+}
+
+static void clr_fd(int fd)
+{
+ FD_CLR(fd, &g_uart_fdsread);
+}
+
+static int init_uart_device(char*uart_path)
+{
+
+ int fd = open(uart_path, O_RDWR);
+
+ if (fd < 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to open \"%s\"!\n", uart_path);
+ return -1;
+ }
+
+ uart_set(fd);
+ return fd;
+}
+
+/**
+ * @brief ¶ÁÈ¡uart Êý¾ÝµÄÏ̺߳¯Êý
+ * @param[in] args Ï̺߳¯Êý²ÎÊý
+ * @return N/A
+ * @note
+ * @see
+ */
+static void* ReadUartThread(void* args)
+{
+ int ret = -1;
+ int read_len = 0;
+ char *receive_buffer = malloc(MAX_UART_DATA_LENGTH);
+ UNUSED(args);
+ if (receive_buffer == NULL)
+ {
+ return NULL;
+ }
+ memset(receive_buffer,0,MAX_UART_DATA_LENGTH);
+
+ while (!g_close_uart)
+ {
+ ret = select(g_uart_fd_max, &g_uart_fdsread, NULL, NULL, NULL);
+ if (ret <= 0)
+ {
+ AmtPrintf(AMT_ERROR "select error: %s!\n", strerror(errno));
+ continue;
+ }
+
+ if (g_fd_uart0 >= 0 && FD_ISSET(g_fd_uart0, &g_uart_fdsread))
+ {
+ memset(receive_buffer,0,MAX_UART_DATA_LENGTH);
+ read_len = PortRecv(g_fd_uart0, (unsigned char *)receive_buffer, MAX_UART_DATA_LENGTH - 1, NO_WAIT);
+ if(read_len > 0)
+ {
+ receive_buffer[read_len] = '\0';
+ AmtPrintf(AMT_INFO "ttyS0 receive[%s]\n", receive_buffer);
+ if(!strcmp(receive_buffer,"amt uart test\r\n"))
+ {
+ PortSend(g_fd_uart0, "ttyS0 test OK!", strlen("ttyS0 test OK!"), WAIT_ALL);
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "ttyS0 input error!\n");
+ }
+
+ }
+ }
+ if (g_fd_uart1 >= 0 && FD_ISSET(g_fd_uart1, &g_uart_fdsread))
+ {
+ memset(receive_buffer,0,MAX_UART_DATA_LENGTH);
+ read_len = PortRecv(g_fd_uart1, (unsigned char *)receive_buffer, MAX_UART_DATA_LENGTH - 1, NO_WAIT);
+ if(read_len > 0)
+ {
+ receive_buffer[read_len] = '\0';
+ AmtPrintf(AMT_INFO "ttyS1 receive[%s]\n", receive_buffer);
+ if(!strcmp(receive_buffer,"amt uart test\r\n"))
+ {
+ PortSend(g_fd_uart1, "ttyS1 test OK!", strlen("ttyS1 test OK!"), WAIT_ALL);
+ }
+
+ else
+ {
+ AmtPrintf(AMT_ERROR "ttyS1 input error!\n");
+ }
+ }
+ }
+ if (g_fd_uart2 >= 0 && FD_ISSET(g_fd_uart2, &g_uart_fdsread))
+ {
+ memset(receive_buffer,0,MAX_UART_DATA_LENGTH);
+ read_len = PortRecv(g_fd_uart2, (unsigned char *)receive_buffer, MAX_UART_DATA_LENGTH - 1, NO_WAIT);
+ if(read_len > 0)
+ {
+ receive_buffer[read_len] = '\0';
+ AmtPrintf(AMT_INFO "ttyS2 receive[%s]\n", receive_buffer);
+ if(!strcmp(receive_buffer,"amt uart test\r\n"))
+ {
+ PortSend(g_fd_uart2, "ttyS2 test OK!", strlen("ttyS2 test OK!"), WAIT_ALL);
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "ttyS2 input error!\n");
+ }
+ }
+ }
+ }
+
+ free(receive_buffer);
+ receive_buffer = NULL;
+ return NULL;
+}
+
+
+
+
+/**
+ * @brief AMTÍâÉè²âÊÔ³õʼ»¯
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_FuncTest_Init(void)
+{
+ return 0;
+}
+
+/**
+ * @brief AMTÍâÉèÏûÏ¢´¦Àíº¯Êý
+ * @param[in] msg_id FID
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_FuncTest_ProcessMsg(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ unsigned char result = 1;
+
+ switch(msg_id)
+ {
+ case FID_OPEN_UART:
+ {
+ //´ò¿ª´®¿Ú
+ g_close_uart = 0;
+ FD_ZERO(&g_uart_fdsread);
+ g_fd_uart0 = init_uart_device(UART0_DEV);
+ AmtPrintf(AMT_INFO "g_fd_uart0 = %d.\n", g_fd_uart0);
+ if (g_fd_uart0 >= 0)
+ {
+ set_fd(g_fd_uart0);
+ }
+ g_fd_uart1 = init_uart_device(UART1_DEV);
+ AmtPrintf(AMT_INFO "g_fd_uart1 = %d.\n", g_fd_uart1);
+ if (g_fd_uart1 >= 0)
+ {
+ set_fd(g_fd_uart1);
+ }
+ g_fd_uart2 = init_uart_device(UART2_DEV);
+ AmtPrintf(AMT_INFO "g_fd_uart2 = %d.\n", g_fd_uart2);
+ if (g_fd_uart2 >= 0)
+ {
+ set_fd(g_fd_uart2);
+ }
+ if((g_fd_uart0 == -1)&&(g_fd_uart1 == -1)&&(g_fd_uart2 == -1))
+ {
+ unsigned char ret = 1;
+ if (Amt_CreateResponse(msg_id, (unsigned char*)&ret, sizeof(unsigned char)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else
+ {
+ unsigned char ret = 0;
+ if (Amt_CreateResponse(msg_id, (unsigned char*)&ret, sizeof(unsigned char)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ //´´½¨Ï̼߳àÌý´®¿Ú
+
+ pthread_t uart_read_thread;
+ if (pthread_create(&uart_read_thread, NULL, ReadUartThread, NULL) != 0)
+ {
+ AmtPrintf(AMT_ERROR "Failed to create uart read thread!\n");
+ return -1;
+ }
+
+ }
+
+ break;
+ }
+ case FID_CLOSE_UART:
+ {
+ AmtPrintf(AMT_INFO "receive FID_CLOSE_UART\n");
+ g_close_uart = 1;
+ if (g_fd_uart0 >= 0)
+ {
+ close(g_fd_uart0);
+ }
+ if (g_fd_uart1 >= 0)
+ {
+ close(g_fd_uart1);
+ }
+ if (g_fd_uart2 >= 0)
+ {
+ close(g_fd_uart2);
+ }
+ if (Amt_CreateResponse(msg_id, NULL, 0) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ break;
+ }
+ default:
+ break;
+
+ }
+
+ return 0;
+}
+
+/**
+ * @brief AMTÍâÉèÏûÏ¢·´À¡¸øPC
+ * @param[in] msg_id FID
+ * @param[in] result ״̬Âë
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_FuncTest_SendMsg(unsigned int msg_id, int result, unsigned char *msg_buf, unsigned int msg_len)
+{
+ return 0;
+}
+
+
diff --git a/ap/app/zte_amt/amt_func_test.h b/ap/app/zte_amt/amt_func_test.h
new file mode 100755
index 0000000..f4eb2ff
--- /dev/null
+++ b/ap/app/zte_amt/amt_func_test.h
@@ -0,0 +1,78 @@
+/**
+ *
+ * @file amt_func_test.h
+ * @brief
+ * This file is part of FTM.
+ * AMT´úÀíÓ¦Óòã
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2020/11/25
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2020/11/25 1.0 liu.xin Create file
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+#ifndef _AMT_FUNC_TEST_H
+#define _AMT_FUNC_TEST_H
+
+//´®¿Ú²âÊÔ
+#define FID_OPEN_UART (FID_FUN_TEST_START + 6)
+#define FID_CLOSE_UART (FID_FUN_TEST_START + 7)
+#define UART0_DEV "/dev/ttyS0"
+#define UART1_DEV "/dev/ttyS1"
+#define UART2_DEV "/dev/ttyS2"
+#define MAX_UART_DATA_LENGTH (1024)
+
+
+
+
+
+
+
+/**
+ * @brief AMTÍâÉè²âÊÔ³õʼ»¯
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_FuncTest_Init(void);
+
+/**
+ * @brief AMTÍâÉèÏûÏ¢´¦Àíº¯Êý
+ * @param[in] msg_id FID
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_FuncTest_ProcessMsg(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len);
+
+/**
+ * @brief AMTÍâÉèÏûÏ¢·´À¡¸øPC
+ * @param[in] msg_id FID
+ * @param[in] result ״̬Âë
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_FuncTest_SendMsg(unsigned int msg_id, int result, unsigned char *msg_buf, unsigned int msg_len);
+
+#endif
+
diff --git a/ap/app/zte_amt/amt_gps_test.c b/ap/app/zte_amt/amt_gps_test.c
new file mode 100644
index 0000000..d2be2dc
--- /dev/null
+++ b/ap/app/zte_amt/amt_gps_test.c
@@ -0,0 +1,124 @@
+/**
+ *
+ * @file amt_gps_test.c
+ * @brief
+ * This file is part of FTM.
+ * AMT´úÀíÓ¦Óòã
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2015/04/28 1.0 lu.xieji Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+
+#include <sys/msg.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/types.h>
+#include <semaphore.h>
+#include <time.h>
+#include <sys/stat.h>
+#include "softap_api.h"
+#include "kwatch_msg.h"
+#include "amt.h"
+
+/**
+ * @brief AMT²âÊÔGPS³õʼ»¯
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_Gps_Init(void)
+{
+ return 0;
+}
+
+
+/**
+ * @brief AMT´¦ÀíGPSÏûÏ¢º¯Êý
+ * @param[in] msg_id FID
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_Gps_ProcessMsg(unsigned int msg_id, unsigned char *msg_buf, unsigned int msg_len)
+{
+ UNUSED(msg_len);
+
+ switch(msg_id)
+ {
+ case FID_GPS_MODULE_TEST:
+ {
+ AmtPrintf(AMT_INFO "%s: MODULE_ID_AMT=%d,MODULE_ID_GPS=%d\n", __FUNCTION__,MODULE_ID_AMT,MODULE_ID_GPS);
+ AmtPrintf(AMT_INFO "%s: KWATCH_MSG_GPS_PWR_SET_REQ=%d\n", __FUNCTION__,KWATCH_MSG_GPS_PWR_SET_REQ);
+ unsigned char Flag = 0;
+ memcpy(&Flag,msg_buf,sizeof(unsigned char));
+ if(Flag == 1) //´ò¿ªgps
+ {
+ char buf[] = {"1"};
+ ipc_send_message2(MODULE_ID_AMT, MODULE_ID_GPS, KWATCH_MSG_GPS_PWR_SET_REQ, sizeof(buf), (unsigned char*)buf, 0);
+ }
+ else if(Flag == 0) //¹Ø±Õgps
+ {
+ char buf[] = {"0"};
+ ipc_send_message2(MODULE_ID_AMT, MODULE_ID_GPS, KWATCH_MSG_GPS_PWR_SET_REQ, sizeof(buf), (unsigned char*)buf, 0);
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: param error!\n", __FUNCTION__);
+ return -1;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return 0;
+}
+
+/**
+ * @brief AMT·´À¡GPSÏûÏ¢¸øPC
+ * @param[in] msg_id FID
+ * @param[in] msg ÏûÏ¢Ìå
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_Process_Gps_Rsp(MSG_BUF *msg, unsigned int msg_id)
+{
+ unsigned char *buf = msg->aucDataBuf;
+ AmtPrintf(AMT_INFO "%s: receive data= %s,datalen=%d.\n", __FUNCTION__,buf,msg->usDataLen);
+ if (Amt_CreateResponse(msg_id, buf, msg->usDataLen) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ return 0;
+}
+
diff --git a/ap/app/zte_amt/amt_wifi_test.c b/ap/app/zte_amt/amt_wifi_test.c
new file mode 100755
index 0000000..0aecd40
--- /dev/null
+++ b/ap/app/zte_amt/amt_wifi_test.c
@@ -0,0 +1,194 @@
+/**
+ *
+ * @file amt_wifi_test.c
+ * @brief
+ * This file is part of FTM.
+ * AMT´úÀíÓ¦Óòã
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2015/04/28 1.0 lu.xieji Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include "amt.h"
+
+#define MAX_CMD_BUFFER_LENGTH 256
+#define MAX_RECV_BUFFER_LENGTH 2048
+
+//static char g_CmdBuffer[MAX_CMD_BUFFER_LENGTH];
+//static char g_RecvBuffer[MAX_RECV_BUFFER_LENGTH];
+
+/**
+ * @brief AMT²âÊÔWIFI³õʼ»¯
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_Wifi_Init(void)
+{
+ return 0;
+}
+
+int wifi_ioctl_handle(int cmd)
+{
+ int fd = -1;
+ int ret = 0;
+ fd = open("/dev/wifi_device", O_RDWR);
+ if (fd < 0)
+ return -1;
+ ret = ioctl(fd, cmd);
+ if (ret < 0)
+ printf("ioctl wifi_device err:%d\n", ret);
+ close(fd);
+ return ret;
+}
+
+
+
+/**
+ * @brief AMT´¦ÀíWIFIÏûÏ¢º¯Êý
+ * @param[in] msg_id FID
+ * @param[in] msg_buf ½ÓÊÕÊý¾Ýbuffer
+ * @param[in] msg_len ½ÓÊÕÊý¾Ýbuffer³¤¶È
+ * @return ³É¹¦·µ»Ø0, ʧ°Ü·µ»Ø-1
+ * @note
+ * @see
+ */
+int Amt_Wifi_ProcessMsg(unsigned int msg_id, unsigned char* msg_buf, unsigned int msg_len)
+{
+ char*pCmdBuffer = malloc(MAX_CMD_BUFFER_LENGTH);
+ if (pCmdBuffer == NULL)
+ {
+ AmtPrintf(AMT_ERROR "%s: malloc pCmdBuffer failure.\n", __FUNCTION__);
+ return -1;
+ }
+ char*pRecvBuffer = malloc(MAX_RECV_BUFFER_LENGTH);
+ if (pRecvBuffer == NULL)
+ {
+ AmtPrintf(AMT_ERROR "%s: malloc pRecvBuffer failure.\n", __FUNCTION__);
+ free(pCmdBuffer);
+ return -1;
+ }
+ memcpy(pCmdBuffer, msg_buf, msg_len);
+ pCmdBuffer[msg_len] = '\0';
+
+ memset(pRecvBuffer, 0, MAX_RECV_BUFFER_LENGTH);
+
+ AmtPrintf(AMT_INFO "%s: cmd=%s.\n", __FUNCTION__, pCmdBuffer);
+
+ // sv6158 load firmware
+ if ((strcmp(pCmdBuffer, "insmod ./lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/ssv6x5x/ssv6x5x.ko stacfgpath=/etc/firmware/ssv6x5x-wifi.cfg") == 0)||
+ (strcmp(pCmdBuffer, "insmod ./lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/ssv6x5x/prealloc/ssv6xxx_prealloc_skb.ko") == 0)||
+ (strcmp(pCmdBuffer, "insmod ./lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/ssv6x5x/ssv6x5x_host/ssv6x5x.ko stacfgpath=/etc/firmware/ssv6x5x-wifi.cfg") == 0))
+ {
+ static int load_flag = 0;
+ AmtPrintf(AMT_INFO "%s: recv insmod cmd=%s.\n", __FUNCTION__, pCmdBuffer);
+ if(load_flag == 0)
+ {
+ int ret = wifi_ioctl_handle(1);
+ load_flag = 1;
+ if(ret < 0)
+ {
+ AmtPrintf(AMT_ERROR "%s: load sv6158 firmware fail! ret=%d.\n", __FUNCTION__, ret);
+ free(pCmdBuffer);
+ free(pRecvBuffer);
+ return -1;
+ }
+ else
+ {
+ if (Amt_CreateResponse(msg_id, &ret, sizeof(ret)) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+
+ free(pCmdBuffer);
+ free(pRecvBuffer);
+
+ return 0;
+ }
+
+ }
+ else
+ {
+ free(pCmdBuffer);
+ free(pRecvBuffer);
+ return 0;
+ }
+ }
+
+
+ int read_len = Amt_ExecuteCmd(pCmdBuffer, pRecvBuffer, MAX_RECV_BUFFER_LENGTH);
+
+ if (read_len > 0)
+ {
+ // Ç¿ÖÆÔö¼Ó½áÊø·û
+ pRecvBuffer[MAX_RECV_BUFFER_LENGTH - 1] = '\0';
+
+ // Broadcom
+ if (strcmp(pCmdBuffer, "wl counters") == 0)
+ {
+ char pRxStr[] = "pktengrxdmcast";
+ char *ptr = strstr(pRecvBuffer, pRxStr);
+
+ if (ptr != NULL)
+ {
+ int packetsNum = 0;
+ sscanf(ptr, "%*[^ ]%d", &packetsNum);
+ memcpy(pRecvBuffer, &packetsNum, sizeof(packetsNum));
+ read_len = sizeof(packetsNum);
+ }
+ else
+ {
+ AmtPrintf(AMT_ERROR "%s: Can not find \"%s\".\n", __FUNCTION__, pRxStr);
+ free(pCmdBuffer);
+ free(pRecvBuffer);
+ return -1;
+ }
+ }
+
+ if (Amt_CreateResponse(msg_id, (unsigned char*)pRecvBuffer, read_len) == -1)
+ {
+ AmtPrintf(AMT_ERROR "%s: Send data failure.\n", __FUNCTION__);
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: Send data success.\n", __FUNCTION__);
+ }
+ }
+ else
+ {
+ AmtPrintf(AMT_INFO "%s: no return.\n", __FUNCTION__);
+ }
+ free(pCmdBuffer);
+ free(pRecvBuffer);
+ return 0;
+}
+
+
diff --git a/ap/app/zte_amt/fft.c b/ap/app/zte_amt/fft.c
new file mode 100644
index 0000000..0abe030
--- /dev/null
+++ b/ap/app/zte_amt/fft.c
@@ -0,0 +1,176 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <math.h>
+
+static void fft(short *data,double *x,double *y,unsigned short n,short sign)
+{
+ unsigned short i,j,k,l,m,n1,n2;
+ double c,c1,e,s,s1,t,tr,ti;
+ //Calculate i = log2N
+ for (i = 0;i < n;i++)
+ {
+ x[i] = data[i];
+ //zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL,"cal_freq_fft x[%d]=%f,data=%d!\n",i,x[i],data[i]);
+
+ }
+ for (j = 1,i = 1; i<20; i++)
+ {
+ m = i;
+ j = 2*j;
+ if (j == n)
+ break;
+ }
+
+ //¼ÆËãµûÐÎͼµÄÊäÈëϱ꣨Âëλµ¹¶Á£©
+ n1 = n - 1;
+ for (j=0,i=0; i<n1; i++)
+ {
+ if (i<j)
+ {
+ tr = x[j];
+ ti = y[j];
+ x[j] = x[i];
+ y[j] = y[i];
+ x[i] = tr;
+ y[i] = ti;
+ }
+ k = n/2;
+ while (k<(j+1))
+ {
+ j = j - k;
+ k = k/2;
+ }
+ j = j + k;
+ }
+ //¼ÆËãÿһ¼¶µÄÊä³ö£¬lΪijһ¼¶£¬iΪͬһ¼¶µÄ²»Í¬Èº£¬Ê¹ÓÃͬһÄڴ棨¼´Î»ÔËË㣩
+ n1 = 1;
+ for (l=1; l<=m; l++)
+ {
+ n1 = 2*n1;
+ n2 = n1/2;
+ e = 3.1415926/n2;
+ c = 1.0;
+ s = 0.0;
+ c1 = cos(e);
+ s1 = -sign*sin(e);
+ for (j=0; j<n2; j++)
+ {
+ for (i=j; i<n; i+=n1)
+ {
+ k = i + n2;
+ tr = c*x[k] - s*y[k];
+ ti = c*y[k] + s*x[k];
+ x[k] = x[i] - tr;
+ y[k] = y[i] - ti;
+ x[i] = x[i] + tr;
+ y[i] = y[i] + ti;
+ }
+ t = c;
+ c = c*c1 - s*s1;
+ s = t*s1 + s*c1;
+ }
+ }
+ //Èç¹ûÊÇÇóIFFT£¬ÔÙ³ýÒÔN
+ if (sign == -1)
+ {
+ for (i=0; i<n; i++)
+ {
+ x[i] /= n;
+ y[i] /= n;
+ }
+ }
+}
+static void max_fft(double *a,unsigned short n,unsigned short *h)
+{
+ unsigned short i = 0;
+ *h=5;
+ for (i=5;i<n;i++)
+ {
+ if (a[i]>a[*h])
+ *h=i;
+ }
+
+}
+
+static void abs_fft(double *x,double *y,unsigned short n,double *z)
+{
+ unsigned short i=0;
+
+ for (i= 0;i<n;i++)
+ {
+ z[i] =sqrt(x[i]*x[i]+y[i]*y[i]);
+ }
+
+
+
+}
+
+
+typedef struct
+{
+ double freqValue;
+ double freqAmp;
+}
+zDrvVp_Freqfft;
+
+int cal_freq_fft( short *data,zDrvVp_Freqfft *freqfft,unsigned short n, int fs)
+{
+ unsigned short h = 0;
+ unsigned short offset = 0;
+ double *x = NULL,*xi = NULL,*xvalue = NULL;
+ if ( data == NULL || freqfft == NULL || n <= 0 || fs < 0)
+ {
+ return -1;
+ }
+
+ if (n > 32768 || n < 2) // ÏÞÖÆÔÚ2µÄ1´ÎÃݵ½15´ÎÃÝ
+ return -1;
+
+ // ¼ì²énÊÇ·ñ2µÄÃÝ´Î
+ do
+ {
+ offset++;
+ h = n >> offset;
+ }while (h > 0);
+
+ if( n != (1 << (offset - 1))) return -1;
+
+ x=(double*)calloc(n, sizeof(double));
+ xi=(double*)calloc(n, sizeof(double));
+ xvalue=(double*)calloc(n, sizeof(double));
+
+ if(x && xi && xvalue)
+ {
+ fft(data,x,xi,n,1);
+ /*for(i=0;i<1024;i++)
+ {
+ zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL,"cal_freq_fft x[%d]=%f,xi[%d]=%f!\n",i,x[i],i,xi[i]);
+ }*/
+
+ abs_fft(x,xi,n/2,xvalue);
+ max_fft(xvalue,n/2,&h);
+ //zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL,"h=%d!\n",h);
+ freqfft->freqValue = (h-1)*fs/((n)*1.0);
+ freqfft->freqAmp = xvalue[h]/(n/2);
+ //*freqValue = (h-1)*fs/((n)*1.0);
+ //zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL,"n=%d!\n",n);
+ // freq = freqfft->freqValue;
+ //zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL,"fs=%d!\n",fs);
+ //zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL,"freq=%f!\n",freq);
+ //zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL,"freqfft->freqAmp=%f!\n",freqfft->freqAmp);
+
+
+ free(x);
+ free(xi);
+ free(xvalue);
+ return 0;
+ }
+
+ if(x) free(x);
+ if(xi) free(xi);
+ if(xvalue) free(xvalue);
+
+
+ return -1;
+}
diff --git a/ap/app/zte_amt/port_com.c b/ap/app/zte_amt/port_com.c
new file mode 100755
index 0000000..8136259
--- /dev/null
+++ b/ap/app/zte_amt/port_com.c
@@ -0,0 +1,401 @@
+/**
+ * ±¾³ÌÐò·ûºÏGPLÌõÔ¼
+ * Beneboy 2003-5-16
+ */
+#include <stdio.h> // printf
+#include <fcntl.h> // open
+#include <string.h> // bzero
+#include <stdlib.h> // exit
+#include <sys/times.h> // times
+#include <sys/types.h> // pid_t
+#include <termios.h> //termios, tcgetattr(), tcsetattr()
+#include <unistd.h>
+#include <sys/ioctl.h> // ioctl
+#include "port_com.h"
+#include "amt.h"
+
+// ½ÓÊÕ³¬Ê±
+#define TIMEOUT_SEC(buflen,baud) (buflen*20/baud+1)
+#define TIMEOUT_USEC 0
+
+// serial port information
+portinfo_t g_sPortInfo =
+{
+ '0', // print prompt after receiving
+ 115200, // baudrate: 115200
+ '8', // databit: 8
+ '0', // debug: off
+ '0', // echo: off
+ '0', // flow control: software
+ '0', // default tty: COM1
+ '0', // parity: none
+ '1', // stopbit: 1
+ 0 // reserved
+};
+
+/**
+ * ²¨ÌØÂÊת»¯×ª»»º¯Êý
+ */
+int convbaud(unsigned long int baudrate)
+{
+ switch (baudrate)
+ {
+ case 2400:
+ return B2400;
+ case 4800:
+ return B4800;
+ case 9600:
+ return B9600;
+ case 19200:
+ return B19200;
+ case 38400:
+ return B38400;
+ case 57600:
+ return B57600;
+ case 115200:
+ return B115200;
+ case 921600:
+ return B921600;
+ default:
+ return B9600;
+ }
+}
+
+/**
+ * Setup comm attr
+ * fd: ´®¿ÚÎļþÃèÊö·û, pportinfo: ´ýÉèÖõĶ˿ÚÐÅÏ¢s
+ *
+ */
+int PortSet(int fd)
+{
+ struct termios termios_old, termios_new;
+ int baudrate, tmp;
+ char databit, stopbit, parity, fctl;
+ bzero(&termios_old, sizeof(termios_old));
+ bzero(&termios_new, sizeof(termios_new));
+ cfmakeraw(&termios_new);
+ tcgetattr(fd, &termios_old); //get the serial port attributions
+ /*------------ÉèÖö˿ÚÊôÐÔ----------------*/
+ //baudrates
+ baudrate = convbaud(g_sPortInfo.baudrate);
+ cfsetispeed(&termios_new, baudrate); // ÌîÈë´®¿ÚÊäÈë¶Ë²¨ÌØÂÊ
+ cfsetospeed(&termios_new, baudrate); // ÌîÈë´®¿ÚÊä³ö¶Ë²¨ÌØÂÊ
+ termios_new.c_cflag |= CLOCAL; // ¿ØÖÆÄ£Ê½, ±£Ö¤³ÌÐò²»»á³ÉΪ¶Ë¿ÚµÄÕ¼ÓÐÕß
+ termios_new.c_cflag |= CREAD; // ¿ØÖÆÄ£Ê½, ʹÄܶ˿ڶÁÈ¡ÊäÈëµÄÊý¾Ý
+ // ¿ØÖÆÄ£Ê½, flow control
+ fctl = g_sPortInfo.fctl;
+ switch (fctl)
+ {
+ case '0':
+ {
+ termios_new.c_cflag &= ~CRTSCTS; //no flow control
+ }
+ break;
+ case '1':
+ {
+ termios_new.c_cflag |= CRTSCTS; //hardware flow control
+ }
+ break;
+ case '2':
+ {
+ termios_new.c_iflag |= IXON | IXOFF | IXANY; //software flow control
+ }
+ break;
+ default:
+ {
+ printf("Unknown fctl %c\n", fctl);
+ break;
+ }
+ }
+
+ // ¿ØÖÆÄ£Ê½, data bits
+ termios_new.c_cflag &= ~CSIZE; // ¿ØÖÆÄ£Ê½, ÆÁ±Î×Ö·û´óСλ
+ databit = g_sPortInfo.databit;
+ switch (databit)
+ {
+ case '5':
+ termios_new.c_cflag |= CS5;
+ //lint -fallthrough
+ case '6':
+ termios_new.c_cflag |= CS6;
+ //lint -fallthrough
+ case '7':
+ termios_new.c_cflag |= CS7;
+ //lint -fallthrough
+ default:
+ termios_new.c_cflag |= CS8;
+ }
+
+ // ¿ØÖÆÄ£Ê½ parity check
+ parity = g_sPortInfo.parity;
+ switch (parity)
+ {
+ case '0':
+ {
+ termios_new.c_cflag &= ~PARENB; // no parity check
+ }
+ break;
+ case '1':
+ {
+ termios_new.c_cflag |= PARENB; // odd check
+ termios_new.c_cflag &= ~PARODD;
+ }
+ break;
+ case '2':
+ {
+ termios_new.c_cflag |= PARENB; // even check
+ termios_new.c_cflag |= PARODD;
+ }
+ break;
+ default:
+ {
+ printf("Unknown parity %c\n", parity);
+ break;
+ }
+ }
+
+ // ¿ØÖÆÄ£Ê½, stop bits
+ stopbit = g_sPortInfo.stopbit;
+ if (stopbit == '2')
+ {
+ termios_new.c_cflag |= CSTOPB; // 2 stop bits
+ }
+ else
+ {
+ termios_new.c_cflag &= ~CSTOPB; // 1 stop bits
+ }
+
+ //other attributions default
+ termios_new.c_oflag &= ~OPOST; // Êä³öģʽ, ÔʼÊý¾ÝÊä³ö
+ termios_new.c_cc[VMIN] = 1; // ¿ØÖÆ×Ö·û, ËùÒª¶ÁÈ¡×Ö·ûµÄ×îСÊýÁ¿
+ termios_new.c_cc[VTIME] = 1; // ¿ØÖÆ×Ö·û, ¶ÁÈ¡µÚÒ»¸ö×Ö·ûµÄµÈ´ýʱ¼ä, unit: (1/10)second
+ tcflush(fd, TCIFLUSH); // Òç³öµÄÊý¾Ý¿ÉÒÔ½ÓÊÕ,µ«²»¶Á
+ tmp = tcsetattr(fd, TCSANOW, &termios_new); // ÉèÖÃÐÂÊôÐÔ, TCSANOW: ËùÓɸıäÁ¢¼´ÉúЧ
+ tcgetattr(fd, &termios_old);
+ return(tmp);
+}
+
+/**
+ * Open serial port
+ * tty: ¶Ë¿ÚºÅ ttyS0, ttyS1, ....
+ * ·µ»ØÖµÎª´®¿ÚÎļþÃèÊö·û
+ */
+int PortOpen(pportinfo_t pportinfo, int mode)
+{
+ UNUSED(pportinfo);
+ UNUSED(mode);
+
+ return 0;
+}
+
+/**
+ * Close serial port
+ */
+void PortClose(int fd)
+{
+ close(fd);
+}
+
+/**
+ * PortSend
+ * fd: ´®¿ÚÃèÊö·û,
+ * data: ´ý·¢ËÍÊý¾ÝÖ¸Õë
+ * datalen: Êý¾Ý³¤¶È
+ * flag: ·¢ËÍ·½Ê½±êʶ
+ * ·µ»ØÊµ¼Ê·¢Ëͳ¤¶È
+ */
+int PortSend(int fd, unsigned char* data, int datalen, int flag)
+{
+ int snRet = 0;
+
+ if (flag == WAIT_ALL)
+ {
+ int offset = 0;
+
+ while (offset < datalen)
+ {
+ snRet = write(fd, (data + offset), min(datalen - offset, 4096));
+ if (snRet > 0)
+ {
+ offset += snRet;
+ }
+ else
+ {
+ usleep(2*1000);
+ }
+ }
+
+ return offset;
+ }
+ else
+ {
+ snRet = write(fd, data, datalen);
+ return snRet;
+ }
+}
+
+/**
+ * PortRecv
+ * ²ÎÊý£º
+ * fd: ´®¿ÚÃèÊö·û,
+ * data: ´ý½ÓÊÕÊý¾ÝÖ¸Õë
+ * datalen: Êý¾Ý³¤¶È
+ * flag: ½ÓÊÕ·½Ê½±êʶ
+ * ·µ»ØÊµ¼Ê¶ÁÈëµÄ×Ö½ÚÊý
+ */
+int PortRecv(int fd, unsigned char* data, int datalen, int flag)
+{
+ int snRet = 0;
+
+ if (flag == WAIT_ALL)
+ {
+ int offset = 0;
+
+ while (offset < datalen)
+ {
+ snRet = read(fd, (data + offset), (datalen - offset));
+
+ if (snRet > 0)
+ {
+ offset += snRet;
+ }
+ else
+ {
+ return snRet;
+ }
+ }
+
+ return offset;
+ }
+ else
+ {
+ snRet = read(fd, data, datalen);
+ return snRet;
+ }
+}
+
+int uart_set(int fd)
+{
+ struct termios termios_old, termios_new;
+ int baudrate, tmp;
+ char databit, stopbit, parity, fctl;
+ portinfo_t uart_Info =
+ {
+ '0', // print prompt after receiving
+ 921600, // baudrate: 921600
+ '8', // databit: 8
+ '0', // debug: off
+ '0', // echo: off
+ '0', // flow control: software
+ '0', // default tty: COM1
+ '0', // parity: none
+ '1', // stopbit: 1
+ 0 // reserved
+ };
+ bzero(&termios_old, sizeof(termios_old));
+ bzero(&termios_new, sizeof(termios_new));
+ cfmakeraw(&termios_new);
+ tcgetattr(fd, &termios_old); //get the serial port attributions
+ /*------------ÉèÖö˿ÚÊôÐÔ----------------*/
+ //baudrates
+ baudrate = convbaud(uart_Info.baudrate);
+ cfsetispeed(&termios_new, baudrate); // ÌîÈë´®¿ÚÊäÈë¶Ë²¨ÌØÂÊ
+ cfsetospeed(&termios_new, baudrate); // ÌîÈë´®¿ÚÊä³ö¶Ë²¨ÌØÂÊ
+ termios_new.c_cflag |= CLOCAL; // ¿ØÖÆÄ£Ê½, ±£Ö¤³ÌÐò²»»á³ÉΪ¶Ë¿ÚµÄÕ¼ÓÐÕß
+ termios_new.c_cflag |= CREAD; // ¿ØÖÆÄ£Ê½, ʹÄܶ˿ڶÁÈ¡ÊäÈëµÄÊý¾Ý
+ // ¿ØÖÆÄ£Ê½, flow control
+ fctl = uart_Info.fctl;
+ switch (fctl)
+ {
+ case '0':
+ {
+ termios_new.c_cflag &= ~CRTSCTS; //no flow control
+ }
+ break;
+ case '1':
+ {
+ termios_new.c_cflag |= CRTSCTS; //hardware flow control
+ }
+ break;
+ case '2':
+ {
+ termios_new.c_iflag |= IXON | IXOFF | IXANY; //software flow control
+ }
+ break;
+ default:
+ {
+ printf("Unknown fctl %c\n", fctl);
+ break;
+ }
+ }
+
+ // ¿ØÖÆÄ£Ê½, data bits
+ termios_new.c_cflag &= ~CSIZE; // ¿ØÖÆÄ£Ê½, ÆÁ±Î×Ö·û´óСλ
+ databit = uart_Info.databit;
+ switch (databit)
+ {
+ case '5':
+ termios_new.c_cflag |= CS5;
+ //lint -fallthrough
+ case '6':
+ termios_new.c_cflag |= CS6;
+ //lint -fallthrough
+ case '7':
+ termios_new.c_cflag |= CS7;
+ //lint -fallthrough
+ default:
+ termios_new.c_cflag |= CS8;
+ }
+
+ // ¿ØÖÆÄ£Ê½ parity check
+ parity = uart_Info.parity;
+ switch (parity)
+ {
+ case '0':
+ {
+ termios_new.c_cflag &= ~PARENB; // no parity check
+ }
+ break;
+ case '1':
+ {
+ termios_new.c_cflag |= PARENB; // odd check
+ termios_new.c_cflag &= ~PARODD;
+ }
+ break;
+ case '2':
+ {
+ termios_new.c_cflag |= PARENB; // even check
+ termios_new.c_cflag |= PARODD;
+ }
+ break;
+ default:
+ {
+ printf("Unknown parity %c\n", parity);
+ break;
+ }
+ }
+
+ // ¿ØÖÆÄ£Ê½, stop bits
+ stopbit = uart_Info.stopbit;
+ if (stopbit == '2')
+ {
+ termios_new.c_cflag |= CSTOPB; // 2 stop bits
+ }
+ else
+ {
+ termios_new.c_cflag &= ~CSTOPB; // 1 stop bits
+ }
+
+ //other attributions default
+ termios_new.c_oflag &= ~OPOST; // Êä³öģʽ, ÔʼÊý¾ÝÊä³ö
+ termios_new.c_cc[VMIN] = 1; // ¿ØÖÆ×Ö·û, ËùÒª¶ÁÈ¡×Ö·ûµÄ×îСÊýÁ¿
+ termios_new.c_cc[VTIME] = 1; // ¿ØÖÆ×Ö·û, ¶ÁÈ¡µÚÒ»¸ö×Ö·ûµÄµÈ´ýʱ¼ä, unit: (1/10)second
+ tcflush(fd, TCIFLUSH); // Òç³öµÄÊý¾Ý¿ÉÒÔ½ÓÊÕ,µ«²»¶Á
+ tmp = tcsetattr(fd, TCSANOW, &termios_new); // ÉèÖÃÐÂÊôÐÔ, TCSANOW: ËùÓɸıäÁ¢¼´ÉúЧ
+ tcgetattr(fd, &termios_old);
+ return(tmp);
+
+}
+
+
+
diff --git a/ap/app/zte_amt/port_com.h b/ap/app/zte_amt/port_com.h
new file mode 100755
index 0000000..cacaafc
--- /dev/null
+++ b/ap/app/zte_amt/port_com.h
@@ -0,0 +1,80 @@
+/**
+ * ±¾³ÌÐò·ûºÏGPLÌõÔ¼
+ * Ò»×é²Ù×÷´®¿ÚµÄº¯Êý
+ * Beneboy 2003-5-16
+ */
+
+#ifndef _PORT_COM_H
+#define _PORT_COM_H
+
+
+typedef struct
+{
+ char prompt; // prompt after reciving data
+ int baudrate; // baudrate
+ char databit; // data bits, 5, 6, 7, 8
+ char debug; // debug mode, 0: none, 1: debug
+ char echo; // echo mode, 0: none, 1: echo
+ char fctl; // flow control, 0: none, 1: hardware, 2: software
+ char tty; // tty: 0, 1, 2, 3, 4, 5, 6, 7
+ char parity; // parity 0: none, 1: odd, 2: even
+ char stopbit; // stop bits, 1, 2
+ int reserved; // reserved, must be zero
+} portinfo_t, *pportinfo_t;
+
+
+typedef enum
+{
+ NO_WAIT = 0,
+ WAIT_ALL
+} WAIT_FLAG;
+
+/**
+ * ´ò¿ª´®¿Ú, ·µ»ØÎļþÃèÊö·û
+ * pportinfo: ´ýÉèÖõĴ®¿ÚÐÅÏ¢
+ */
+int PortOpen(pportinfo_t pportinfo,int mode);
+
+/**
+ * ¶Ë¿Ú³õʼ»¯
+ */
+int PortInit(int mode);
+/**
+ * ÉèÖô®¿Ú
+ * fdcom: ´®¿ÚÎļþÃèÊö·û, pportinfo: ´ýÉèÖõĴ®¿ÚÐÅÏ¢
+ */
+int PortSet(int fd);
+/**
+ * ¹Ø±Õ´®¿Ú
+ * fdcom: ´®¿ÚÎļþÃèÊö·û
+ */
+void PortClose(int fd);
+
+/**
+ * PortSend
+ * fd: ´®¿ÚÃèÊö·û,
+ * data: ´ý·¢ËÍÊý¾ÝÖ¸Õë
+ * datalen: Êý¾Ý³¤¶È
+ * ·µ»ØÊµ¼Ê·¢Ëͳ¤¶È
+ */
+int PortSend(int fd, unsigned char* data, int datalen, int flag);
+
+/**
+ * PortRecv
+ * ²ÎÊý£º
+ * fd: ´®¿ÚÃèÊö·û,
+ * data: ´ý½ÓÊÕÊý¾ÝÖ¸Õë
+ * datalen: Êý¾Ý³¤¶È
+ * ·µ»ØÊµ¼Ê¶ÁÈëµÄ×Ö½ÚÊý
+ */
+int PortRecv(int fd, unsigned char* data, int datalen, int flag);
+
+/**
+ * ´®¿Ú²âÊÔʱÉèÖô®¿Ú
+ * fdcom: ´®¿ÚÎļþÃèÊö·û, pportinfo: ´ýÉèÖõĴ®¿ÚÐÅÏ¢
+ */
+int uart_set(int fd);
+
+
+#endif
+