|
| 1 | +package comboat |
| 2 | + |
| 3 | +import ( |
| 4 | + "bytes" |
| 5 | + "strconv" |
| 6 | +) |
| 7 | + |
| 8 | +var errStrings = map[int]string{ |
| 9 | + |
| 10 | + // System framework related error codes |
| 11 | + |
| 12 | + 0: "success", |
| 13 | + 1: "The command is not supported (the combo framework contains the command but the current platform has not transplanted or adapted to support it)", |
| 14 | + 2: "The command parameters contain unsupported operations (the current platform only supports some operations for this command)", |
| 15 | + 3: "The instruction format is incorrect (this refers to the wrong number of parameters, for example, two parameters are required, but only one parameter is entered)", |
| 16 | + 4: "Parameter error (the content of the parameter is wrong, for example, a number between 0 and 9 is required, but 10 or xyz is passed in, which is a parameter error)", |
| 17 | + 5: "Parameter length error (command length exceeds the maximum supported length)", |
| 18 | + 31: "The current command has not ended and needs to report the status asynchronously. This value is used by the state machine to determine the use of the command and no message is returned.", |
| 19 | + 32: "Unknown error (or unhandled error type)", |
| 20 | + |
| 21 | + // Common error codes |
| 22 | + |
| 23 | + 33: "malloc error", |
| 24 | + 34: "Failed to read buf", |
| 25 | + 35: "Failed to write buf", |
| 26 | + 36: "Configuration error (configuration error loaded from memory, for example, we set port -1 for OTA upgrade, and check port error when executing AT+OTA, then configuration error will be reported)", |
| 27 | + 37: "Failed to create task", |
| 28 | + 38: "Flash read and write failure", |
| 29 | + 39: "Serial port configuration error, unsupported baud rate", |
| 30 | + 40: "Serial port configuration error, unsupported data bits", |
| 31 | + 41: "Serial port configuration error, unsupported stop bit", |
| 32 | + 42: "Serial port configuration error, unsupported parity bit", |
| 33 | + 43: "Serial port configuration error, unsupported flow control", |
| 34 | + 44: "Serial port configuration failed", |
| 35 | + 45: "Wrong username/password", |
| 36 | + 46: "Low power mode error or unsupported low power mode", |
| 37 | + 47: "Uninitialized configuration data error (including io mapping data)", |
| 38 | + 63: "General error code (without other information)", |
| 39 | + |
| 40 | + // Wi-Fi related error codes |
| 41 | + |
| 42 | + 64: "Wi-Fi not initialized or initialization failed", |
| 43 | + 65: "Wi-Fi mode error (unable to connect to Wi-Fi in single AP mode)", |
| 44 | + 66: "Wi-Fi connection failed", |
| 45 | + 67: "Wi-Fi connection successful, error in obtaining IP (DHCP)", |
| 46 | + 68: "Failed to obtain encryption method", |
| 47 | + 69: "The specified AP was not found.", |
| 48 | + 70: "Wi-Fi scan start failed", |
| 49 | + 71: "Wi-Fi scan timeout", |
| 50 | + 72: "Failed to enable AP hotspot", |
| 51 | + 73: "Failed to obtain the Wi-Fi information of the router or the AP information that you enabled yourself", |
| 52 | + 74: "The network card (STA/AP) is not running", |
| 53 | + 75: "Wi-Fi country code error (unsupported Wi-Fi country code)", |
| 54 | + 76: "The current network configuration mode is wrong.", |
| 55 | + 95: "Wi-Fi connection unknown error", |
| 56 | + |
| 57 | + // Socket related error codes |
| 58 | + |
| 59 | + 96: "Failed to create socket", |
| 60 | + 97: "Socket connection failed", |
| 61 | + 98: "DNS Failure", |
| 62 | + 99: "The socket status is wrong (for example, TCP is not connected yet)", |
| 63 | + 100: "Socket type error", |
| 64 | + 101: "Socket send failed", |
| 65 | + 102: "Socket receive failed", |
| 66 | + 103: "Socket monitoring thread creation failed", |
| 67 | + 104: "Socket bind error", |
| 68 | + 105: "The current connection cannot be transparently linked (wrong socket type or number)", |
| 69 | + 106: "PING test failed (all packets lost)", |
| 70 | + 107: "Wi-Fi country code error (unsupported Wi-Fi country code)", |
| 71 | + 108: "SSL Config Error", |
| 72 | + 109: "SSL verification error (usually caused by unsupported SSL encryption type or certificate error)", |
| 73 | + 127: "Unknown socket error", |
| 74 | +} |
| 75 | + |
| 76 | +func getErrStr(errLine []byte) (errStr string) { |
| 77 | + errStr = "Can't parse ERROR response" |
| 78 | + tokens := bytes.Split(errLine, []byte(":")) |
| 79 | + if len(tokens) > 1 { |
| 80 | + errCode, err := strconv.Atoi(string(tokens[1])) |
| 81 | + if err == nil { |
| 82 | + errStr = errStrings[errCode] |
| 83 | + } |
| 84 | + } |
| 85 | + return |
| 86 | +} |
0 commit comments