Changeset 65 for ctrl/firmware/Main/SES/Core
- Timestamp:
- Jan 21, 2025, 11:26:15 AM (4 days ago)
- Location:
- ctrl/firmware/Main/SES/Core
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ctrl/firmware/Main/SES/Core/Inc/gsm_thread.h
r64 r65 3 3 4 4 #include "tx_api.h" 5 6 struct Gsm_req_resp_t7 {8 const char* const req;9 const char* const resp;10 void* ptr;11 };12 5 13 6 #ifdef __cplusplus -
ctrl/firmware/Main/SES/Core/Src/gsm_thread.cpp
r64 r65 15 15 static constexpr GPIO_PinState GSM_STATUS_MODULE_IS_OFF = GPIO_PIN_RESET; 16 16 17 18 17 static constexpr unsigned PWR_PULSE_DELAY_MS = 50U; // See datasheet for A7672X 19 18 static constexpr ULONG PWR_STATUS_DELAY_MS = 10000U; // See datasheet for A7672X (Typ. 7s) … … 22 21 static uint16_t delay_ms = 5000U; 23 22 24 static const char* const PREFIX = "AT"; 25 static const char* const PLUS = "+"; 26 static const char* const EQUAL = "="; 27 static const char* const QUESTION = "?"; 28 static const char* const CR = "\r"; 29 static const char* const FMT = "%s\n"; 30 31 static const char* const SIGNAL_QUALITY = "CSQ"; 32 33 static Gsm_req_resp_t rr[] = { 34 {} 35 }; 36 37 static constexpr unsigned INPUT_BUF_SIZE = 512U; 23 24 struct Gsm_req_resp_t 25 { 26 const char* const prfx; 27 const char* const pls; 28 const char* const req; 29 const char* const eql; 30 const char* const qstn; 31 const char* const param; 32 bool exec_once; 33 bool is_exec; 34 uint16_t delay_ms; 35 const uint16_t repeat_num; 36 uint16_t repeat_cnt; 37 }; 38 39 static const char* const PRFX = "AT"; 40 static const char* const PLS = "+"; 41 static const char* const EQ = "="; 42 static const char* const QM = "?"; 43 static const char* const CR = "\r"; 44 static const char* const FMT = "%s%s%s%s%s%s%s"; 45 static const char* const CPIN = "CPIN"; 46 static const char* const CSQ = "CSQ"; 47 static const char* const CGMI = "CGMI"; 48 static const char* const CMGF = "CMGF"; 49 static const char* const CMGS = "CMGS"; 50 static const char* const CGNSSPWR = "CGNSSPWR"; 51 static const char* const CGNSSPROD = "CGNSSPROD"; 52 static const char* const CGNSSIPR = "CGNSSIPR"; 53 static const char* const CGNSSPORTSWITCH = "CGNSSPORTSWITCH"; 54 static const char* const CGPSINFO = "CGPSINFO"; 55 static const char* const CGNSSINFO = "CGNSSINFO"; 56 static const char* const CGPSCOLD = "CGPSCOLD"; 57 static const char* const CGNSSMODE = "CGNSSMODE"; 58 static const char* const CWSTASCAN = "CWSTASCAN"; 59 static const char* const BLEPOWER = "BLEPOWER"; 60 static const char* const BLESTATUS = "BLESTATUS"; 61 //static const char* const BTPOWER = "BTPOWER"; 62 //static const char* const BTSCAN = "BTSCAN"; 63 static const char* const BLESCAN = "BLESCAN"; 64 static const char* const BLEADDR = "BLEADDR"; 65 //static const char* const BTHOST = "BTHOST"; 66 //static const char* const BTADDR = "BTADDR"; 67 static const char* const BLEHOST = "BLEHOST"; 68 static const char* const BLESREG = "BLESREG"; 69 static const char* const BLESSAD = "BLESSAD"; 70 static const char* const BLESSCAD = "BLESSCAD"; 71 static const char* const BLESSDAD = "BLESSDAD"; 72 static const char* const BLESSSTART = "BLESSSTART"; 73 static const char* const BLESLSTART = "BLESLSTART"; 74 75 static constexpr unsigned GSM_CMD_COUNT = 22U; 76 static Gsm_req_resp_t rr[GSM_CMD_COUNT] = { // Once 77 { PRFX, PLS, CPIN, "", QM, "", false, false, 25000U, 0 , 0 }, 78 { PRFX, PLS, CPIN, EQ, "", "5196", true, false, 30000U, 0 , 0 }, 79 //{ PRFX, PLS, CGMI, "", "", "", false, false, 5000U, 0 , 0 }, 80 //{ PRFX, PLS, CMGF, "", QM, "", false, false, 5000U, 0 , 0 }, 81 //{ PRFX, PLS, CMGF, EQ, "", "1", true, false, 5000U, 0 , 0 }, 82 //{ PRFX, PLS, CSQ, "", "", "", false, false, 5000U, 10 , 0 }, 83 //{ PRFX, PLS, CGNSSIPR, EQ, QM, "", false, false, 5000U, 0 , 0 }, 84 //{ PRFX, PLS, CGNSSIPR, EQ, "", "230400", true, false, 5000U, 0 , 0 }, 85 { PRFX, PLS, CGNSSPWR, "", QM, "", false, false, 5000U, 0 , 0 }, 86 { PRFX, PLS, CGNSSPWR, EQ, "", "1", true, false, 30000U, 0 , 0 }, 87 { PRFX, PLS, CGNSSPROD, "", "", "", false, false, 5000U, 0 , 0 }, 88 { PRFX, PLS, CGNSSPORTSWITCH, "", QM, "", false, false, 5000U, 0 , 0 }, 89 { PRFX, PLS, CGNSSPORTSWITCH, EQ, "", "1,0", true, false, 5000U, 0 , 0 }, 90 { PRFX, PLS, CSQ, "", "", "", false, false, 5000U, 0 , 0 }, 91 //{ PRFX, PLS, CMGS, EQ, "", "+4917647653312", true, false, 20U, 1, , 0 }, 92 //{ "", "", "", "", "", "Test message!\032", true, false, 5000U, 1, , 0 }, 93 { PRFX, PLS, CGPSINFO, "", "", "", false, false, 5000U, 0 , 0 }, 94 { PRFX, PLS, CGNSSINFO, "", "", "", false, false, 5000U, 0 , 0 }, 95 //{ PRFX, PLS, CGPSCOLD, "", "", "", true, false, 5000U, 0 , 0 }, 96 { PRFX, PLS, CGNSSMODE, "", QM, "", false, false, 5000U, 0 , 0 }, 97 //{ PRFX, PLS, CWSTASCAN, EQ, "", "1", false, false, 5000U, 0 , 0 }, 98 //{ PRFX, PLS, CWSTASCAN, "", QM, "", false, false, 5000U, 0 , 0 }, 99 //{ PRFX, PLS, CWSTASCAN, "", "", "", false, false, 5000U, 0 , 0 }, 100 { PRFX, PLS, BLEADDR, "", QM, "", false, false, 5000U, 0 , 0 }, 101 { PRFX, PLS, BLESTATUS, "", QM, "", false, false, 5000U, 0 , 0 }, 102 { PRFX, PLS, BLEHOST, "", QM, "", false, false, 5000U, 0 , 0 }, 103 { PRFX, PLS, BLEPOWER, "", QM, "", false, false, 5000U, 0 , 0 }, 104 { PRFX, PLS, BLEPOWER, EQ, "", "1", true, false, 5000U, 0 , 0 }, 105 { PRFX, PLS, BLESREG, "", "", "", true, false, 5000U, 0 , 0 }, 106 { PRFX, PLS, BLESSAD, EQ, "", "0,\"1802\",30,1,0", true, false, 5000U, 0 , 0 }, 107 { PRFX, PLS, BLESSCAD, EQ, "", "0,\"2A06\",4,38,3", true, false, 5000U, 0 , 0 }, 108 { PRFX, PLS, BLESSDAD, EQ, "", "0,\"2902\",4,0", true, false, 5000U, 0 , 0 }, 109 { PRFX, PLS, BLESSSTART, EQ, "", "0,0", true, false, 5000U, 0 , 0 }, 110 { PRFX, PLS, BLESLSTART, EQ, "", "0", true, false, 5000U, 0 , 0 }, 111 }; 112 113 //static constexpr unsigned INPUT_BUF_SIZE = 512U; 38 114 static constexpr unsigned OUTPUT_BUF_SIZE = 64U; 39 static char ibuf[INPUT_BUF_SIZE]__attribute__((section(".RAM1")));40 static char input_buf[INPUT_BUF_SIZE]__attribute__((section(".RAM1")));41 static char obuf[OUTPUT_BUF_SIZE] __attribute__((section(".RAM1")));42 static unsigned input_buf_num; 115 //alignas(4) static char input_buf[INPUT_BUF_SIZE] __attribute__((section(".RAM1"))); 116 alignas(4) static char obuf[OUTPUT_BUF_SIZE] __attribute__((section(".RAM1"))); 117 //static unsigned input_buf_num; 118 43 119 44 120 //------------------------------------------------------------------------------ … … 51 127 { 52 128 (void)initial_input; 129 //extern DMA_HandleTypeDef hdma_usart3_tx; 53 130 54 131 TurnGSMModuleOn(); 55 132 56 HAL_UARTEx_ReceiveToIdle_DMA(&huart3, (uint8_t*)ibuf, INPUT_BUF_SIZE);133 tx_thread_sleep(10000); 57 134 58 135 while(1) 59 136 { 60 tx_thread_sleep(delay_ms);61 62 sprintf(obuf, "%s%s", "AT+CSQ", CR);63 HAL_UART_Transmit_DMA(&huart3, (uint8_t*)obuf, strlen(obuf));64 65 66 if (input_buf_num)67 {68 printf("\n");69 for (auto i = 0U; i < input_buf_num; i++) printf("%c", ibuf[i]);70 printf(" \n");137 //printf("Waiting %ums...\n", 1000U); 138 tx_thread_sleep(1000); 139 //while(!input_buf_num) tx_thread_sleep(10); 140 /*if (input_buf_num) 141 { 142 //printf("%lu\n", tx_time_get()); 143 printf("Got %2u bytes: [", input_buf_num); 144 for (auto i = 0U; i < input_buf_num; i++) 145 if (input_buf[i] >= ' ') printf("%c", input_buf[i]); 146 else printf(" %c", ' '); 147 printf("]\n"); 71 148 input_buf_num = 0; 72 } 73 74 printThreadStackInfo(TAG); 149 //printf("%lu\n", tx_time_get()); 150 }*/ 151 152 static unsigned idx; 153 unsigned i = idx % GSM_CMD_COUNT; 154 if (!(rr[i].exec_once && rr[i].is_exec)) 155 { 156 sprintf(obuf, FMT, rr[i].prfx, rr[i].pls, rr[i].req, rr[i].eql, rr[i].qstn, rr[i].param, CR); 157 158 size_t len = strlen(obuf); 159 if (len) 160 { 161 printf("Sending %02u bytes: {", len); 162 for (auto j = 0U; j < len; j++) printf("%c", obuf[j] >= 0x20 ? obuf[j]: '_'); 163 printf("}\n"); 164 165 166 HAL_UART_Transmit_IT(&huart3, (uint8_t*)obuf, strlen(obuf)); 167 if (rr[i].exec_once) rr[i].is_exec = true; 168 169 //printf("Waiting %ums...\n", rr[i].delay_ms); 170 tx_thread_sleep(rr[i].delay_ms); 171 } 172 } 173 174 if (rr[i].repeat_num) 175 { 176 if (++rr[i].repeat_cnt >= rr[i].repeat_num) 177 { 178 rr[i].repeat_cnt = 0; 179 idx++; 180 } 181 } 182 else idx++; 183 //printThreadStackInfo(TAG); 75 184 } 76 185 } … … 81 190 { 82 191 // Putting data into queue 83 memcpy(input_buf, ibuf, BytesNum); 84 input_buf_num = BytesNum; 192 //printf("%lu\n", tx_time_get()); 193 //memcpy(input_buf, ibuf, BytesNum); 194 //input_buf_num = BytesNum; 195 //printf("%lu\n", tx_time_get()); 196 //HAL_UARTEx_ReceiveToIdle_IT(&huart3, (uint8_t*)ibuf, INPUT_BUF_SIZE); 85 197 } 86 198 -
ctrl/firmware/Main/SES/Core/Src/keys_thread.cpp
r64 r65 17 17 HAL_GPIO_WritePin(POWER_10V_EN_GPIO_Port, POWER_10V_EN_Pin, GPIO_PIN_SET); 18 18 19 for (auto i = 0U; i < 5; i++)19 /*for (auto i = 0U; i < 5; i++) 20 20 { 21 21 HAL_GPIO_WritePin(BUZZER_GPIO_Port, BUZZER_Pin, GPIO_PIN_SET); … … 23 23 HAL_GPIO_WritePin(BUZZER_GPIO_Port, BUZZER_Pin, GPIO_PIN_RESET); 24 24 tx_thread_sleep(100U); 25 } 25 }*/ 26 26 27 27 while(1)
Note: See TracChangeset
for help on using the changeset viewer.