/* Function that performs the command of writing string to EEPROM. 
Function gets user input and writes given string to EEPROM starting from address 0. It is accessing EEPROM using maximum allowed number of bytes in sequence.  */
static void do_string_write(void)
/* Function that performs the command of writing string to EEPROM. 
Function gets user input and writes given string to EEPROM starting from address 0. It is accessing EEPROM using maximum allowed number of bytes in sequence.  */
static void do_string_write(void)
{
    char str[(EEPROM_SIM_SIZE) + 1];
    size_t addr = 0;
    NRF_LOG_RAW_INFO("Waiting for string to write:\r\n");
    NRF_LOG_FLUSH();
    safe_gets(str, sizeof(str) - 1);
    while (1)
    {
        ret_code_t err_code;
        size_t to_write = safe_strlen(str + addr, EEPROM_SIM_SEQ_WRITE_MAX);
        if (0 == to_write)
            break;
        err_code = eeprom_write(addr, (uint8_t const *)str + addr, to_write);
        if (NRF_SUCCESS != err_code)
        {
            NRF_LOG_WARNING("Communication error\r\n");
            return;
        }
        addr += to_write;
    }
    NRF_LOG_RAW_INFO("OK\r\n");
}