statusbar.cc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. #include "utils/TimeHelper.h"
  4. #include "net/NetManager.h"
  5. #include "net/DhcpClient.h"
  6. #include "manager/LanguageManager.h"
  7. #include "core/utilities.h"
  8. #include "core/sip_config.h"
  9. #include "edge/call_log.h"
  10. #include "edge/popup_service.h"
  11. #include "base/base.hpp"
  12. #include "service/BusinessConfig.h"
  13. #include "net/tcp_client.h"
  14. #include <sys/reboot.h>
  15. #include <net/NetUtils.h>
  16. /*
  17. *此文件由GUI工具生成
  18. *文件功能:用于处理用户的逻辑相应代码
  19. *功能说明:
  20. *========================onButtonClick_XXXX
  21. 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[标识]名称,
  22. 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
  23. *========================onSlideWindowItemClick_XXXX(int index)
  24. 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[标识]名称,
  25. 如slideWindow1;index 代表按下图标的偏移值
  26. *========================onSeekBarChange_XXXX(int progress)
  27. 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[标识]名称,
  28. 如SeekBar1;progress 代表当前的进度值
  29. *========================ogetListItemCount_XXXX()
  30. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[标识]名称,
  31. 如List1;返回值为当前列表的总条数
  32. *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
  33. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[标识]名称,
  34. 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
  35. *========================常用接口===============
  36. *LOGD(...) 打印调试信息的接口
  37. *mTextXXX->setText("****") 在控件TextXXX上显示文字****
  38. *mButton1->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
  39. *mSeekBar->setProgress(12) 在控件mSeekBar上将进度调整到12
  40. *mListView1->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
  41. *mDashbroadView1->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
  42. */
  43. #define ETHERNETMANAGER NETMANAGER->getEthernetManager()
  44. #define WIFIMANAGER NETMANAGER->getWifiManager()
  45. #define SYS_RESTART 10 // 重启
  46. static bool networkConnect = false;
  47. static bool networkNowConnect = false;
  48. static bool tcpConnect = false;
  49. static bool tcpNowConnect = false;
  50. static bool sipConnect = true;
  51. static bool sipNowConnect = false;
  52. static void statusLight() {
  53. if (!networkConnect) {
  54. lightControl("CALLLED", "200F");
  55. }
  56. else {
  57. if (!tcpConnect) {
  58. lightControl("CALLLED", "110F");
  59. }
  60. else {
  61. if (!sipConnect) {
  62. lightControl("CALLLED", "220F");
  63. }
  64. else {
  65. lightControl("CALLLED", "020F");
  66. }
  67. }
  68. }
  69. }
  70. static bool isLight = false;
  71. static net::DhcpClient _s_wifi_dhcp_client;
  72. static net::DhcpClient _s_eth_dhcp_client;
  73. static bool _start_wifi_dhcp_client() {
  74. // 静态ip模式不做处理
  75. if (!WIFIMANAGER->isAutoMode()) {
  76. return false;
  77. }
  78. if (!WIFIMANAGER->isConnected()) {
  79. return false;
  80. }
  81. char ip[32], gw[32];
  82. if (!WIFIMANAGER->getConfigureInfo(ip, NULL, gw, NULL, NULL)) {
  83. return false;
  84. }
  85. return _s_wifi_dhcp_client.start(ip, WIFIMANAGER->getMacAddr(), gw);
  86. }
  87. static void _stop_wifi_dhcp_client() {
  88. _s_wifi_dhcp_client.stop();
  89. }
  90. static bool _start_eth_dhcp_client() {
  91. // 静态ip模式不做处理
  92. if (!ETHERNETMANAGER->isAutoMode()) {
  93. LOGD("以太网静态");
  94. return false;
  95. }
  96. if (!ETHERNETMANAGER->isConnected()) {
  97. LOGD("以太网连接状态");
  98. return false;
  99. }
  100. char ip[32], gw[32];
  101. if (!ETHERNETMANAGER->getConfigureInfo(ip, NULL, gw, NULL, NULL)) {
  102. return false;
  103. }
  104. LOGD("正在重新请求dhcp");
  105. return _s_eth_dhcp_client.start(ip, ETHERNETMANAGER->getMacAddr(), gw);
  106. }
  107. static void _stop_eth_dhcp_client() {
  108. _s_eth_dhcp_client.stop();
  109. }
  110. static void _dhcp_lease_cb(dhcp_lease_type_e type, void *data) {
  111. LOGD("_dhcp_lease_cb type %d\n", type);
  112. switch (type) {
  113. case E_DHCP_LEASE_TYPE_SUCCESS:
  114. LOGD("DHCP连接成功");
  115. break;
  116. case E_DHCP_LEASE_TYPE_FAIL:
  117. LOGD("DHCP连接失败,重连");
  118. _start_eth_dhcp_client();
  119. break;
  120. case E_DHCP_LEASE_TYPE_TIMEOUT:
  121. // 续租超时,可以断开再重连尝试
  122. LOGD("DHCP连接超时,断开重连");
  123. _stop_eth_dhcp_client();
  124. _start_eth_dhcp_client();
  125. break;
  126. }
  127. }
  128. void NavibarSetPartName(const std::string& partName){
  129. mPartNamePtr->setText(partName);
  130. }
  131. static int netOffCount = 0; //断网计数,每秒+1
  132. static int netOffMax = 300; //断网300秒,则重启
  133. static bool isDataRefresh = false;
  134. static void updateNetState(){
  135. if (netOffCount == 0) {
  136. mRestartTimeTextViewPtr->setText("");
  137. }
  138. else {
  139. int restartTime = netOffMax - netOffCount;
  140. string restartTimeStr = LANGUAGEMANAGER->getValue("RestartTime") + to_string(restartTime);
  141. mRestartTimeTextViewPtr->setText(restartTimeStr);
  142. }
  143. if (ETHERNETMANAGER->isConnected() || WIFIMANAGER->isConnected()){
  144. netOffCount = 0;
  145. if (isDataRefresh) {
  146. dataRefresh();
  147. isDataRefresh = false;
  148. }
  149. } else {
  150. netOffCount++;
  151. isDataRefresh = true;
  152. //5分钟仍然断网,则重启
  153. if (netOffCount > netOffMax){
  154. netOffCount = 0;
  155. // 网卡重启
  156. LOGD("断网300秒,网卡断电重启");
  157. std::string heartStr = "NETRESET,1F";
  158. LOGD("=====> the heartStr == %s", heartStr.c_str());
  159. const char* sendMsg = heartStr.c_str();
  160. sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
  161. //重启
  162. sleep(3);
  163. LOGD("网卡重启无效,程序内部重启");
  164. lightControl("CALLLED", "000F");
  165. sync();
  166. reboot(RB_AUTOBOOT);
  167. }
  168. }
  169. ENetChannel channel = NETMANAGER->getConnChannel();
  170. switch (channel) {
  171. case E_NET_CHANNEL_ETHERNET:
  172. if (ETHERNETMANAGER->isConnected()) {
  173. mPainter1Ptr->setBackgroundColor(0xFF37C127);
  174. networkConnect = true;
  175. if (networkNowConnect != networkConnect) {
  176. networkNowConnect = networkConnect;
  177. statusLight();
  178. }
  179. }
  180. else {
  181. mPainter1Ptr->setBackgroundColor(0xFF949494);
  182. networkConnect = false;
  183. if (networkNowConnect != networkConnect) {
  184. networkNowConnect = networkConnect;
  185. statusLight();
  186. }
  187. }
  188. break;
  189. case E_NET_CHANNEL_WIFI:
  190. if (WIFIMANAGER->isConnected()) {
  191. mPainter1Ptr->setBackgroundColor(0xFF37C127);
  192. networkConnect = true;
  193. if (networkNowConnect != networkConnect) {
  194. networkNowConnect = networkConnect;
  195. statusLight();
  196. }
  197. }
  198. else {
  199. mPainter1Ptr->setBackgroundColor(0xFF949494);
  200. networkConnect = false;
  201. if (networkNowConnect != networkConnect) {
  202. networkNowConnect = networkConnect;
  203. statusLight();
  204. }
  205. }
  206. break;
  207. default:
  208. mPainter1Ptr->setBackgroundColor(0xFF949494);
  209. networkConnect = false;
  210. if (networkNowConnect != networkConnect) {
  211. networkNowConnect = networkConnect;
  212. statusLight();
  213. }
  214. break;
  215. }
  216. // EEthConnState connState = ETHERNETMANAGER->getConnState();
  217. // switch (connState){
  218. // case E_ETH_DISCONNECTED: // 以太网断开
  219. // mPainter1Ptr->setBackgroundColor(0xFF949494);
  220. // break;
  221. // case E_ETH_CONNECTING: // 以太网连接中
  222. // mPainter1Ptr->setBackgroundColor(0xFF2F9DF1);
  223. // break;
  224. // case E_ETH_CONNECTED: // 以太网连接
  225. // mPainter1Ptr->setBackgroundColor(0xFF37C127);
  226. // break;
  227. // case E_ETH_DISCONNECTING: // 以太网断开连接中
  228. // mPainter1Ptr->setBackgroundColor(0xFF949494);
  229. // break;
  230. // case E_ETH_CONN_UNKNOWN: // 以太网未知
  231. // mPainter1Ptr->setBackgroundColor(0xFF949494);
  232. // break;
  233. // }
  234. }
  235. void OnRegisterStateChanged(voip::Telephone* telephone, int code){
  236. code = GetTelephone()->GetRegistrationStatusCode();
  237. LOGD("SIP STATUS =======================> %d", code);
  238. if (code == voip::SIP_STATUS_CODE_PROGRESS){
  239. //mTextViewRegPtr->setText("CONNECTING");
  240. mTextViewRegPtr->setBackgroundColor(0xFF2F9DF1);
  241. sipConnect = false;
  242. if (sipNowConnect != sipConnect) {
  243. sipNowConnect = sipConnect;
  244. statusLight();
  245. }
  246. } else if (code == voip::SIP_STATUS_CODE_OK){
  247. //mTextViewRegPtr->setText("OK");
  248. mTextViewRegPtr->setBackgroundColor(0xFF37C127);
  249. sipConnect = true;
  250. if (sipNowConnect != sipConnect) {
  251. sipNowConnect = sipConnect;
  252. statusLight();
  253. }
  254. } else {
  255. //mTextViewRegPtr->setText("ERROR");
  256. mTextViewRegPtr->setBackgroundColor(0xFF949494);
  257. sipConnect = false;
  258. if (sipNowConnect != sipConnect) {
  259. sipNowConnect = sipConnect;
  260. statusLight();
  261. }
  262. }
  263. }
  264. void tcpStatus(){
  265. if (TcpClient::instance()->connected()){
  266. mTextViewTCPPtr->setBackgroundColor(0xFF37C127);
  267. tcpConnect = true;
  268. if (tcpNowConnect != tcpConnect) {
  269. tcpNowConnect = tcpConnect;
  270. statusLight();
  271. }
  272. } else {
  273. mTextViewTCPPtr->setBackgroundColor(0xFF949494);
  274. tcpConnect = false;
  275. if (tcpNowConnect != tcpConnect) {
  276. tcpNowConnect = tcpConnect;
  277. statusLight();
  278. }
  279. }
  280. }
  281. int pingCount = 0;
  282. class PingThread: public Thread {
  283. public:
  284. /**
  285. * 线程创建成功后会调用该函数,可以在该函数中做一些初始化操作
  286. * return true 继续线程
  287. * false 退出线程
  288. */
  289. virtual bool readyToRun() {
  290. LOGD("Ping Thread 已经创建完成");
  291. return true;
  292. }
  293. /**
  294. * 线程循环函数
  295. *
  296. * return true 继续线程循环
  297. * false 推出线程
  298. */
  299. virtual bool threadLoop() {
  300. //为了方便观察,这里添加休眠500ms
  301. usleep(1 * 60 * 1000 * 1000);
  302. //检查是否有退出线程的请求,如果有,则返回false,立即退出线程
  303. if (exitPending()) {
  304. return false;
  305. }
  306. LOGD("Ping 线程循环函数");
  307. if (ETHERNETMANAGER->isAutoMode()) {
  308. string serverIp = StoragePreferences::getString(STORE_GATEWAY, serverIP);
  309. LOGD("===================> ping %s", serverIp.c_str());
  310. string pingStr = "ping " + serverIp + " -c 3";
  311. int result = system(pingStr.c_str());
  312. LOGD("===================> ping 服务器返回的结果: %d", result);
  313. if (result != 0) { // 如果不是0,就代表ping不通,需要重新请求dhcp
  314. LOGD("无法ping通服务器地址:%s", serverIp.c_str());
  315. pingCount += 1;
  316. LOGD("pingCount计数 == %d", pingCount);
  317. if (pingCount == 3) {
  318. NetUtils::dhcpExit();
  319. usleep(20 * 1000);
  320. NetUtils::enableIfc("eth0", false);
  321. usleep(100 * 1000);
  322. NetUtils::enableIfc("eth0", true);
  323. pingCount = 0;
  324. }
  325. }
  326. else {
  327. pingCount = 0;
  328. }
  329. }
  330. //返回真,继续下次线程循环
  331. return true;
  332. }
  333. };
  334. static PingThread ping_thread;
  335. void pingThreadExitPending() {
  336. bool result = ping_thread.isRunning();
  337. if (result) {
  338. ping_thread.requestExitAndWait();
  339. LOGD("ping_thread已关闭");
  340. }
  341. }
  342. void setIsLight(bool _isLight) {
  343. LOGD("设置是否常亮:%d", _isLight);
  344. isLight = _isLight;
  345. if (isLight) { // 常亮的时候关闭息屏
  346. setSleepTimerRegistered(false); // 关闭息屏功能
  347. }
  348. }
  349. int getTime(char* timeStr) {
  350. int hour, minute, second;// 定义时间的各个int临时变量。
  351. sscanf(timeStr, "%d:%d:%d", &hour, &minute, &second);
  352. int time = hour * 60 * 60 + minute * 60 + second;
  353. return time;
  354. }
  355. int dayLight = 100;
  356. int nightLight = 100;
  357. void isTimeScale(char* timeStr) {
  358. std::string dayTime = StoragePreferences::getString(STORE_DAY_START, "07:00:00");
  359. std::string nightTime = StoragePreferences::getString(STORE_NIGHT_START, "18:00:00");
  360. int day = getTime((char*) dayTime.data());
  361. int night = getTime((char*) nightTime.data());
  362. int now = getTime(timeStr);
  363. bool isSleepTime = getSleepTimerRegistered();
  364. if (day <= night) { // 在白天时间小于晚上时间的时候
  365. if (day <= now && now <= night) { // 这个时候,时间处于白天
  366. if (isSleepTime) { // isSleepTime就是定时任务开启,需要关闭
  367. setSleepTimerRegistered(false); // 关闭息屏功能
  368. dayLight = StoragePreferences::getInt(STORE_DAY_LIGHT, 100);
  369. if (dayLight > 100) {
  370. dayLight = 100;
  371. }
  372. LOGD("dayLight == %d", dayLight);
  373. BRIGHTNESSHELPER->setBrightness(dayLight);
  374. LOGD("白天开始时间小于晚上开始时间,切换至白天");
  375. }
  376. }
  377. else { // 这个时间处于晚上
  378. if (!isSleepTime) { // isSleepTime就是定时任务关闭,需要开启
  379. setSleepTimerRegistered(true); // 开启息屏功能
  380. nightLight = StoragePreferences::getInt(STORE_NIGHT_LIGHT, 70);
  381. if (nightLight > 100) {
  382. nightLight = 100;
  383. }
  384. LOGD("nightLight == %d", nightLight);
  385. BRIGHTNESSHELPER->setBrightness(nightLight);
  386. LOGD("白天开始时间小于晚上开始时间,切换至晚上");
  387. }
  388. }
  389. } else { // 这里是day > night时间的时候
  390. if (night <= now && now < day) { // 这个其实是晚上时间
  391. if (!isSleepTime) { // isSleepTime就是定时任务关闭,需要开启
  392. setSleepTimerRegistered(true); // 开启息屏功能
  393. nightLight = StoragePreferences::getInt(STORE_NIGHT_LIGHT, 70);
  394. if (nightLight > 100) {
  395. nightLight = 100;
  396. }
  397. LOGD("nightLight == %d", nightLight);
  398. BRIGHTNESSHELPER->setBrightness(nightLight);
  399. LOGD("白天开始时间大于晚上开始时间,切换至晚上");
  400. }
  401. } else {
  402. if (isSleepTime) { // isSleepTime就是定时任务开启,需要关闭
  403. setSleepTimerRegistered(false); // 关闭息屏功能
  404. dayLight = StoragePreferences::getInt(STORE_DAY_LIGHT, 100);
  405. if (dayLight > 100) {
  406. dayLight = 100;
  407. }
  408. LOGD("dayLight == %d", dayLight);
  409. BRIGHTNESSHELPER->setBrightness(dayLight);
  410. LOGD("白天开始时间大于晚上开始时间,切换至白天");
  411. }
  412. }
  413. }
  414. }
  415. namespace {
  416. // 以太网状态监听
  417. class EthernetConnStateListener : public EthernetManager::IEthernetConnStateListener {
  418. public:
  419. virtual void handleEthernetConnState(EEthConnState state) {
  420. LOGD("[net] handleEthernetConnState state: %d\n", state);
  421. switch (state) {
  422. case E_ETH_CONNECTED:
  423. LOGD("以太网连接");
  424. _start_eth_dhcp_client();
  425. break;
  426. case E_ETH_DISCONNECTED:
  427. LOGD("以太网断开");
  428. _stop_eth_dhcp_client();
  429. break;
  430. default:
  431. break;
  432. }
  433. }
  434. };
  435. // wifi状态监听
  436. class WifiListener: public WifiManager::IWifiListener {
  437. public:
  438. virtual void handleWifiConnect(E_WIFI_CONNECT event, int args) {
  439. LOGD("[net] handleWifiConnect event: %d\n", event);
  440. switch (event) {
  441. case E_WIFI_CONNECT_CONNECTED:
  442. LOGD("WIFI连接");
  443. _start_wifi_dhcp_client();
  444. break;
  445. case E_WIFI_CONNECT_DISCONNECT:
  446. LOGD("WIFI断开");
  447. _stop_wifi_dhcp_client();
  448. break;
  449. default:
  450. break;
  451. }
  452. }
  453. };
  454. }
  455. /**
  456. * 注册定时器
  457. * 填充数组用于注册定时器
  458. * 注意:id不能重复
  459. */
  460. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  461. {1, 1000},
  462. {2, 5000}
  463. };
  464. static void updateUI_time() {
  465. struct tm *t = TimeHelper::getDateTime();
  466. char timeStr[50];
  467. string day[] = {
  468. LANGUAGEMANAGER->getValue("Sunday"),
  469. LANGUAGEMANAGER->getValue("Monday"),
  470. LANGUAGEMANAGER->getValue("Tuesday"),
  471. LANGUAGEMANAGER->getValue("Wednesday"),
  472. LANGUAGEMANAGER->getValue("Thursday"),
  473. LANGUAGEMANAGER->getValue("Friday"),
  474. LANGUAGEMANAGER->getValue("Saturday")};
  475. string formatStr = "%s %d"+LANGUAGEMANAGER->getValue("Year")+"%02d"+LANGUAGEMANAGER->getValue("Month")+"%02d"+LANGUAGEMANAGER->getValue("Day")+" %02d:%02d:%02d";
  476. //string formatStr = "%s %d-%02d-%02d %02d:%02d:%02d";
  477. sprintf(timeStr, formatStr.c_str(), day[t->tm_wday].c_str(),1900 + t->tm_year, t->tm_mon + 1, t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
  478. mDateViewPtr->setText(timeStr); // 注意修改控件名称
  479. // 如果不是常亮,就能需要去判断
  480. if (!isLight) {
  481. char timeStr2[50];
  482. string formatStr2 = "%02d:%02d:%02d";
  483. sprintf(timeStr2, formatStr2.c_str(), t->tm_hour,t->tm_min,t->tm_sec);
  484. isTimeScale(timeStr2);
  485. }
  486. }
  487. static EthernetConnStateListener _s_eth_state_listener;
  488. static WifiListener _s_wifi_listener;
  489. /**
  490. * 当界面构造时触发
  491. */
  492. static void onUI_init(){
  493. //SIP
  494. GetTelephone()->AddRegisteredStateListener(OnRegisterStateChanged);
  495. mPartNamePtr->setText(StoragePreferences::getString(STORE_PARTNAME,""));
  496. updateUI_time();
  497. //网络判断
  498. updateNetState();
  499. tcpStatus();
  500. //Tips :添加 UI初始化的显示代码到这里,如:mText1Ptr->setText("123");
  501. ETHERNETMANAGER->addEthernetConnStateListener(&_s_eth_state_listener);
  502. WIFIMANAGER->addWifiListener(&_s_wifi_listener);
  503. StoragePreferences::putString(STORE_MAC_ADDR, std::string(ETHERNETMANAGER->getMacAddr()));
  504. _s_wifi_dhcp_client.set_lease_cb(_dhcp_lease_cb);
  505. _s_eth_dhcp_client.set_lease_cb(_dhcp_lease_cb);
  506. // 这里也检测网络是否连接上 (有可能启动前网络已经连接触发不到回调),启动dhcp租赁检测,之后都是根据网络的连接断开执行相应的操作
  507. _start_wifi_dhcp_client();
  508. _start_eth_dhcp_client();
  509. ping_thread.run("ping");
  510. StoragePreferences::putBool(STORE_LIGHT, true);
  511. isLight = StoragePreferences::getBool(STORE_LIGHT, false);
  512. }
  513. /*
  514. * 当界面完全退出时触发
  515. */
  516. static void onUI_quit() {
  517. GetTelephone()->RemoveRegisteredStateListener(OnRegisterStateChanged);
  518. }
  519. /**
  520. * 串口数据回调接口
  521. */
  522. static void onProtocolDataUpdate(const SProtocolData &data) {
  523. //串口数据回调接口
  524. }
  525. /**
  526. * 定时器触发函数
  527. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  528. * 参数: id
  529. * 当前所触发定时器的id,与注册时的id相同
  530. * 返回值: true
  531. * 继续运行当前定时器
  532. * false
  533. * 停止运行当前定时器
  534. */
  535. static bool onUI_Timer(int id){
  536. switch (id) {
  537. case 1:
  538. updateUI_time();
  539. updateNetState();
  540. break;
  541. case 2:
  542. tcpStatus();
  543. break;
  544. default:
  545. break;
  546. }
  547. return true;
  548. }
  549. /**
  550. * 有新的触摸事件时触发
  551. * 参数:ev
  552. * 新的触摸事件
  553. * 返回值:true
  554. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  555. * false
  556. * 触摸事件将继续传递到控件上
  557. */
  558. static bool onstatusbarActivityTouchEvent(const MotionEvent &ev) {
  559. switch (ev.mActionStatus) {
  560. case MotionEvent::E_ACTION_DOWN://触摸按下
  561. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  562. break;
  563. case MotionEvent::E_ACTION_MOVE://触摸滑动
  564. break;
  565. case MotionEvent::E_ACTION_UP: //触摸抬起
  566. break;
  567. default:
  568. break;
  569. }
  570. return false;
  571. }