Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mDot_AT_firmware by
CmdSendBinary.cpp
00001 #include "CmdSendBinary.h" 00002 #include "CommandTerminal.h" 00003 00004 CmdSendBinary::CmdSendBinary() : 00005 #if MTS_CMD_TERM_VERBOSE 00006 Command("Send Binary", "AT+SENDB", "Sends supplied binary (hex) packet data one time and return response", "(hex:242)") 00007 #else 00008 Command("AT+SENDB") 00009 #endif 00010 {} 00011 00012 uint32_t CmdSendBinary::action(const std::vector<std::string>& args) { 00013 std::vector<uint8_t> data; 00014 00015 int temp; 00016 uint32_t length = args[1].size(); 00017 00018 // Detach the serial rx irq handler temporarily here to allow for deep sleep 00019 //CommandTerminal::Serial()->detach(); 00020 00021 // Convert the ASCII hex data to binary... 00022 for (uint32_t i = 0; i < length; i += 2) { 00023 sscanf(&args[1][i], "%2x", &temp); 00024 data.push_back(temp); 00025 } 00026 00027 if (CommandTerminal::Dot()->send(data, CommandTerminal::Dot()->getTxWait()) != mDot::MDOT_OK) { 00028 //CommandTerminal::Serial()->attach(); 00029 return 1; 00030 } 00031 00032 if (CommandTerminal::Dot()->getTxWait()) { 00033 printRecvData(); 00034 } 00035 00036 //CommandTerminal::Serial()->attach(); 00037 return 0; 00038 } 00039 00040 bool CmdSendBinary::verify(const std::vector<std::string>& args) { 00041 if (args.size() == 2) { 00042 if (args[1].size() > 484 || !isHexString(args[1], args[1].size() / 2)) { 00043 #if MTS_CMD_TERM_VERBOSE 00044 CommandTerminal::setErrorMessage("Invalid hex string, (hex:242)"); 00045 #endif 00046 return false; 00047 } 00048 00049 return true; 00050 } 00051 00052 #if MTS_CMD_TERM_VERBOSE 00053 CommandTerminal::setErrorMessage("Invalid arguments"); 00054 #endif 00055 return false; 00056 } 00057
Generated on Wed Jan 15 2025 16:10:47 by
1.7.2


