Mercurial > public > ostc4
comparison Discovery/Src/tComm.c @ 966:90edc237d60f Evo_2_23 tip
Bluetooth commands for new module:
The new Bluetooth module has a slightly different protocol then the previous => Some configuration steps needs to be skip because parameter is not supported and command structures need to be adapted. In the first step this is done for the Bootloader only.
author | Ideenmodellierer |
---|---|
date | Mon, 13 Jan 2025 20:42:24 +0100 |
parents | 1b05a84f6d0f |
children |
comparison
equal
deleted
inserted
replaced
965:58cc980ee848 | 966:90edc237d60f |
---|---|
386 uint8_t answer = HAL_OK; | 386 uint8_t answer = HAL_OK; |
387 uint8_t aRxBuffer[50]; | 387 uint8_t aRxBuffer[50]; |
388 | 388 |
389 // char aTxFactoryDefaults[50] = "AT&F1\r"; | 389 // char aTxFactoryDefaults[50] = "AT&F1\r"; |
390 | 390 |
391 char aTxBufferEscapeSequence[50] = "+++"; | 391 char aTxBufferEscapeSequence[50] = "+++"; /* factory default */ |
392 // limit is 19 chars, with 7 chars shown in BLE advertising mode | 392 // limit is 19 chars, with 7 chars shown in BLE advertising mode |
393 //________________________123456789012345678901 | 393 //________________________123456789012345678901 |
394 | |
395 #ifndef BOOTLOADER_STANDALONE | |
394 char aTxBufferName[50] = "AT+BNAME=OSTC4-12345\r"; | 396 char aTxBufferName[50] = "AT+BNAME=OSTC4-12345\r"; |
397 #else | |
398 char aTxBufferName[50] = "AT+UBTLN=OSTC4-12345\r"; | |
399 #endif | |
395 char answerOkay[6] = "\r\nOK\r\n"; | 400 char answerOkay[6] = "\r\nOK\r\n"; |
396 | 401 |
397 gfx_number_to_string(5,1,&aTxBufferName[15],serial); | 402 gfx_number_to_string(5,1,&aTxBufferName[15],serial); |
398 | 403 |
399 // store active configuration in non-volatile memory | 404 // store active configuration in non-volatile memory |
2185 | 2190 |
2186 switch (BmTmpConfig) | 2191 switch (BmTmpConfig) |
2187 { | 2192 { |
2188 case BM_CONFIG_ECHO: sprintf(TxBuffer,"ATE0\r"); | 2193 case BM_CONFIG_ECHO: sprintf(TxBuffer,"ATE0\r"); |
2189 break; | 2194 break; |
2190 case BM_CONFIG_SILENCE: sprintf(TxBuffer,"ATS30=0\r"); | 2195 case BM_CONFIG_SILENCE: |
2196 #ifndef BOOTLOADER_STANDALONE | |
2197 sprintf(TxBuffer,"ATS30=0\r"); | |
2198 #else | |
2199 BmTmpConfig++; | |
2200 #endif | |
2191 break; | 2201 break; |
2192 case BM_CONFIG_ESCAPE_DELAY: sprintf(TxBuffer,"ATS12=10\r"); | 2202 case BM_CONFIG_ESCAPE_DELAY: |
2203 #ifndef BOOTLOADER_STANDALONE | |
2204 sprintf(TxBuffer,"ATS12=10\r"); | |
2205 #else | |
2206 BmTmpConfig++; | |
2207 #endif | |
2193 break; | 2208 break; |
2194 case BM_CONFIG_SIGNAL_POLL: sprintf(TxBuffer,"AT+BSTPOLL=100\r"); | 2209 case BM_CONFIG_SIGNAL_POLL: |
2210 #ifndef BOOTLOADER_STANDALONE | |
2211 sprintf(TxBuffer,"AT+BSTPOLL=100\r"); | |
2212 #else | |
2213 BmTmpConfig++; | |
2214 #endif | |
2195 break; | 2215 break; |
2196 case BM_CONFIG_BAUD: | 2216 case BM_CONFIG_BAUD: |
2197 #ifdef ENABLE_FAST_COMM | 2217 #ifdef ENABLE_FAST_COMM |
2218 #ifndef BOOTLOADER_STANDALONE | |
2198 sprintf(TxBuffer,"AT%%B22\r"); | 2219 sprintf(TxBuffer,"AT%%B22\r"); |
2220 #else | |
2221 sprintf(TxBuffer,"AT+UMRS=460800,1,8,1,1,1\r"); | |
2222 #endif | |
2199 #else | 2223 #else |
2200 BmTmpConfig++; | 2224 BmTmpConfig = BM_CONFIG_DONE; |
2201 #endif | 2225 #endif |
2202 break; | 2226 break; |
2203 case BM_CONFIG_RETRY: ConfigRetryCnt--; | 2227 case BM_CONFIG_RETRY: ConfigRetryCnt--; |
2204 HAL_Delay(1); | 2228 HAL_Delay(1); |
2205 if(ConfigRetryCnt == 0) | 2229 if(ConfigRetryCnt == 0) |
2265 UartHandle.Init.BaudRate = 460800; | 2289 UartHandle.Init.BaudRate = 460800; |
2266 HAL_UART_Init(&UartHandle); | 2290 HAL_UART_Init(&UartHandle); |
2267 } | 2291 } |
2268 else if((BmTmpConfig == BM_CONFIG_BAUD) && (result == HAL_OK) && (UartHandle.Init.BaudRate == 460800)) /* This shut not happen because default speed is 115200 => update module configuration */ | 2292 else if((BmTmpConfig == BM_CONFIG_BAUD) && (result == HAL_OK) && (UartHandle.Init.BaudRate == 460800)) /* This shut not happen because default speed is 115200 => update module configuration */ |
2269 { | 2293 { |
2294 #ifndef BOOTLOADER_STANDALONE | |
2270 sprintf(TxBuffer,"AT%%B8\r"); /* set default baudrate */ | 2295 sprintf(TxBuffer,"AT%%B8\r"); /* set default baudrate */ |
2296 #else | |
2297 sprintf(TxBuffer,"AT+UMRS=115200,1,8,1,1,1\r"); | |
2298 #endif | |
2271 CmdSize = strlen(TxBuffer); | 2299 CmdSize = strlen(TxBuffer); |
2272 HAL_UART_Transmit(&UartHandle, (uint8_t*)TxBuffer,CmdSize, 2000); | 2300 HAL_UART_Transmit(&UartHandle, (uint8_t*)TxBuffer,CmdSize, 2000); |
2273 HAL_UART_DeInit(&UartHandle); | 2301 HAL_UART_DeInit(&UartHandle); |
2274 HAL_Delay(10); | 2302 HAL_Delay(10); |
2275 UartHandle.Init.BaudRate = 115200; | 2303 UartHandle.Init.BaudRate = 115200; |
2279 HAL_UART_Transmit(&UartHandle, (uint8_t*)TxBuffer,CmdSize, 2000); | 2307 HAL_UART_Transmit(&UartHandle, (uint8_t*)TxBuffer,CmdSize, 2000); |
2280 } | 2308 } |
2281 if(result == HAL_OK) | 2309 if(result == HAL_OK) |
2282 { | 2310 { |
2283 BmTmpConfig++; | 2311 BmTmpConfig++; |
2312 if(BmTmpConfig == BM_CONFIG_RETRY) | |
2313 { | |
2314 BmTmpConfig = BM_CONFIG_DONE; | |
2315 } | |
2284 } | 2316 } |
2285 if(BmTmpConfig == BM_CONFIG_ECHO) | 2317 if(BmTmpConfig == BM_CONFIG_ECHO) |
2286 { | 2318 { |
2287 BmTmpConfig = BM_CONFIG_DONE; | 2319 BmTmpConfig = BM_CONFIG_DONE; |
2288 ConfigRetryCnt = 0; | 2320 ConfigRetryCnt = 0; |