Mercurial > public > ostc4
comparison Discovery/Src/tComm.c @ 872:5e027b0f7475 Evo_2_23
Added first time initialization for new bluetooth module:
The serial numbers are not defined when the electonic is connected to power for the first time. This event is used to run a initialization sequence which sets the defaults for the bluetooth modul. At the end the module may be accessed using a default name.
| author | Ideenmodellierer |
|---|---|
| date | Wed, 14 Aug 2024 14:41:04 +0200 |
| parents | bc6c90e20d9e |
| children | e373e90a48db |
comparison
equal
deleted
inserted
replaced
| 870:bc6c90e20d9e | 872:5e027b0f7475 |
|---|---|
| 109 | 109 |
| 110 #define UART_OPERATION_TIMEOUT (500u) /* Timeout for common read / write operations (ms) */ | 110 #define UART_OPERATION_TIMEOUT (500u) /* Timeout for common read / write operations (ms) */ |
| 111 #define UART_TIMEOUT_SECONDS (120u) /* Timeout for keeping connection open and waiting for data */ | 111 #define UART_TIMEOUT_SECONDS (120u) /* Timeout for keeping connection open and waiting for data */ |
| 112 #define UART_TIMEOUT_LARGE_BLOCK (6000u) /* Timeout (ms) for reception of an 16K data block (typical RX time ~4,5seconds) */ | 112 #define UART_TIMEOUT_LARGE_BLOCK (6000u) /* Timeout (ms) for reception of an 16K data block (typical RX time ~4,5seconds) */ |
| 113 | 113 |
| 114 #define UART_CMD_BUF_SIZE (20u) /* size of buffer for command exchange */ | 114 #define UART_CMD_BUF_SIZE (30u) /* size of buffer for command exchange */ |
| 115 | 115 |
| 116 const uint8_t id_Region1_firmware = 0xFF; | 116 const uint8_t id_Region1_firmware = 0xFF; |
| 117 const uint8_t id_RTE = 0xFE; | 117 const uint8_t id_RTE = 0xFE; |
| 118 const uint8_t id_FONT = 0x10; | 118 const uint8_t id_FONT = 0x10; |
| 119 const uint8_t id_FONT_OLD = 0x00; | 119 const uint8_t id_FONT_OLD = 0x00; |
| 366 if(force || (hardwareDataGetPointer()->production_bluetooth_name_set == 0xFF)) | 366 if(force || (hardwareDataGetPointer()->production_bluetooth_name_set == 0xFF)) |
| 367 answer = HW_Set_Bluetooth_Name(hardwareDataGetPointer()->primarySerial, 0); | 367 answer = HW_Set_Bluetooth_Name(hardwareDataGetPointer()->primarySerial, 0); |
| 368 #ifdef BOOTLOADER_STANDALONE | 368 #ifdef BOOTLOADER_STANDALONE |
| 369 if(answer == HAL_OK) | 369 if(answer == HAL_OK) |
| 370 hardware_programmPrimaryBluetoothNameSet(); | 370 hardware_programmPrimaryBluetoothNameSet(); |
| 371 #endif | |
| 372 } | |
| 373 else /* no serial set at all => do default configuration of the module */ | |
| 374 { | |
| 375 #define NINAB22103B00 | |
| 376 #ifdef NINAB22103B00 | |
| 377 answer = 0xFF; | |
| 371 #endif | 378 #endif |
| 372 } | 379 } |
| 373 return answer; | 380 return answer; |
| 374 } | 381 } |
| 375 | 382 |
| 2139 }while(answer == HAL_OK); | 2146 }while(answer == HAL_OK); |
| 2140 } | 2147 } |
| 2141 } | 2148 } |
| 2142 } | 2149 } |
| 2143 | 2150 |
| 2151 void tComm_StartBlueModBaseInit() | |
| 2152 { | |
| 2153 BmTmpConfig = BM_INIT_TRIGGER_ON; | |
| 2154 } | |
| 2144 void tComm_StartBlueModConfig() | 2155 void tComm_StartBlueModConfig() |
| 2145 { | 2156 { |
| 2146 uint8_t answer = HAL_OK; | 2157 uint8_t answer = HAL_OK; |
| 2147 uint8_t RxBuffer[UART_CMD_BUF_SIZE]; | 2158 uint8_t RxBuffer[UART_CMD_BUF_SIZE]; |
| 2148 uint8_t index = 0; | 2159 uint8_t index = 0; |
| 2190 case BM_CONFIG_DONE: | 2201 case BM_CONFIG_DONE: |
| 2191 case BM_CONFIG_OFF: | 2202 case BM_CONFIG_OFF: |
| 2192 ConfigRetryCnt = 0; | 2203 ConfigRetryCnt = 0; |
| 2193 RestartModule = 1; | 2204 RestartModule = 1; |
| 2194 break; | 2205 break; |
| 2206 #ifdef BOOTLOADER_STANDALONE | |
| 2207 case BM_INIT_TRIGGER_ON: HAL_Delay(2000); | |
| 2208 HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); | |
| 2209 BmTmpConfig++; | |
| 2210 break; | |
| 2211 case BM_INIT_TRIGGER_OFF: HAL_Delay(1); | |
| 2212 HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_SET); | |
| 2213 HAL_Delay(2000); | |
| 2214 BmTmpConfig++; | |
| 2215 break; | |
| 2216 case BM_INIT_FACTORY: sprintf(TxBuffer,"AT+UFACTORY\r"); /*Set to factory defined configuration */ | |
| 2217 break; | |
| 2218 case BM_INIT_MODE: sprintf(TxBuffer,"AT+UMSM=1\r"); /* start in Data mode */ | |
| 2219 break; | |
| 2220 case BM_INIT_BLE: sprintf(TxBuffer,"AT+UBTLE=2\r"); /* Bluetooth low energy Peripheral */ | |
| 2221 break; | |
| 2222 case BM_INIT_NAME: sprintf(TxBuffer,"AT+UBTLN=OSTC4-12345\r"); /* Bluetooth name */ | |
| 2223 break; | |
| 2224 case BM_INIT_SSP_IDO_OFF: sprintf(TxBuffer,"AT+UDSC=0,0\r"); /* Disable SPP Server on ID0 */ | |
| 2225 break; | |
| 2226 case BM_INIT_SSP_IDO_ON: sprintf(TxBuffer,"AT+UDSC=0,3\r"); /* SPP Server on ID0 */ | |
| 2227 break; | |
| 2228 case BM_INIT_SSP_ID1_OFF: sprintf(TxBuffer,"AT+UDSC=1,0\r"); /* Disable SPS Server on ID1 */ | |
| 2229 break; | |
| 2230 case BM_INIT_SSP_ID1_ON: sprintf(TxBuffer,"AT+UDSC=1,6\r"); /* SPS Server on ID1 */ | |
| 2231 break; | |
| 2232 case BM_INIT_STORE: sprintf(TxBuffer,"AT&W\r"); /* write settings into eeprom */ | |
| 2233 break; | |
| 2234 case BM_INIT_RESTART: sprintf(TxBuffer,"AT+CPWROFF\r"); /* reboot module */ | |
| 2235 break; | |
| 2236 case BM_INIT_DONE: BmTmpConfig = BM_CONFIG_ECHO; | |
| 2237 break; | |
| 2238 #endif | |
| 2195 default: | 2239 default: |
| 2196 break; | 2240 break; |
| 2197 } | 2241 } |
| 2198 if(TxBuffer[0] != 0) /* forward command to module */ | 2242 if(TxBuffer[0] != 0) /* forward command to module */ |
| 2199 { | 2243 { |
