// // Created by zemon on 27.12.22. // #include #include "AtCmdCommonProtected.h" #include "SystemDelayInterface.h" AtCommandResult AtGsmSms_GetPdu( tAtCmd *env, char *pduHex, uint8_t *pduHexSize, uint8_t pduHexLimit ) { *pduHexSize = 0; uint32_t endMs = SystemGetMs() + 2000; while (endMs > SystemGetMs()) { if (AtCmdReceiveNextLine(env, 1000) == AT_OK) { uint16_t pos = 0; if (AtCmdRxBeginWithStatic(env, "+CMGL:")) { if (AtCmdReceiveNextLine(env, 500) == AT_OK) { while ((pos < pduHexLimit) && (env->rxBuffer.data[pos] != '\r')) { pduHex[pos] = env->rxBuffer.data[pos]; ++pos; } } *pduHexSize = pos; return AT_OK; } if (AtCmdRxBeginWithStatic(env, "+CMS ERROR: ")) { return AT_ERROR; } if (AtCmdRxBeginWithStatic(env, "OK")) { return AT_TIMEOUT; } AtCmdProcessUnresolvedLine(env); } } return AT_TIMEOUT; } AtCommandResult AtGsmSms_ReedOneNewPdu( tAtCmd *env, char *pduHex, uint8_t *pduHexSize, uint16_t pduHexLimit ) { if(env->test == 1){ /// запрос на переотправку МНД char hexData[] = "04814523F1040A8180515634120004329072513435402B0100000B001E000A00013117000A00400404331400500A000000000000000000000013010000000002712B"; uint16_t pos = 0; while ((pos < pduHexLimit) && (hexData[pos] != 0)) { pduHex[pos] = hexData[pos]; ++pos; } *pduHexSize = pos; env->test=0; return AT_OK; } else if (env->test == 2){ /// запрос повторного вызова char hexData[] = "04814523F1040A818051563412000432215221141500270100000B001A00040001D913000400400404331000500400000000000000000000001201000DF1"; uint16_t pos = 0; while ((pos < pduHexLimit) && (hexData[pos] != 0)) { pduHex[pos] = hexData[pos]; ++pos; } *pduHexSize = pos; env->test=0; return AT_OK; } else if (env->test == 3){ /// Установка номера для отправки информации по SMS (555) char hexData[] = "04804523F1040A8080515634120004324041318175402A0100000B001D000A00017516000A00400404331300500A0000000000000000000002230235353535852C"; uint16_t pos = 0; while ((pos < pduHexLimit) && (hexData[pos] != 0)) { pduHex[pos] = hexData[pos]; ++pos; } *pduHexSize = pos; env->test=0; return AT_OK; } else if (env->test == 4){ /// запрос на обновление char hexData[] = "04814523F1040A8180515634120000429042512592404EB0180C0683C18430582C0883C16030182C6684C56630180C0683D160301A8C369BC56030580D0683C16030180C0683C16030180C0683C16030184C06A3C16433580C37CC01"; // char hexData[] = "04814523F111000A81805156341200F40B4E303130303030304230303141303030303030303146303133303030303030343030343034333331303030353030303030303030303030303030303030303030303030303230343032333031384339"; uint16_t pos = 0; while ((pos < pduHexLimit) && (hexData[pos] != 0)) { pduHex[pos] = hexData[pos]; ++pos; } *pduHexSize = pos; env->test=0; return AT_OK; } // /// запрос на переотправку МНД // char hexData[] = "04814523F1040A8180515634120004329072513435402B0100000B001E000A00013117000A00400404331400500A000000000000000000000013010000000002712B"; // char hexData[] = "04814523F1040A8180515634120004329052815002402B0100000B001E000600014A1700060040040433140050060000000000000000000000130100000000028155"; // char hexData[] = "04814523F1040A8180515634120004326090419405402B0100000B001E00010001A91700010040040433140050010000000000000000000000130100000000027290"; // char hexData[] = "0100010B003300010001EA2800010094E07404110A0A282500010222140601430145554B3C25C00000810037F08B8835FC1179A7A7B0FE0F1C1FE000001AA3D2"; /// установка номера /* * Установка номера для отправки информации по SMS (555) */ // char hexData[] = "04804523F1040A8080515634120004324041318175402A0100000B001D000A00017516000A00400404331300500A0000000000000000000002230235353535852C"; /* * Установка номера для тестового вызова 79418100025 */ // char hexData[] = "07919714180010F3040B919714111190F7000432302231033221350100000B0028000A00013D1D000A00010A0000000404331A00500A000000A9010000000100420D0237393431383130303032357D82"; // char hexData[] = "07919714180010F3040B919714111190F70004323022310332213501A001C00012F13001C00400404331000501C0000000000000000000000120100A87010101010"; /// запрос повторного вызова // char hexData[] = "04814523F1040A818051563412000432215221141500270100000B001A00040001D913000400400404331000500400000000000000000000001201000DF1"; // uint16_t pos = 0; // while ((pos < pduHexLimit) && (hexData[pos] != 0)) { // pduHex[pos] = hexData[pos]; // ++pos; // } // *pduHexSize = pos; // return AT_OK; // ///============================================================================================================== AtCmdPrepare(env); AtCmdSendStatic(env, "AT+CMGL=0\r\n"); if(AtGsmSms_GetPdu(env, pduHex, pduHexSize, pduHexLimit) == AT_OK){ return AT_OK; } else { AtCmdPrepare(env); AtCmdSendStatic(env, "AT+CMGL=1\r\n"); if(AtGsmSms_GetPdu(env, pduHex, pduHexSize, pduHexLimit) == AT_OK){ return AT_OK; } } return AT_ERROR; }