Helper library to use modem_ref driver.
Dependencies: WizziCom WizziDebug ram_fs modem_ref
Dependents: D7A_Localisation D7A_1x_demo_send_file_data_and_forget D7A_1x_demo_CodeUpgradeProtocol D7A_1x_demo_LoRaWAN ... more
Diff: modem_ref_helper.cpp
- Revision:
- 43:90c9221c1430
- Parent:
- 36:7cea3c6d7a63
- Child:
- 44:7563b8e53e1d
--- a/modem_ref_helper.cpp Thu Oct 04 09:58:36 2018 +0000 +++ b/modem_ref_helper.cpp Thu Oct 04 11:44:36 2018 +0000 @@ -8,37 +8,172 @@ #define MODEM_VERSION_MAJOR 5 #define MODEM_VERSION_MINOR 2 -#define MODEM_VERSION_PATCH 184 +#define MODEM_VERSION_PATCH 310 static WizziCom* g_modem_com; static Semaphore g_modem_ready[MAX_USER_NB]; -static void modem_print_status(int status) +void modem_print_error(uint8_t itf, int8_t error) { - switch (status) + if (ALP_ERR_ITF_START >= error && ALP_ERR_ITF_END <= error) { - case ALP_ERR_NONE: - HELPER_PRINT("Status: OK\n"); - break; - default: - HELPER_PRINT("Status: error %d\n", status); - break; + error -= ALP_ERR_ITF_START; + // Interface specific error + if (ALP_ITF_TYPE_HOST == itf) + { + PRINT("ITF[%02X] Error %d\r\n", itf, error); + } + else if (ALP_ITF_TYPE_COM == itf) + { + PRINT("ITF[%02X] Error %d\r\n", itf, error); + } + else if (ALP_ITF_TYPE_D7A == itf) + { + PRINT("ITF[%02X] ", itf); + switch (error) + { + /// No error + case D7A_ERROR_NO: // = 0, + PRINT("D7A_ERROR_NO\r\n"); + break; + /// Resource busy + case D7A_ERROR_BUSY: // = -1, + PRINT("D7A_ERROR_BUSY\r\n"); + break; + /// Bad parameter + case D7A_ERROR_BAD_PARAM: // = -2, + PRINT("D7A_ERROR_BAD_PARAM\r\n"); + break; + /// Duty cycle limit overflow + case D7A_ERROR_DUTY_CYCLE: // = -3, + PRINT("D7A_ERROR_DUTY_CYCLE\r\n"); + break; + /// CCA timeout + case D7A_ERROR_CCA_TO: // = -4, + PRINT("D7A_ERROR_CCA_TO\r\n"); + break; + /// Security frame counter overflow + case D7A_ERROR_NLS_KEY: // = -5, + PRINT("D7A_ERROR_NLS_KEY\r\n"); + break; + /// TX stream underflow + case D7A_ERROR_TX_UDF: // = -6, + PRINT("D7A_ERROR_TX_UDF\r\n"); + break; + /// RX stream overflow + case D7A_ERROR_RX_OVF: // = -7, + PRINT("D7A_ERROR_RX_OVF\r\n"); + break; + /// RX checksum + case D7A_ERROR_RX_CRC: // = -8, + PRINT("D7A_ERROR_RX_CRC\r\n"); + break; + /// Abort + case D7A_ERROR_ABORT: // = -9, + PRINT("D7A_ERROR_ABORT\r\n"); + break; + /// No ACK received + case D7A_ERROR_NO_ACK: // = -10, + PRINT("D7A_ERROR_NO_ACK\r\n"); + break; + /// RX timeout + case D7A_ERROR_RX_TO: // = -11, + PRINT("D7A_ERROR_RX_TO\r\n"); + break; + default: + PRINT("Unknown Error %d\r\n", error); + break; + } + } + else if (ALP_ITF_TYPE_LWAN == itf) + { + PRINT("ITF[%02X] Error %d\r\n", itf, error); + } + else + { + PRINT("ITF[%02X] Error %d\r\n", itf, error); + } } -} - -static void modem_print_resp(int status) -{ - switch (status) + else { - case ALP_ERR_NONE: - HELPER_PRINT("Resp: OK\n"); - break; - case ALP_ERR_FILE_EXIST: - HELPER_PRINT("Resp: Already registered\n"); - break; - default: - HELPER_PRINT("Resp: error %d\n", status); - break; + PRINT("ALP: "); + switch (error) + { + // Not really errors, more like status + case ALP_ERR_ITF_FULL: // 0x02: For interfaces supporting buffering, indicates buffer reached maximum capacity (no data loss) + PRINT("ALP_ERR_ITF_FULL\r\n"); + break; + case ALP_ERR_PARTIAL_COMPLETION: // 0x01: Action received and partially completed at response. To be completed after response + PRINT("ALP_ERR_PARTIAL_COMPLETION\r\n"); + break; + + // ALP Errors + case ALP_ERR_NONE: // 0x00: Action completed (OK) + PRINT("ALP_ERR_NONE\r\n"); + break; + case ALP_ERR_FILE_NOT_FOUND: // 0xFF: Error access file: File ID does not exist + PRINT("ALP_ERR_FILE_NOT_FOUND\r\n"); + break; + case ALP_ERR_FILE_EXIST: // 0xFE: Error create file: File ID already exists + PRINT("ALP_ERR_FILE_EXIST\r\n"); + break; + case ALP_ERR_FILE_NOT_RESTORABLE: // 0xFD: Error restore file: File is not restorable + PRINT("ALP_ERR_FILE_NOT_RESTORABLEr\n"); + break; + case ALP_ERR_PERMISSION_DENIED: // 0xFC: Error access file: Insufficient permissions + PRINT("ALP_ERR_PERMISSION_DENIED\r\n"); + break; + case ALP_ERR_LENGTH_OVERFLOW: // 0xFB: Error create file: Supplied length (in header) is beyond file limits + PRINT("ALP_ERR_LENGTH_OVERFLOW\r\n"); + break; + case ALP_ERR_ALLOC_OVERFLOW: // 0xFA: Error create file: Supplied allocation (in header) is beyond file limits + PRINT("ALP_ERR_ALLOC_OVERFLOW\r\n"); + break; + case ALP_ERR_OFFSET_OVERFLOW: // 0xF9: Error write: Supplied start offset is out of bounds of file allocation + PRINT("ALP_ERR_OFFSET_OVERFLOW\r\n"); + break; + case ALP_ERR_WRITE_OVERFLOW: // 0xF8: Error complete write: Supplied data goes beyond file allocation + PRINT("ALP_ERR_WRITE_OVERFLOW\r\n"); + break; + case ALP_ERR_WRITE_ERROR: // 0xF7: Error write: impossible to write in storage location + PRINT("ALP_ERR_WRITE_ERROR\r\n"); + break; + case ALP_ERR_OPERATION_UNKNOWN: // 0xF6: Error unknown Operation + PRINT("ALP_ERR_OPERATION_UNKNOWN\r\n"); + break; + case ALP_ERR_OPERAND_INCOMPLETE: // 0xF5: Error incomplete Operand + PRINT("ALP_ERR_OPERAND_INCOMPLETE\r\n"); + break; + case ALP_ERR_OPERAND_WRONG_FORMAT: // 0xF4: Error wrong Operand format + PRINT("ALP_ERR_OPERAND_WRONG_FORMAT\r\n"); + break; + case ALP_ERR_ITF_INVALID: // 0xF3: Error invalid interface + PRINT("ALP_ERR_ITF_INVALID\r\n"); + break; + case ALP_ERR_ITF_OVERFLOW: // 0xF2: Error interface overflown (i.e. resources exhausted, buffer full with data discarded) + PRINT("ALP_ERR_ITF_OVERFLOW\r\n"); + break; + case ALP_ERR_QUERY_FAIL: // 0xF1: (Group of) Query result was false (Informative error code). + PRINT("ALP_ERR_QUERY_FAIL\r\n"); + break; + + // Other Errors + case ALP_ERR_UNKNOWN: // 0x80: Unknown error + PRINT("ALP_ERR_UNKNOWN\r\n"); + break; + case ALP_ERR_FS_TIMEOUT: // 0x81: Internal FS Error + PRINT("ALP_ERR_FS_TIMEOUT\r\n"); + break; + case ALP_ERR_ITF_UNKNOWN: // 0x82: Unknown Interface + PRINT("ALP_ERR_ITF_UNKNOWN\r\n"); + break; + case ALP_ERR_ITF_TIMEOUT: // 0x83: Internal ITF Error + PRINT("ALP_ERR_ITF_TIMEOUT\r\n"); + break; + default: + PRINT("Unknown Error %d\r\n", error); + break; + } } } @@ -77,13 +212,8 @@ if (terminal) { - modem_print_status(err); g_modem_ready[id].release(); } - else - { - modem_print_resp(err); - } } // Misc