#include "ComCtrl.h" void SendCmd(const vector &args, const string &type) { string tmpCmd = type + args[1] + "," + args[2] + "\r\n"; myDateTime tmp; string log = tmp.toDateTime() + " Send: " + tmpCmd; cout << log; historyList.push_back(log); string tmpCmdList = args[0] + " " + args[1] + " " + args[2]; if (cmdList.empty()) { cmdList.push_back(tmpCmdList); } else { if (cmdList.back() != tmpCmdList) { cmdList.push_back(tmpCmdList); } } if (Sender.sendto(tmpCmd) < 0) { cerr << "send error" << endl; } } void setantCommand(const vector &args) { if (args.size() != 3) { cout << "Usage: setant " << endl; return; } SendCmd(args, "AT+SetAnt="); } void setephCommand(const vector &args) { if (args.size() != 3) { cout << "Usage: seteph " << endl; return; } SendCmd(args, "AT+SetEph="); } // 查询键值 void queryCommand(const vector &args) { if (args.size() != 3) { cout << "Usage: query " << endl; return; } SendCmd(args, "AT+Query="); } void listCommand() { for (const auto &i: historyList) { cout << i << flush; } string tmpCmdList = "list"; if (cmdList.empty()) { cmdList.push_back(tmpCmdList); } else { if (cmdList.back() != tmpCmdList) { cmdList.push_back(tmpCmdList); } } }