VesiScan BASIC origin: Piezo + IMU firmware initial code
- nRF52840 + SoftDevice S140 BLE firmware - Piezo ultrasound TX driver (2MHz, 8ch MUX) - ICM42670P IMU 6-axis driver - Echo AFE chain (ADA2200 + ADC121S051) - BLE NUS command parser (mpa/mpc/mdc/mec/maa/msp) - FDS flash config storage - pc_firm parser and ADC driver included Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ v1.17 p1,p2 parssurer
|
||||
|
||||
#include <cmd_parse.h>
|
||||
#include "debug_print.h"
|
||||
#include "fstorage.h"
|
||||
|
||||
#define DEVICE_VERSION "FW25LIT2B102"
|
||||
#define DEVICE_NAME "MEDIDEV_2004"
|
||||
@@ -1452,7 +1453,7 @@ else if((scmd.tag[1] == 'r') && (scmd.tag[2] == 'k')){ // Set the number of
|
||||
|
||||
}
|
||||
// ssl
|
||||
else if((scmd.tag[1] == 's') && (scmd.tag[2] == 'l')){ // Set the delay for PD stabilization. 0µs ~ FFFF(65535)µs
|
||||
else if((scmd.tag[1] == 's') && (scmd.tag[2] == 'l')){ // Set the delay for PD stabilization. 0<EFBFBD>s ~ FFFF(65535)<EFBFBD>s
|
||||
|
||||
|
||||
// ret_code_t err_code;
|
||||
@@ -1485,7 +1486,7 @@ else if((scmd.tag[1] == 's') && (scmd.tag[2] == 'l')){ // Set the delay for
|
||||
}
|
||||
}
|
||||
// srl
|
||||
else if((scmd.tag[1] == 'r') && (scmd.tag[2] == 'l')){ // Set the delay for PD stabilization. 0µs ~ FFFF(65535)µs
|
||||
else if((scmd.tag[1] == 'r') && (scmd.tag[2] == 'l')){ // Set the delay for PD stabilization. 0<EFBFBD>s ~ FFFF(65535)<EFBFBD>s
|
||||
|
||||
|
||||
|
||||
@@ -1655,69 +1656,30 @@ else if((scmd.tag[1] == 's') && (scmd.tag[2] == 'v')){ // Auto Gain Control
|
||||
|
||||
|
||||
}
|
||||
// ssz
|
||||
else if((scmd.tag[1] == 's') && (scmd.tag[2] == 'z')){ //Write, Serial Number
|
||||
// ssz - Write Serial Number (FDS only)
|
||||
else if((scmd.tag[1] == 's') && (scmd.tag[2] == 'z')){
|
||||
if(length_error(scmd.tag,18,length)==false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint8_t tx_data[EEPROM_PAGE_SIZE];
|
||||
uint8_t rx_data[EEPROM_PAGE_SIZE];
|
||||
uint8_t raw_data[EEPROM_PAGE_SIZE];
|
||||
if(cmd_t == CMD_UART) {
|
||||
DBG_PRINTF("Tz0\r\n\r\n");
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
|
||||
//eeprom_write_encrypted(0x0000, secret_data, strlen((char *)secret_data));
|
||||
|
||||
//eeprom_read_decrypted(0x0000, decrypted, strlen((char *)secret_data));
|
||||
//DBG_PRINTF("Decrypted: %s\n", decrypted);
|
||||
|
||||
memcpy(SERIAL_NO, scmd.value_ascii, 12);
|
||||
//eeprom_write_bytes(uint16_t mem_address, const uint8_t *data, size_t length)
|
||||
for (uint8_t i=0 ; i<12 ;i++)
|
||||
{
|
||||
tx_data[i] = (uint8_t)(scmd.value_ascii[i]);
|
||||
}
|
||||
|
||||
// if (eeprom_write_bytes(0x0030 , tx_data ,12) !=NRF_SUCCESS)
|
||||
// {
|
||||
// DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");
|
||||
// }
|
||||
if(eeprom_write_encrypted(0x0030, tx_data, 12)!= NRF_SUCCESS)
|
||||
{
|
||||
DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");;
|
||||
}
|
||||
|
||||
if(eeprom_read_bytes(0x0030, raw_data, 12)!= NRF_SUCCESS)
|
||||
{
|
||||
DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");;
|
||||
}
|
||||
|
||||
nrf_delay_ms(10);
|
||||
DBG_PRINTF("encrypted: %s\n", raw_data);
|
||||
if(eeprom_read_decrypted(0x0030, rx_data, 12)!= NRF_SUCCESS)
|
||||
{
|
||||
DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");;
|
||||
}
|
||||
DBG_PRINTF("Decrypted: %s\n", rx_data);
|
||||
|
||||
memcpy(m_config.serial_no, scmd.value_ascii, 12);
|
||||
config_save();
|
||||
DBG_PRINTF("[ssz] S/N=%s saved to FDS\r\n", m_config.serial_no);
|
||||
ascii_format_data(ble_bin_buffer, "rsz:", scmd.value_ascii,12);
|
||||
binary_tx_handler(ble_bin_buffer,8);
|
||||
binary_tx_handler(ble_bin_buffer,8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
else{
|
||||
DBG_PRINTF("ERR!!! Serial_number 12\r\n\r\n");
|
||||
if(cmd_t == CMD_UART) {
|
||||
DBG_PRINTF("Tz0FF\r\n\r\n");
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
param_error(scmd.tag );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// spz
|
||||
else if((scmd.tag[1] == 'p') && (scmd.tag[2] == 'z')){ //Write, passkey
|
||||
@@ -1808,33 +1770,14 @@ else if((scmd.tag[1] == 'q') && (scmd.tag[2] == 'z')){ // Read, Seri
|
||||
}
|
||||
|
||||
}
|
||||
// srz
|
||||
else if((scmd.tag[1] == 'r') && (scmd.tag[2] == 'z')){ // Read, Serial Number
|
||||
|
||||
uint8_t rx_data[EEPROM_PAGE_SIZE];
|
||||
|
||||
// srz - Read Serial Number (FDS only)
|
||||
else if((scmd.tag[1] == 'r') && (scmd.tag[2] == 'z')){
|
||||
if(cmd_t == CMD_UART) {
|
||||
DBG_PRINTF("Tz1,%s\r\n\r\n", SERIAL_NO);
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
|
||||
|
||||
if(eeprom_read_decrypted(0x0030, rx_data, 12)!= NRF_SUCCESS)
|
||||
{
|
||||
DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");;
|
||||
}
|
||||
DBG_PRINTF("Decrypted: %s\n", rx_data);
|
||||
// if (eeprom_read_bytes(0x0030 , rx_data ,12) !=NRF_SUCCESS)
|
||||
// {
|
||||
// DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");
|
||||
// }
|
||||
// sprintf(ble_tx_buffer, "Tz1,%s\r\n", m_config.serial_number);
|
||||
// data_tx_handler(ble_tx_buffer);
|
||||
for (uint8_t i=0 ; i<12 ;i++)
|
||||
{
|
||||
(SERIAL_NO[i]) = (char)rx_data[i] ;
|
||||
}
|
||||
ascii_format_data(ble_bin_buffer, "rrz:", SERIAL_NO,12);
|
||||
binary_tx_handler(ble_bin_buffer,8);
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
memcpy(SERIAL_NO, m_config.serial_no, 12);
|
||||
ascii_format_data(ble_bin_buffer, "rrz:", SERIAL_NO, 12);
|
||||
binary_tx_handler(ble_bin_buffer, 8);
|
||||
}
|
||||
|
||||
#if 0 // ===== EEPROM start block =====
|
||||
@@ -2024,99 +1967,43 @@ else if((scmd.tag[1] == 'g') && (scmd.tag[2] == 'z')){ // Read, DCP
|
||||
|
||||
}
|
||||
}
|
||||
// siz
|
||||
else if((scmd.tag[1] == 'i') && (scmd.tag[2] == 'z')){ // Read, HW
|
||||
|
||||
hw_i2c_init_once();
|
||||
uint8_t rx_data[EEPROM_PAGE_SIZE];
|
||||
|
||||
// siz - Read HW Number (FDS only)
|
||||
else if((scmd.tag[1] == 'i') && (scmd.tag[2] == 'z')){
|
||||
if(cmd_t == CMD_UART) {
|
||||
DBG_PRINTF("Tz1,%s\r\n\r\n", HW_NO);
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
|
||||
|
||||
if(eeprom_read_decrypted(0x0010, rx_data, 12)!= NRF_SUCCESS)
|
||||
{
|
||||
DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");;
|
||||
}
|
||||
DBG_PRINTF("Decrypted: %s\n", rx_data);
|
||||
// if (eeprom_read_bytes(0x0030 , rx_data ,12) !=NRF_SUCCESS)
|
||||
// {
|
||||
// DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");
|
||||
// }
|
||||
// sprintf(ble_tx_buffer, "Tz1,%s\r\n", m_config.serial_number);
|
||||
// data_tx_handler(ble_tx_buffer);
|
||||
for (uint8_t i=0 ; i<12 ;i++)
|
||||
{
|
||||
(HW_NO[i]) = (char)rx_data[i] ;
|
||||
}
|
||||
ascii_format_data(ble_bin_buffer, "riz:", HW_NO,12);
|
||||
binary_tx_handler(ble_bin_buffer,8);
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
memcpy(HW_NO, m_config.hw_no, 12);
|
||||
ascii_format_data(ble_bin_buffer, "riz:", HW_NO, 12);
|
||||
binary_tx_handler(ble_bin_buffer, 8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
// shz
|
||||
else if((scmd.tag[1] == 'h') && (scmd.tag[2] == 'z')){ //Write, HW
|
||||
// shz - Write HW Number (FDS only)
|
||||
else if((scmd.tag[1] == 'h') && (scmd.tag[2] == 'z')){
|
||||
if(length_error(scmd.tag,18,length)==false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hw_i2c_init_once();
|
||||
uint8_t tx_data[EEPROM_PAGE_SIZE];
|
||||
uint8_t rx_data[EEPROM_PAGE_SIZE];
|
||||
uint8_t raw_data[EEPROM_PAGE_SIZE];
|
||||
if(cmd_t == CMD_UART) {
|
||||
DBG_PRINTF("Tz0\r\n\r\n");
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
memcpy(HW_NO, scmd.value_ascii, 12);
|
||||
//eeprom_write_bytes(uint16_t mem_address, const uint8_t *data, size_t length)
|
||||
for (uint8_t i=0 ; i<12 ;i++)
|
||||
{
|
||||
tx_data[i] = (uint8_t)(scmd.value_ascii[i]);
|
||||
}
|
||||
|
||||
|
||||
if(eeprom_write_encrypted(0x0010, tx_data, 12)!= NRF_SUCCESS)
|
||||
{
|
||||
DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");;
|
||||
}
|
||||
|
||||
if(eeprom_read_bytes(0x0010, raw_data, 12)!= NRF_SUCCESS)
|
||||
{
|
||||
DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");;
|
||||
}
|
||||
|
||||
nrf_delay_ms(10);
|
||||
DBG_PRINTF("encrypted: %s\n", raw_data);
|
||||
if(eeprom_read_decrypted(0x0010, rx_data, 12)!= NRF_SUCCESS)
|
||||
{
|
||||
DBG_PRINTF("ERR!!! EEP_Serial_number 12\r\n\r\n");;
|
||||
}
|
||||
DBG_PRINTF("Decrypted: %s\n", rx_data);
|
||||
|
||||
memcpy(m_config.hw_no, scmd.value_ascii, 12);
|
||||
config_save();
|
||||
DBG_PRINTF("[shz] HW=%s saved to FDS\r\n", m_config.hw_no);
|
||||
ascii_format_data(ble_bin_buffer, "rhz:", scmd.value_ascii,12);
|
||||
binary_tx_handler(ble_bin_buffer,8);
|
||||
binary_tx_handler(ble_bin_buffer,8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
else{
|
||||
DBG_PRINTF("ERR!!! passkey 6\r\n\r\n");
|
||||
DBG_PRINTF("ERR!!! HW_NO 12\r\n\r\n");
|
||||
if(cmd_t == CMD_UART) {
|
||||
DBG_PRINTF("Tpz0FF\r\n\r\n");
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
} else if(cmd_t == CMD_BLE) {
|
||||
param_error(scmd.tag );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// sxz
|
||||
else if((scmd.tag[1] == 'x') && (scmd.tag[2] == 'z')){ // Set the delay for PD stabilization. 0µs ~ FFFF(65535)µs
|
||||
else if((scmd.tag[1] == 'x') && (scmd.tag[2] == 'z')){ // Set the delay for PD stabilization. 0<EFBFBD>s ~ FFFF(65535)<EFBFBD>s
|
||||
|
||||
m_life_cycle = ((uint16_t)scmd.value0 << 16) | ((uint16_t)scmd.value1 & 0xFFFF);
|
||||
result_data[0] = scmd.value0;
|
||||
|
||||
Reference in New Issue
Block a user