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
modem_d7a.cpp@80:c2e45d6eab29, 2021-10-01 (annotated)
- Committer:
- Jeej
- Date:
- Fri Oct 01 08:46:58 2021 +0000
- Revision:
- 80:c2e45d6eab29
- Parent:
- 77:5146f44cde83
modem v6.2.84
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeej | 69:8f2fe2426ef9 | 1 | |
Jeej | 69:8f2fe2426ef9 | 2 | #include "mbed.h" |
Jeej | 68:b2dd7309da44 | 3 | #include "modem_d7a.h" |
Jeej | 75:dad2f09cb870 | 4 | #include "modem_cup.h" |
Jeej | 68:b2dd7309da44 | 5 | |
Jeej | 68:b2dd7309da44 | 6 | #if 0 |
Jeej | 69:8f2fe2426ef9 | 7 | #define HELPER_PRINT(...) PRINT(__VA_ARGS__) |
Jeej | 68:b2dd7309da44 | 8 | #else |
Jeej | 69:8f2fe2426ef9 | 9 | #define HELPER_PRINT(...); |
Jeej | 68:b2dd7309da44 | 10 | #endif |
Jeej | 68:b2dd7309da44 | 11 | |
Jeej | 68:b2dd7309da44 | 12 | #define MODEM_VERSION_MAJOR 5 |
Jeej | 68:b2dd7309da44 | 13 | #define MODEM_VERSION_MINOR 6 |
Jeej | 68:b2dd7309da44 | 14 | #define MODEM_VERSION_PATCH 0 |
Jeej | 68:b2dd7309da44 | 15 | #define MODEM_DEVICE_ID 0x00001001 |
Jeej | 68:b2dd7309da44 | 16 | |
Jeej | 69:8f2fe2426ef9 | 17 | Semaphore g_s[MAX_USER_NB]; |
Jeej | 68:b2dd7309da44 | 18 | |
Jeej | 68:b2dd7309da44 | 19 | static WizziCom* g_modem_com; |
Jeej | 68:b2dd7309da44 | 20 | |
Jeej | 68:b2dd7309da44 | 21 | // Callback for id User |
Jeej | 80:c2e45d6eab29 | 22 | static void modem_cb(uint8_t id) |
Jeej | 68:b2dd7309da44 | 23 | { |
Jeej | 68:b2dd7309da44 | 24 | (void)id; |
Jeej | 68:b2dd7309da44 | 25 | |
Jeej | 80:c2e45d6eab29 | 26 | HELPER_PRINT("CB ID:%d\n", id); |
Jeej | 69:8f2fe2426ef9 | 27 | |
Jeej | 80:c2e45d6eab29 | 28 | g_s[id].release(); |
Jeej | 68:b2dd7309da44 | 29 | } |
Jeej | 68:b2dd7309da44 | 30 | |
Jeej | 68:b2dd7309da44 | 31 | static int g_boot_nb; |
Jeej | 68:b2dd7309da44 | 32 | static int g_read_nb; |
Jeej | 68:b2dd7309da44 | 33 | static int g_swr_nb; |
Jeej | 68:b2dd7309da44 | 34 | static int g_hwr_nb; |
Jeej | 68:b2dd7309da44 | 35 | static int g_pwc_nb; |
Jeej | 68:b2dd7309da44 | 36 | static int g_fail_nb; |
Jeej | 68:b2dd7309da44 | 37 | |
Jeej | 68:b2dd7309da44 | 38 | int my_alp_itf_d7a_cfg_size(d7a_sp_cfg_t* cfg) |
Jeej | 68:b2dd7309da44 | 39 | { |
Jeej | 68:b2dd7309da44 | 40 | int size = sizeof(d7a_sp_cfg_t) - sizeof(d7a_addressee_t); |
Jeej | 68:b2dd7309da44 | 41 | size += D7A_ADDR_LEN(cfg->addressee.ctrl); |
Jeej | 68:b2dd7309da44 | 42 | return size; |
Jeej | 68:b2dd7309da44 | 43 | } |
Jeej | 68:b2dd7309da44 | 44 | |
Jeej | 68:b2dd7309da44 | 45 | // ============================================================}}} |
Jeej | 68:b2dd7309da44 | 46 | |
Jeej | 68:b2dd7309da44 | 47 | // Serial adapters to WizziLab's own architecture |
Jeej | 68:b2dd7309da44 | 48 | // ============================================================{{{ |
Jeej | 68:b2dd7309da44 | 49 | |
Jeej | 68:b2dd7309da44 | 50 | static void modem_serial_input(WizziCom* com, WizziComPacket_t* pkt) |
Jeej | 68:b2dd7309da44 | 51 | { |
Jeej | 68:b2dd7309da44 | 52 | modem_ref_input(wizzicom_type_to_flow(pkt->type), pkt->data, pkt->length); |
Jeej | 68:b2dd7309da44 | 53 | } |
Jeej | 68:b2dd7309da44 | 54 | |
Jeej | 69:8f2fe2426ef9 | 55 | static int modem_serial_send(uint8_t type, uint8_t* data, uint8_t size) |
Jeej | 68:b2dd7309da44 | 56 | { |
Jeej | 69:8f2fe2426ef9 | 57 | // Retrieve Flow ID from header and send packet |
Jeej | 69:8f2fe2426ef9 | 58 | g_modem_com->send((WizziComPacketType)type, size, data); |
Jeej | 68:b2dd7309da44 | 59 | |
Jeej | 69:8f2fe2426ef9 | 60 | return size; |
Jeej | 68:b2dd7309da44 | 61 | } |
Jeej | 68:b2dd7309da44 | 62 | |
Jeej | 75:dad2f09cb870 | 63 | static Semaphore boot(0); |
Jeej | 68:b2dd7309da44 | 64 | void my_startup_boot(u8 cause, u16 number) |
Jeej | 68:b2dd7309da44 | 65 | { |
Jeej | 68:b2dd7309da44 | 66 | HELPER_PRINT("Modem BOOT[%c] #%d\r\n", cause, number); |
Jeej | 68:b2dd7309da44 | 67 | boot.release(); |
Jeej | 68:b2dd7309da44 | 68 | } |
Jeej | 68:b2dd7309da44 | 69 | |
Jeej | 68:b2dd7309da44 | 70 | int modem_open(modem_ref_callbacks_t* callbacks) |
Jeej | 68:b2dd7309da44 | 71 | { |
Jeej | 68:b2dd7309da44 | 72 | static union { |
Jeej | 68:b2dd7309da44 | 73 | uint8_t b[8]; |
Jeej | 68:b2dd7309da44 | 74 | uint32_t w[2]; |
Jeej | 68:b2dd7309da44 | 75 | } uid; |
Jeej | 68:b2dd7309da44 | 76 | revision_t rev; |
Jeej | 68:b2dd7309da44 | 77 | int err; |
Jeej | 68:b2dd7309da44 | 78 | |
Jeej | 69:8f2fe2426ef9 | 79 | //for (int i = 0; i < MAX_USER_NB; i++) |
Jeej | 69:8f2fe2426ef9 | 80 | //{ |
Jeej | 69:8f2fe2426ef9 | 81 | //g_s[i] = Semaphore(0); |
Jeej | 69:8f2fe2426ef9 | 82 | //} |
Jeej | 69:8f2fe2426ef9 | 83 | |
Jeej | 68:b2dd7309da44 | 84 | g_boot_nb++; |
Jeej | 69:8f2fe2426ef9 | 85 | |
Jeej | 68:b2dd7309da44 | 86 | // Override boot callback to catch the first boot message |
Jeej | 68:b2dd7309da44 | 87 | modem_ref_callbacks_t boot_callbacks = { |
Jeej | 68:b2dd7309da44 | 88 | .read = NULL, |
Jeej | 68:b2dd7309da44 | 89 | .write = NULL, |
Jeej | 68:b2dd7309da44 | 90 | .read_fprop = NULL, |
Jeej | 68:b2dd7309da44 | 91 | .flush = NULL, |
Jeej | 68:b2dd7309da44 | 92 | .remove = NULL, |
Jeej | 68:b2dd7309da44 | 93 | .udata = NULL, |
Jeej | 68:b2dd7309da44 | 94 | .reset = NULL, |
Jeej | 68:b2dd7309da44 | 95 | .boot = my_startup_boot, |
Jeej | 68:b2dd7309da44 | 96 | }; |
Jeej | 69:8f2fe2426ef9 | 97 | |
Jeej | 68:b2dd7309da44 | 98 | // Open modem Com port |
Jeej | 68:b2dd7309da44 | 99 | g_modem_com = new WizziCom(MODEM_PIN_RX, MODEM_PIN_TX, MODEM_PIN_IRQ_IN, MODEM_PIN_IRQ_OUT); |
Jeej | 69:8f2fe2426ef9 | 100 | |
Jeej | 68:b2dd7309da44 | 101 | // open with user callbacks |
Jeej | 68:b2dd7309da44 | 102 | modem_ref_open(modem_serial_send, callbacks); |
Jeej | 69:8f2fe2426ef9 | 103 | |
Jeej | 68:b2dd7309da44 | 104 | // Redirect All Port traffic to modem_serial_input |
Jeej | 68:b2dd7309da44 | 105 | g_modem_com->attach(modem_serial_input, WizziComPacketUntreated); |
Jeej | 68:b2dd7309da44 | 106 | |
Jeej | 68:b2dd7309da44 | 107 | // Wait for modem power up |
Jeej | 68:b2dd7309da44 | 108 | ThisThread::sleep_for(100); |
Jeej | 69:8f2fe2426ef9 | 109 | |
Jeej | 68:b2dd7309da44 | 110 | // Try reading UID |
Jeej | 68:b2dd7309da44 | 111 | err = modem_read_file(D7A_FID_UID, uid.b, 0, 8); |
Jeej | 69:8f2fe2426ef9 | 112 | |
Jeej | 68:b2dd7309da44 | 113 | if (ALP_ERR_NONE > err) |
Jeej | 68:b2dd7309da44 | 114 | { |
Jeej | 68:b2dd7309da44 | 115 | PRINT("Trying software reset...\n"); |
Jeej | 69:8f2fe2426ef9 | 116 | |
Jeej | 68:b2dd7309da44 | 117 | // Open driver to catch boot packet |
Jeej | 68:b2dd7309da44 | 118 | modem_ref_close(); |
Jeej | 68:b2dd7309da44 | 119 | modem_ref_open(NULL, &boot_callbacks); |
Jeej | 69:8f2fe2426ef9 | 120 | |
Jeej | 68:b2dd7309da44 | 121 | // Try software reset |
Jeej | 68:b2dd7309da44 | 122 | g_modem_com->send(WizziComPacketSysReset, 0, NULL); |
Jeej | 69:8f2fe2426ef9 | 123 | |
Jeej | 68:b2dd7309da44 | 124 | if (!boot.try_acquire_for(1000)) |
Jeej | 68:b2dd7309da44 | 125 | { |
Jeej | 68:b2dd7309da44 | 126 | PRINT("Trying hardware reset...\n"); |
Jeej | 69:8f2fe2426ef9 | 127 | |
Jeej | 68:b2dd7309da44 | 128 | // Assert reset pin |
Jeej | 68:b2dd7309da44 | 129 | DigitalOut reset_low(MODEM_PIN_RESET, 0); |
Jeej | 68:b2dd7309da44 | 130 | ThisThread::sleep_for(100); |
Jeej | 69:8f2fe2426ef9 | 131 | |
Jeej | 68:b2dd7309da44 | 132 | // Release reset pin |
Jeej | 68:b2dd7309da44 | 133 | DigitalIn reset_release(MODEM_PIN_RESET); |
Jeej | 69:8f2fe2426ef9 | 134 | |
Jeej | 68:b2dd7309da44 | 135 | if (!boot.try_acquire_for(1000)) |
Jeej | 68:b2dd7309da44 | 136 | { |
Jeej | 72:15bf99fcfed9 | 137 | #if 0 |
Jeej | 68:b2dd7309da44 | 138 | // Modem not responding! |
Jeej | 68:b2dd7309da44 | 139 | PRINT("Trying power cycle.\n"); |
Jeej | 69:8f2fe2426ef9 | 140 | |
Jeej | 68:b2dd7309da44 | 141 | // Assert power pin |
Jeej | 68:b2dd7309da44 | 142 | DigitalOut power_high(D12, 1); |
Jeej | 68:b2dd7309da44 | 143 | ThisThread::sleep_for(1000); |
Jeej | 69:8f2fe2426ef9 | 144 | |
Jeej | 68:b2dd7309da44 | 145 | // Release reset pin |
Jeej | 68:b2dd7309da44 | 146 | DigitalIn power_release(D12); |
Jeej | 69:8f2fe2426ef9 | 147 | |
Jeej | 72:15bf99fcfed9 | 148 | if (boot.try_acquire_for(1000)) |
Jeej | 72:15bf99fcfed9 | 149 | { |
Jeej | 72:15bf99fcfed9 | 150 | g_pwc_nb++; |
Jeej | 72:15bf99fcfed9 | 151 | PRINT("Modem is up after power cycle.\n"); |
Jeej | 72:15bf99fcfed9 | 152 | } |
Jeej | 72:15bf99fcfed9 | 153 | else |
Jeej | 72:15bf99fcfed9 | 154 | #endif |
Jeej | 68:b2dd7309da44 | 155 | { |
Jeej | 68:b2dd7309da44 | 156 | // Modem not responding! |
Jeej | 68:b2dd7309da44 | 157 | g_fail_nb++; |
Jeej | 68:b2dd7309da44 | 158 | PRINT("Failed to open modem.\n"); |
Jeej | 68:b2dd7309da44 | 159 | return -1; |
Jeej | 68:b2dd7309da44 | 160 | } |
Jeej | 68:b2dd7309da44 | 161 | } |
Jeej | 68:b2dd7309da44 | 162 | else |
Jeej | 68:b2dd7309da44 | 163 | { |
Jeej | 68:b2dd7309da44 | 164 | g_hwr_nb++; |
Jeej | 68:b2dd7309da44 | 165 | PRINT("Modem is up after hardware reset.\n"); |
Jeej | 68:b2dd7309da44 | 166 | } |
Jeej | 68:b2dd7309da44 | 167 | } |
Jeej | 68:b2dd7309da44 | 168 | else |
Jeej | 68:b2dd7309da44 | 169 | { |
Jeej | 68:b2dd7309da44 | 170 | g_swr_nb++; |
Jeej | 68:b2dd7309da44 | 171 | PRINT("Modem is up after software reset.\n"); |
Jeej | 68:b2dd7309da44 | 172 | } |
Jeej | 69:8f2fe2426ef9 | 173 | |
Jeej | 69:8f2fe2426ef9 | 174 | // Re-open with user callbacks |
Jeej | 69:8f2fe2426ef9 | 175 | modem_ref_close(); |
Jeej | 69:8f2fe2426ef9 | 176 | modem_ref_open(modem_serial_send, callbacks); |
Jeej | 68:b2dd7309da44 | 177 | } |
Jeej | 68:b2dd7309da44 | 178 | else |
Jeej | 68:b2dd7309da44 | 179 | { |
Jeej | 68:b2dd7309da44 | 180 | g_read_nb++; |
Jeej | 68:b2dd7309da44 | 181 | PRINT("Modem is up.\n"); |
Jeej | 68:b2dd7309da44 | 182 | } |
Jeej | 69:8f2fe2426ef9 | 183 | |
Jeej | 68:b2dd7309da44 | 184 | PRINT("Boot stats: boot:%d read:%d swr:%d hwr:%d pwc:%d fail:%d\n", g_boot_nb, g_read_nb, g_swr_nb, g_hwr_nb, g_pwc_nb, g_fail_nb); |
Jeej | 69:8f2fe2426ef9 | 185 | |
Jeej | 69:8f2fe2426ef9 | 186 | ThisThread::sleep_for(100); |
Jeej | 69:8f2fe2426ef9 | 187 | |
Jeej | 68:b2dd7309da44 | 188 | modem_read_file(D7A_FID_UID, uid.b, 0, 8); |
Jeej | 68:b2dd7309da44 | 189 | modem_read_file(D7A_FID_FIRMWARE_VERSION, (uint8_t*)&rev, 0, sizeof(revision_t)); |
Jeej | 69:8f2fe2426ef9 | 190 | |
Jeej | 68:b2dd7309da44 | 191 | PRINT("------------ D7A Modem infos ------------\r\n"); |
Jeej | 68:b2dd7309da44 | 192 | PRINT_DATA(" - UID: ", "%02X", uid.b, 8, "\r\n"); |
Jeej | 68:b2dd7309da44 | 193 | PRINT(" - Manufacturer ID: %08X\r\n", rev.manufacturer_id); |
Jeej | 68:b2dd7309da44 | 194 | PRINT(" - Device ID: %08X\r\n", rev.device_id); |
Jeej | 68:b2dd7309da44 | 195 | PRINT(" - Hardware version: %08X\r\n", rev.hw_version); |
Jeej | 68:b2dd7309da44 | 196 | PRINT(" - Firmware version: v%d.%d.%d [%02X]\r\n", rev.fw_version.major, rev.fw_version.minor, rev.fw_version.patch, rev.fw_version.id); |
Jeej | 68:b2dd7309da44 | 197 | PRINT(" - CUP max size: %d\r\n", rev.cup_max_size); |
Jeej | 68:b2dd7309da44 | 198 | PRINT("-----------------------------------------\r\n"); |
Jeej | 69:8f2fe2426ef9 | 199 | FLUSH(); |
Jeej | 69:8f2fe2426ef9 | 200 | |
Jeej | 80:c2e45d6eab29 | 201 | modem_cup_update(&rev); |
Jeej | 69:8f2fe2426ef9 | 202 | |
Jeej | 68:b2dd7309da44 | 203 | return 0; |
Jeej | 68:b2dd7309da44 | 204 | } |
Jeej | 68:b2dd7309da44 | 205 | |
Jeej | 68:b2dd7309da44 | 206 | int modem_close(void) |
Jeej | 68:b2dd7309da44 | 207 | { |
Jeej | 68:b2dd7309da44 | 208 | modem_ref_close(); |
Jeej | 68:b2dd7309da44 | 209 | delete g_modem_com; |
Jeej | 69:8f2fe2426ef9 | 210 | |
Jeej | 68:b2dd7309da44 | 211 | return 0; |
Jeej | 68:b2dd7309da44 | 212 | } |
Jeej | 68:b2dd7309da44 | 213 | |
Jeej | 69:8f2fe2426ef9 | 214 | static int _modem_d7a_send(void* itf, alp_payload_t* alp, alp_payload_t** alp_rsp, uint32_t timeout) |
Jeej | 68:b2dd7309da44 | 215 | { |
Jeej | 69:8f2fe2426ef9 | 216 | u8 id = modem_ref_get_id(modem_cb); |
Jeej | 68:b2dd7309da44 | 217 | int err = ALP_ERR_UNKNOWN; |
Jeej | 70:753b602bd7bd | 218 | |
Jeej | 70:753b602bd7bd | 219 | // Make sure Semaphore is taken |
Jeej | 70:753b602bd7bd | 220 | g_s[id].try_acquire(); |
Jeej | 69:8f2fe2426ef9 | 221 | |
Jeej | 69:8f2fe2426ef9 | 222 | modem_ref_alp(itf, alp, alp_rsp, id); |
Jeej | 69:8f2fe2426ef9 | 223 | if (!g_s[id].try_acquire_for(timeout)) |
Jeej | 69:8f2fe2426ef9 | 224 | { |
Jeej | 80:c2e45d6eab29 | 225 | PRINT("Modem_d7a timeout (%dms) on id %d\n", timeout, id); |
Jeej | 69:8f2fe2426ef9 | 226 | err = ALP_ERR_UNKNOWN; |
Jeej | 69:8f2fe2426ef9 | 227 | } |
Jeej | 69:8f2fe2426ef9 | 228 | else |
Jeej | 69:8f2fe2426ef9 | 229 | { |
Jeej | 69:8f2fe2426ef9 | 230 | err = ALP_ERR_NONE; |
Jeej | 69:8f2fe2426ef9 | 231 | } |
Jeej | 69:8f2fe2426ef9 | 232 | |
Jeej | 68:b2dd7309da44 | 233 | modem_ref_free_id(id); |
Jeej | 69:8f2fe2426ef9 | 234 | |
Jeej | 68:b2dd7309da44 | 235 | return err; |
Jeej | 68:b2dd7309da44 | 236 | } |
Jeej | 68:b2dd7309da44 | 237 | |
Jeej | 69:8f2fe2426ef9 | 238 | static int _modem_get_istatus(alp_payload_t* alp, void* istatus) |
Jeej | 69:8f2fe2426ef9 | 239 | { |
Jeej | 69:8f2fe2426ef9 | 240 | alp_payload_t* alp_tmp = alp_payload_get(alp, ALP_OPCODE_RSP_ISTATUS); |
Jeej | 69:8f2fe2426ef9 | 241 | |
Jeej | 69:8f2fe2426ef9 | 242 | if (alp_tmp) |
Jeej | 69:8f2fe2426ef9 | 243 | { |
Jeej | 69:8f2fe2426ef9 | 244 | alp_parsed_chunk_t r; |
Jeej | 69:8f2fe2426ef9 | 245 | u8* p = alp_tmp->d; |
Jeej | 69:8f2fe2426ef9 | 246 | |
Jeej | 69:8f2fe2426ef9 | 247 | alp_parse_chunk(&p, &r); |
Jeej | 69:8f2fe2426ef9 | 248 | memcpy(istatus, r.data, r.meta.itf.length); |
Jeej | 69:8f2fe2426ef9 | 249 | |
Jeej | 69:8f2fe2426ef9 | 250 | return ALP_ERR_NONE; |
Jeej | 69:8f2fe2426ef9 | 251 | } |
Jeej | 69:8f2fe2426ef9 | 252 | else |
Jeej | 69:8f2fe2426ef9 | 253 | { |
Jeej | 69:8f2fe2426ef9 | 254 | PRINT("No metadata\n"); |
Jeej | 69:8f2fe2426ef9 | 255 | } |
Jeej | 69:8f2fe2426ef9 | 256 | |
Jeej | 69:8f2fe2426ef9 | 257 | return ALP_ERR_UNKNOWN; |
Jeej | 69:8f2fe2426ef9 | 258 | } |
Jeej | 69:8f2fe2426ef9 | 259 | |
Jeej | 76:cbe558f136a4 | 260 | int modem_raw_alp(alp_payload_t* alp, alp_payload_t** alp_rsp) |
Jeej | 68:b2dd7309da44 | 261 | { |
Jeej | 76:cbe558f136a4 | 262 | return _modem_d7a_send(NULL, alp, alp_rsp, MODEM_TIMEOUT_LOCAL); |
Jeej | 69:8f2fe2426ef9 | 263 | } |
Jeej | 69:8f2fe2426ef9 | 264 | |
Jeej | 76:cbe558f136a4 | 265 | int modem_remote_raw_alp(void* itf, alp_payload_t* alp, alp_payload_t** alp_rsp) |
Jeej | 69:8f2fe2426ef9 | 266 | { |
Jeej | 76:cbe558f136a4 | 267 | return _modem_d7a_send(itf, alp, alp_rsp, MODEM_TIMEOUT_DISTANT); |
Jeej | 69:8f2fe2426ef9 | 268 | } |
Jeej | 69:8f2fe2426ef9 | 269 | |
Jeej | 76:cbe558f136a4 | 270 | static int _modem_send_alp(void* itf, void *istatus, alp_payload_t* alp, uint32_t timeout) |
Jeej | 69:8f2fe2426ef9 | 271 | { |
Jeej | 68:b2dd7309da44 | 272 | int err = ALP_ERR_UNKNOWN; |
Jeej | 69:8f2fe2426ef9 | 273 | alp_payload_t* alp_rsp = NULL; |
Jeej | 69:8f2fe2426ef9 | 274 | |
Jeej | 75:dad2f09cb870 | 275 | err = _modem_d7a_send(itf, alp, &alp_rsp, timeout); |
Jeej | 69:8f2fe2426ef9 | 276 | |
Jeej | 69:8f2fe2426ef9 | 277 | do { |
Jeej | 69:8f2fe2426ef9 | 278 | if (ALP_ERR_NONE > err) { PRINT("Send ALP timeout\n"); break; } |
Jeej | 69:8f2fe2426ef9 | 279 | |
Jeej | 69:8f2fe2426ef9 | 280 | err = alp_payload_get_err(alp_rsp); |
Jeej | 69:8f2fe2426ef9 | 281 | |
Jeej | 69:8f2fe2426ef9 | 282 | if (ALP_ERR_NONE > err) { PRINT("Send ALP err %d\n", err); break; } |
Jeej | 69:8f2fe2426ef9 | 283 | |
Jeej | 69:8f2fe2426ef9 | 284 | if (istatus) |
Jeej | 69:8f2fe2426ef9 | 285 | { |
Jeej | 69:8f2fe2426ef9 | 286 | _modem_get_istatus(alp_rsp, istatus); |
Jeej | 69:8f2fe2426ef9 | 287 | } |
Jeej | 68:b2dd7309da44 | 288 | |
Jeej | 69:8f2fe2426ef9 | 289 | } while (0); |
Jeej | 69:8f2fe2426ef9 | 290 | |
Jeej | 69:8f2fe2426ef9 | 291 | alp_payload_free(alp_rsp); |
Jeej | 69:8f2fe2426ef9 | 292 | |
Jeej | 69:8f2fe2426ef9 | 293 | return err; |
Jeej | 69:8f2fe2426ef9 | 294 | } |
Jeej | 69:8f2fe2426ef9 | 295 | |
Jeej | 69:8f2fe2426ef9 | 296 | static int _modem_read_file(uint8_t* itf, void *istatus, uint8_t fid, void *data, uint32_t offset, uint32_t length, uint32_t timeout) |
Jeej | 69:8f2fe2426ef9 | 297 | { |
Jeej | 69:8f2fe2426ef9 | 298 | int err = ALP_ERR_UNKNOWN; |
Jeej | 69:8f2fe2426ef9 | 299 | alp_payload_t* alp = NULL; |
Jeej | 69:8f2fe2426ef9 | 300 | alp_payload_t* alp_rsp = NULL; |
Jeej | 69:8f2fe2426ef9 | 301 | |
Jeej | 69:8f2fe2426ef9 | 302 | alp = alp_payload_f_rd_data(NULL, fid, offset, length, false); |
Jeej | 69:8f2fe2426ef9 | 303 | |
Jeej | 69:8f2fe2426ef9 | 304 | err = _modem_d7a_send(NULL, alp, &alp_rsp, timeout); |
Jeej | 68:b2dd7309da44 | 305 | |
Jeej | 69:8f2fe2426ef9 | 306 | do { |
Jeej | 69:8f2fe2426ef9 | 307 | if (ALP_ERR_NONE > err) { PRINT("Read file timeout\n"); break; } |
Jeej | 69:8f2fe2426ef9 | 308 | |
Jeej | 69:8f2fe2426ef9 | 309 | err = alp_payload_get_err(alp_rsp); |
Jeej | 69:8f2fe2426ef9 | 310 | |
Jeej | 69:8f2fe2426ef9 | 311 | if (ALP_ERR_NONE > err) { PRINT("Read file err %d\n", err); break; } |
Jeej | 69:8f2fe2426ef9 | 312 | |
Jeej | 75:dad2f09cb870 | 313 | alp = alp_payload_get(alp_rsp, ALP_OPCODE_RSP_F_DATA); |
Jeej | 75:dad2f09cb870 | 314 | if (alp) |
Jeej | 69:8f2fe2426ef9 | 315 | { |
Jeej | 69:8f2fe2426ef9 | 316 | alp_parsed_chunk_t r; |
Jeej | 75:dad2f09cb870 | 317 | u8* p = alp->d; |
Jeej | 69:8f2fe2426ef9 | 318 | |
Jeej | 69:8f2fe2426ef9 | 319 | alp_parse_chunk(&p, &r); |
Jeej | 69:8f2fe2426ef9 | 320 | memcpy(data, r.data, r.meta.f_data.length); |
Jeej | 69:8f2fe2426ef9 | 321 | } |
Jeej | 69:8f2fe2426ef9 | 322 | else |
Jeej | 69:8f2fe2426ef9 | 323 | { |
Jeej | 69:8f2fe2426ef9 | 324 | PRINT("Read file no payload\n"); |
Jeej | 69:8f2fe2426ef9 | 325 | err = ALP_ERR_UNKNOWN; |
Jeej | 69:8f2fe2426ef9 | 326 | break; |
Jeej | 69:8f2fe2426ef9 | 327 | } |
Jeej | 69:8f2fe2426ef9 | 328 | |
Jeej | 69:8f2fe2426ef9 | 329 | if (istatus) |
Jeej | 69:8f2fe2426ef9 | 330 | { |
Jeej | 69:8f2fe2426ef9 | 331 | _modem_get_istatus(alp_rsp, istatus); |
Jeej | 69:8f2fe2426ef9 | 332 | } |
Jeej | 68:b2dd7309da44 | 333 | |
Jeej | 69:8f2fe2426ef9 | 334 | } while (0); |
Jeej | 69:8f2fe2426ef9 | 335 | |
Jeej | 69:8f2fe2426ef9 | 336 | alp_payload_free(alp_rsp); |
Jeej | 69:8f2fe2426ef9 | 337 | |
Jeej | 69:8f2fe2426ef9 | 338 | return err; |
Jeej | 69:8f2fe2426ef9 | 339 | } |
Jeej | 69:8f2fe2426ef9 | 340 | |
Jeej | 75:dad2f09cb870 | 341 | int modem_read_file(uint8_t fid, void *data, uint32_t offset, uint32_t length) |
Jeej | 69:8f2fe2426ef9 | 342 | { |
Jeej | 75:dad2f09cb870 | 343 | return _modem_read_file(NULL, NULL, fid, data, offset, length, MODEM_TIMEOUT_LOCAL); |
Jeej | 68:b2dd7309da44 | 344 | } |
Jeej | 68:b2dd7309da44 | 345 | |
Jeej | 75:dad2f09cb870 | 346 | int modem_remote_read_file(uint8_t* itf, void *istatus, uint8_t fid, void *data, uint32_t offset, uint32_t length) |
Jeej | 68:b2dd7309da44 | 347 | { |
Jeej | 75:dad2f09cb870 | 348 | return _modem_read_file(itf, istatus, fid, data, offset, length, MODEM_TIMEOUT_DISTANT); |
Jeej | 68:b2dd7309da44 | 349 | } |
Jeej | 68:b2dd7309da44 | 350 | |
Jeej | 68:b2dd7309da44 | 351 | int modem_write_file(uint8_t fid, void *data, uint32_t offset, uint32_t length) |
Jeej | 68:b2dd7309da44 | 352 | { |
Jeej | 75:dad2f09cb870 | 353 | alp_payload_t* alp = alp_payload_f_wr_data(NULL, fid, data, offset, length, false); |
Jeej | 76:cbe558f136a4 | 354 | return _modem_send_alp(NULL, NULL, alp, MODEM_TIMEOUT_LOCAL); |
Jeej | 68:b2dd7309da44 | 355 | } |
Jeej | 68:b2dd7309da44 | 356 | |
Jeej | 75:dad2f09cb870 | 357 | int modem_remote_write_file(uint8_t* itf, void *istatus , uint8_t fid, void *data, uint32_t offset, uint32_t length) |
Jeej | 68:b2dd7309da44 | 358 | { |
Jeej | 75:dad2f09cb870 | 359 | alp_payload_t* alp = alp_payload_f_wr_data(NULL, fid, data, offset, length, false); |
Jeej | 76:cbe558f136a4 | 360 | return _modem_send_alp(itf, istatus, alp, MODEM_TIMEOUT_DISTANT); |
Jeej | 75:dad2f09cb870 | 361 | } |
Jeej | 75:dad2f09cb870 | 362 | |
Jeej | 75:dad2f09cb870 | 363 | int modem_flush_file(uint8_t fid) |
Jeej | 75:dad2f09cb870 | 364 | { |
Jeej | 75:dad2f09cb870 | 365 | alp_payload_t* alp = alp_payload_f_flush(NULL, fid, false); |
Jeej | 76:cbe558f136a4 | 366 | return _modem_send_alp(NULL, NULL, alp, MODEM_TIMEOUT_LOCAL); |
Jeej | 68:b2dd7309da44 | 367 | } |
Jeej | 68:b2dd7309da44 | 368 | |
Jeej | 68:b2dd7309da44 | 369 | int modem_declare_file(uint8_t fid, alp_file_header_t* header) |
Jeej | 68:b2dd7309da44 | 370 | { |
Jeej | 75:dad2f09cb870 | 371 | alp_payload_t* alp = alp_payload_f_declare(NULL, fid, header); |
Jeej | 76:cbe558f136a4 | 372 | return _modem_send_alp(NULL, NULL, alp, MODEM_TIMEOUT_LOCAL); |
Jeej | 69:8f2fe2426ef9 | 373 | } |
Jeej | 69:8f2fe2426ef9 | 374 | |
Jeej | 72:15bf99fcfed9 | 375 | int modem_notify_file(uint8_t fid, uint32_t offset, uint32_t length) |
Jeej | 72:15bf99fcfed9 | 376 | { |
Jeej | 75:dad2f09cb870 | 377 | alp_payload_t* alp = alp_payload_f_touch(NULL, fid, offset, length, false); |
Jeej | 76:cbe558f136a4 | 378 | return _modem_send_alp(NULL, NULL, alp, MODEM_TIMEOUT_LOCAL); |
Jeej | 72:15bf99fcfed9 | 379 | } |
Jeej | 72:15bf99fcfed9 | 380 | |
Jeej | 69:8f2fe2426ef9 | 381 | static int _modem_d7a_itf_enable(u8 enable) |
Jeej | 69:8f2fe2426ef9 | 382 | { |
Jeej | 75:dad2f09cb870 | 383 | alp_payload_t* alp = alp_payload_activate_itf(NULL, ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_RESP | ALP_D7A_ISTAT_UNS | ALP_D7A_ISTAT_EOP, enable); |
Jeej | 76:cbe558f136a4 | 384 | return _modem_send_alp(NULL, NULL, alp, MODEM_TIMEOUT_LOCAL); |
Jeej | 68:b2dd7309da44 | 385 | } |
Jeej | 68:b2dd7309da44 | 386 | |
Jeej | 68:b2dd7309da44 | 387 | int modem_d7a_enable_itf(void) |
Jeej | 68:b2dd7309da44 | 388 | { |
Jeej | 69:8f2fe2426ef9 | 389 | return _modem_d7a_itf_enable(true); |
Jeej | 68:b2dd7309da44 | 390 | } |
Jeej | 68:b2dd7309da44 | 391 | |
Jeej | 68:b2dd7309da44 | 392 | int modem_d7a_disable_itf(void) |
Jeej | 68:b2dd7309da44 | 393 | { |
Jeej | 69:8f2fe2426ef9 | 394 | return _modem_d7a_itf_enable(false); |
Jeej | 69:8f2fe2426ef9 | 395 | } |
Jeej | 69:8f2fe2426ef9 | 396 | |
Jeej | 69:8f2fe2426ef9 | 397 | static int modem_lwan_set_urc(void) |
Jeej | 69:8f2fe2426ef9 | 398 | { |
Jeej | 75:dad2f09cb870 | 399 | alp_payload_t* alp = alp_payload_urcc_en(NULL, ALP_URC_TYPE_ITF_BUSY, FID_LWAN_ITF, 1); |
Jeej | 76:cbe558f136a4 | 400 | return _modem_send_alp(NULL, NULL, alp, MODEM_TIMEOUT_LOCAL); |
Jeej | 69:8f2fe2426ef9 | 401 | } |
Jeej | 69:8f2fe2426ef9 | 402 | |
Jeej | 69:8f2fe2426ef9 | 403 | static int modem_lwan_enable_itf(void) |
Jeej | 69:8f2fe2426ef9 | 404 | { |
Jeej | 75:dad2f09cb870 | 405 | alp_payload_t* alp = alp_payload_activate_itf(NULL, ALP_ITF_TYPE_LWAN, 1, FID_LWAN_ITF, 0, true); |
Jeej | 76:cbe558f136a4 | 406 | return _modem_send_alp(NULL, NULL, alp, MODEM_TIMEOUT_LOCAL); |
Jeej | 69:8f2fe2426ef9 | 407 | } |
Jeej | 69:8f2fe2426ef9 | 408 | |
Jeej | 77:5146f44cde83 | 409 | int modem_lwan_open(void) |
Jeej | 69:8f2fe2426ef9 | 410 | { |
Jeej | 68:b2dd7309da44 | 411 | int err = ALP_ERR_UNKNOWN; |
Jeej | 77:5146f44cde83 | 412 | |
Jeej | 69:8f2fe2426ef9 | 413 | err = modem_lwan_set_urc(); |
Jeej | 69:8f2fe2426ef9 | 414 | if (ALP_ERR_NONE > err) { return err; } |
Jeej | 69:8f2fe2426ef9 | 415 | |
Jeej | 69:8f2fe2426ef9 | 416 | err = modem_lwan_enable_itf(); |
Jeej | 68:b2dd7309da44 | 417 | |
Jeej | 68:b2dd7309da44 | 418 | return err; |
Jeej | 68:b2dd7309da44 | 419 | } |
Jeej | 68:b2dd7309da44 | 420 | |
Jeej | 69:8f2fe2426ef9 | 421 | int modem_lwan_set_cfg(lwan_cfg_t* cfg) |
Jeej | 69:8f2fe2426ef9 | 422 | { |
Jeej | 69:8f2fe2426ef9 | 423 | return modem_write_file(FID_LWAN_CFG, cfg, 0, sizeof(lwan_cfg_t)); |
Jeej | 69:8f2fe2426ef9 | 424 | } |
Jeej | 69:8f2fe2426ef9 | 425 | |
Jeej | 69:8f2fe2426ef9 | 426 | int modem_lwan_set_nls(lwan_nls_t* nls) |
Jeej | 69:8f2fe2426ef9 | 427 | { |
Jeej | 69:8f2fe2426ef9 | 428 | return modem_write_file(FID_LWAN_NLS, nls, 0, sizeof(lwan_nls_t)); |
Jeej | 69:8f2fe2426ef9 | 429 | } |
Jeej | 69:8f2fe2426ef9 | 430 | |
Jeej | 69:8f2fe2426ef9 | 431 | int modem_lwan_send(alp_payload_t* alp) |
Jeej | 69:8f2fe2426ef9 | 432 | { |
Jeej | 69:8f2fe2426ef9 | 433 | alp_itf_lwan_cfg_t itf = { .type = ALP_ITF_TYPE_LWAN }; |
Jeej | 76:cbe558f136a4 | 434 | return _modem_d7a_send((void*)&itf, alp, NULL, MODEM_TIMEOUT_DISTANT); |
Jeej | 69:8f2fe2426ef9 | 435 | } |
Jeej | 69:8f2fe2426ef9 | 436 | |
Jeej | 69:8f2fe2426ef9 | 437 | int modem_lwan_get_status(lwan_status_t* status) |
Jeej | 69:8f2fe2426ef9 | 438 | { |
Jeej | 69:8f2fe2426ef9 | 439 | return modem_read_file(FID_LWAN_STATUS, status, 0, sizeof(lwan_status_t)); |
Jeej | 69:8f2fe2426ef9 | 440 | } |
Jeej | 69:8f2fe2426ef9 | 441 | |
Jeej | 69:8f2fe2426ef9 | 442 | void modem_print_error(uint8_t itf, int error) |
Jeej | 68:b2dd7309da44 | 443 | { |
Jeej | 68:b2dd7309da44 | 444 | if (ALP_ERR_ITF_START >= error && ALP_ERR_ITF_END < error) |
Jeej | 68:b2dd7309da44 | 445 | { |
Jeej | 68:b2dd7309da44 | 446 | error -= ALP_ERR_ITF_START; |
Jeej | 68:b2dd7309da44 | 447 | // Interface specific error |
Jeej | 68:b2dd7309da44 | 448 | if (ALP_ITF_TYPE_HOST == itf) |
Jeej | 68:b2dd7309da44 | 449 | { |
Jeej | 69:8f2fe2426ef9 | 450 | PRINT("ITF[%02X] Error %d\r\n", itf, error); |
Jeej | 68:b2dd7309da44 | 451 | } |
Jeej | 68:b2dd7309da44 | 452 | else if (ALP_ITF_TYPE_COM == itf) |
Jeej | 68:b2dd7309da44 | 453 | { |
Jeej | 69:8f2fe2426ef9 | 454 | PRINT("ITF[%02X] Error %d\r\n", itf, error); |
Jeej | 68:b2dd7309da44 | 455 | } |
Jeej | 68:b2dd7309da44 | 456 | else if (ALP_ITF_TYPE_D7A == itf) |
Jeej | 68:b2dd7309da44 | 457 | { |
Jeej | 68:b2dd7309da44 | 458 | PRINT("ITF[%02X] ", itf); |
Jeej | 68:b2dd7309da44 | 459 | switch (error) |
Jeej | 68:b2dd7309da44 | 460 | { |
Jeej | 68:b2dd7309da44 | 461 | /// No error |
Jeej | 68:b2dd7309da44 | 462 | case D7A_ERROR_NO: // = 0, |
Jeej | 68:b2dd7309da44 | 463 | PRINT("D7A_ERROR_NO\r\n"); |
Jeej | 68:b2dd7309da44 | 464 | break; |
Jeej | 69:8f2fe2426ef9 | 465 | /// Resource busy |
Jeej | 68:b2dd7309da44 | 466 | case D7A_ERROR_BUSY: // = -1, |
Jeej | 68:b2dd7309da44 | 467 | PRINT("D7A_ERROR_BUSY\r\n"); |
Jeej | 68:b2dd7309da44 | 468 | break; |
Jeej | 69:8f2fe2426ef9 | 469 | /// Bad parameter |
Jeej | 68:b2dd7309da44 | 470 | case D7A_ERROR_BAD_PARAM: // = -2, |
Jeej | 68:b2dd7309da44 | 471 | PRINT("D7A_ERROR_BAD_PARAM\r\n"); |
Jeej | 68:b2dd7309da44 | 472 | break; |
Jeej | 69:8f2fe2426ef9 | 473 | /// Duty cycle limit overflow |
Jeej | 68:b2dd7309da44 | 474 | case D7A_ERROR_DUTY_CYCLE: // = -3, |
Jeej | 68:b2dd7309da44 | 475 | PRINT("D7A_ERROR_DUTY_CYCLE\r\n"); |
Jeej | 68:b2dd7309da44 | 476 | break; |
Jeej | 69:8f2fe2426ef9 | 477 | /// CCA timeout |
Jeej | 68:b2dd7309da44 | 478 | case D7A_ERROR_CCA_TO: // = -4, |
Jeej | 68:b2dd7309da44 | 479 | PRINT("D7A_ERROR_CCA_TO\r\n"); |
Jeej | 68:b2dd7309da44 | 480 | break; |
Jeej | 69:8f2fe2426ef9 | 481 | /// Security frame counter overflow |
Jeej | 68:b2dd7309da44 | 482 | case D7A_ERROR_NLS_KEY: // = -5, |
Jeej | 68:b2dd7309da44 | 483 | PRINT("D7A_ERROR_NLS_KEY\r\n"); |
Jeej | 68:b2dd7309da44 | 484 | break; |
Jeej | 69:8f2fe2426ef9 | 485 | /// TX stream underflow |
Jeej | 68:b2dd7309da44 | 486 | case D7A_ERROR_TX_UDF: // = -6, |
Jeej | 68:b2dd7309da44 | 487 | PRINT("D7A_ERROR_TX_UDF\r\n"); |
Jeej | 68:b2dd7309da44 | 488 | break; |
Jeej | 69:8f2fe2426ef9 | 489 | /// RX stream overflow |
Jeej | 68:b2dd7309da44 | 490 | case D7A_ERROR_RX_OVF: // = -7, |
Jeej | 68:b2dd7309da44 | 491 | PRINT("D7A_ERROR_RX_OVF\r\n"); |
Jeej | 68:b2dd7309da44 | 492 | break; |
Jeej | 69:8f2fe2426ef9 | 493 | /// RX checksum |
Jeej | 68:b2dd7309da44 | 494 | case D7A_ERROR_RX_CRC: // = -8, |
Jeej | 68:b2dd7309da44 | 495 | PRINT("D7A_ERROR_RX_CRC\r\n"); |
Jeej | 68:b2dd7309da44 | 496 | break; |
Jeej | 69:8f2fe2426ef9 | 497 | /// Abort |
Jeej | 68:b2dd7309da44 | 498 | case D7A_ERROR_ABORT: // = -9, |
Jeej | 68:b2dd7309da44 | 499 | PRINT("D7A_ERROR_ABORT\r\n"); |
Jeej | 68:b2dd7309da44 | 500 | break; |
Jeej | 69:8f2fe2426ef9 | 501 | /// No ACK received |
Jeej | 68:b2dd7309da44 | 502 | case D7A_ERROR_NO_ACK: // = -10, |
Jeej | 68:b2dd7309da44 | 503 | PRINT("D7A_ERROR_NO_ACK\r\n"); |
Jeej | 68:b2dd7309da44 | 504 | break; |
Jeej | 69:8f2fe2426ef9 | 505 | /// RX timeout |
Jeej | 69:8f2fe2426ef9 | 506 | case D7A_ERROR_RX_TO: // = -11, |
Jeej | 68:b2dd7309da44 | 507 | PRINT("D7A_ERROR_RX_TO\r\n"); |
Jeej | 68:b2dd7309da44 | 508 | break; |
Jeej | 68:b2dd7309da44 | 509 | default: |
Jeej | 68:b2dd7309da44 | 510 | PRINT("Unknown Error %d\r\n", error); |
Jeej | 68:b2dd7309da44 | 511 | break; |
Jeej | 68:b2dd7309da44 | 512 | } |
Jeej | 68:b2dd7309da44 | 513 | } |
Jeej | 68:b2dd7309da44 | 514 | else if (ALP_ITF_TYPE_LWAN == itf) |
Jeej | 68:b2dd7309da44 | 515 | { |
Jeej | 69:8f2fe2426ef9 | 516 | PRINT("ITF[%02X] Error %d\r\n", itf, error); |
Jeej | 68:b2dd7309da44 | 517 | } |
Jeej | 68:b2dd7309da44 | 518 | else |
Jeej | 68:b2dd7309da44 | 519 | { |
Jeej | 69:8f2fe2426ef9 | 520 | PRINT("ITF[%02X] Error %d\r\n", itf, error); |
Jeej | 68:b2dd7309da44 | 521 | } |
Jeej | 68:b2dd7309da44 | 522 | } |
Jeej | 68:b2dd7309da44 | 523 | else |
Jeej | 68:b2dd7309da44 | 524 | { |
Jeej | 69:8f2fe2426ef9 | 525 | PRINT("ITF[%02X] ALP: ", itf); |
Jeej | 68:b2dd7309da44 | 526 | switch (error) |
Jeej | 68:b2dd7309da44 | 527 | { |
Jeej | 68:b2dd7309da44 | 528 | // Not really errors, more like status |
Jeej | 69:8f2fe2426ef9 | 529 | case ALP_ERR_ITF_FULL: // 0x02: For interfaces supporting buffering, indicates buffer reached maximum capacity (no data loss) |
Jeej | 68:b2dd7309da44 | 530 | PRINT("ALP_ERR_ITF_FULL\r\n"); |
Jeej | 68:b2dd7309da44 | 531 | break; |
Jeej | 68:b2dd7309da44 | 532 | case ALP_ERR_PARTIAL_COMPLETION: // 0x01: Action received and partially completed at response. To be completed after response |
Jeej | 68:b2dd7309da44 | 533 | PRINT("ALP_ERR_PARTIAL_COMPLETION\r\n"); |
Jeej | 68:b2dd7309da44 | 534 | break; |
Jeej | 69:8f2fe2426ef9 | 535 | |
Jeej | 69:8f2fe2426ef9 | 536 | // ALP Errors |
Jeej | 68:b2dd7309da44 | 537 | case ALP_ERR_NONE: // 0x00: Action completed (OK) |
Jeej | 68:b2dd7309da44 | 538 | PRINT("ALP_ERR_NONE\r\n"); |
Jeej | 68:b2dd7309da44 | 539 | break; |
Jeej | 68:b2dd7309da44 | 540 | case ALP_ERR_FILE_NOT_FOUND: // 0xFF: Error access file: File ID does not exist |
Jeej | 68:b2dd7309da44 | 541 | PRINT("ALP_ERR_FILE_NOT_FOUND\r\n"); |
Jeej | 68:b2dd7309da44 | 542 | break; |
Jeej | 68:b2dd7309da44 | 543 | case ALP_ERR_FILE_EXIST: // 0xFE: Error create file: File ID already exists |
Jeej | 68:b2dd7309da44 | 544 | PRINT("ALP_ERR_FILE_EXIST\r\n"); |
Jeej | 68:b2dd7309da44 | 545 | break; |
Jeej | 68:b2dd7309da44 | 546 | case ALP_ERR_FILE_NOT_RESTORABLE: // 0xFD: Error restore file: File is not restorable |
Jeej | 68:b2dd7309da44 | 547 | PRINT("ALP_ERR_FILE_NOT_RESTORABLEr\n"); |
Jeej | 68:b2dd7309da44 | 548 | break; |
Jeej | 68:b2dd7309da44 | 549 | case ALP_ERR_PERMISSION_DENIED: // 0xFC: Error access file: Insufficient permissions |
Jeej | 68:b2dd7309da44 | 550 | PRINT("ALP_ERR_PERMISSION_DENIED\r\n"); |
Jeej | 68:b2dd7309da44 | 551 | break; |
Jeej | 68:b2dd7309da44 | 552 | case ALP_ERR_LENGTH_OVERFLOW: // 0xFB: Error create file: Supplied length (in header) is beyond file limits |
Jeej | 68:b2dd7309da44 | 553 | PRINT("ALP_ERR_LENGTH_OVERFLOW\r\n"); |
Jeej | 68:b2dd7309da44 | 554 | break; |
Jeej | 68:b2dd7309da44 | 555 | case ALP_ERR_ALLOC_OVERFLOW: // 0xFA: Error create file: Supplied allocation (in header) is beyond file limits |
Jeej | 68:b2dd7309da44 | 556 | PRINT("ALP_ERR_ALLOC_OVERFLOW\r\n"); |
Jeej | 68:b2dd7309da44 | 557 | break; |
Jeej | 68:b2dd7309da44 | 558 | case ALP_ERR_OFFSET_OVERFLOW: // 0xF9: Error write: Supplied start offset is out of bounds of file allocation |
Jeej | 68:b2dd7309da44 | 559 | PRINT("ALP_ERR_OFFSET_OVERFLOW\r\n"); |
Jeej | 68:b2dd7309da44 | 560 | break; |
Jeej | 68:b2dd7309da44 | 561 | case ALP_ERR_WRITE_OVERFLOW: // 0xF8: Error complete write: Supplied data goes beyond file allocation |
Jeej | 68:b2dd7309da44 | 562 | PRINT("ALP_ERR_WRITE_OVERFLOW\r\n"); |
Jeej | 68:b2dd7309da44 | 563 | break; |
Jeej | 68:b2dd7309da44 | 564 | case ALP_ERR_WRITE_ERROR: // 0xF7: Error write: impossible to write in storage location |
Jeej | 68:b2dd7309da44 | 565 | PRINT("ALP_ERR_WRITE_ERROR\r\n"); |
Jeej | 68:b2dd7309da44 | 566 | break; |
Jeej | 68:b2dd7309da44 | 567 | case ALP_ERR_OPERATION_UNKNOWN: // 0xF6: Error unknown Operation |
Jeej | 68:b2dd7309da44 | 568 | PRINT("ALP_ERR_OPERATION_UNKNOWN\r\n"); |
Jeej | 68:b2dd7309da44 | 569 | break; |
Jeej | 68:b2dd7309da44 | 570 | case ALP_ERR_OPERAND_INCOMPLETE: // 0xF5: Error incomplete Operand |
Jeej | 68:b2dd7309da44 | 571 | PRINT("ALP_ERR_OPERAND_INCOMPLETE\r\n"); |
Jeej | 68:b2dd7309da44 | 572 | break; |
Jeej | 68:b2dd7309da44 | 573 | case ALP_ERR_OPERAND_WRONG_FORMAT: // 0xF4: Error wrong Operand format |
Jeej | 68:b2dd7309da44 | 574 | PRINT("ALP_ERR_OPERAND_WRONG_FORMAT\r\n"); |
Jeej | 68:b2dd7309da44 | 575 | break; |
Jeej | 68:b2dd7309da44 | 576 | case ALP_ERR_ITF_INVALID: // 0xF3: Error invalid interface |
Jeej | 68:b2dd7309da44 | 577 | PRINT("ALP_ERR_ITF_INVALID\r\n"); |
Jeej | 68:b2dd7309da44 | 578 | break; |
Jeej | 68:b2dd7309da44 | 579 | case ALP_ERR_ITF_OVERFLOW: // 0xF2: Error interface overflown (i.e. resources exhausted, buffer full with data discarded) |
Jeej | 68:b2dd7309da44 | 580 | PRINT("ALP_ERR_ITF_OVERFLOW\r\n"); |
Jeej | 68:b2dd7309da44 | 581 | break; |
Jeej | 68:b2dd7309da44 | 582 | case ALP_ERR_QUERY_FAIL: // 0xF1: (Group of) Query result was false (Informative error code). |
Jeej | 68:b2dd7309da44 | 583 | PRINT("ALP_ERR_QUERY_FAIL\r\n"); |
Jeej | 68:b2dd7309da44 | 584 | break; |
Jeej | 68:b2dd7309da44 | 585 | case ALP_ERR_ITF_NOT_SPECIFIED: |
Jeej | 68:b2dd7309da44 | 586 | PRINT("ALP_ERR_ITF_NOT_SPECIFIED\r\n"); |
Jeej | 68:b2dd7309da44 | 587 | break; |
Jeej | 69:8f2fe2426ef9 | 588 | |
Jeej | 69:8f2fe2426ef9 | 589 | // Other Errors |
Jeej | 68:b2dd7309da44 | 590 | case ALP_ERR_UNKNOWN: // 0x80: Unknown error |
Jeej | 68:b2dd7309da44 | 591 | PRINT("ALP_ERR_UNKNOWN\r\n"); |
Jeej | 68:b2dd7309da44 | 592 | break; |
Jeej | 68:b2dd7309da44 | 593 | case ALP_ERR_FS_TIMEOUT: // 0x81: Internal FS Error |
Jeej | 68:b2dd7309da44 | 594 | PRINT("ALP_ERR_FS_TIMEOUT\r\n"); |
Jeej | 68:b2dd7309da44 | 595 | break; |
Jeej | 68:b2dd7309da44 | 596 | case ALP_ERR_ITF_UNKNOWN: // 0x82: Unknown Interface |
Jeej | 68:b2dd7309da44 | 597 | PRINT("ALP_ERR_ITF_UNKNOWN\r\n"); |
Jeej | 68:b2dd7309da44 | 598 | break; |
Jeej | 68:b2dd7309da44 | 599 | case ALP_ERR_ITF_TIMEOUT: // 0x83: Internal ITF Error |
Jeej | 68:b2dd7309da44 | 600 | PRINT("ALP_ERR_ITF_TIMEOUT\r\n"); |
Jeej | 68:b2dd7309da44 | 601 | break; |
Jeej | 68:b2dd7309da44 | 602 | default: |
Jeej | 68:b2dd7309da44 | 603 | PRINT("Unknown Error %d\r\n", error); |
Jeej | 68:b2dd7309da44 | 604 | break; |
Jeej | 68:b2dd7309da44 | 605 | } |
Jeej | 68:b2dd7309da44 | 606 | } |
Jeej | 69:8f2fe2426ef9 | 607 | } |