diff --git a/build/ble_ctf.bin b/build/ble_ctf.bin index bcefc26..d160cde 100644 Binary files a/build/ble_ctf.bin and b/build/ble_ctf.bin differ diff --git a/build/bootloader/bootloader.bin b/build/bootloader/bootloader.bin index f577f92..3b52b97 100644 Binary files a/build/bootloader/bootloader.bin and b/build/bootloader/bootloader.bin differ diff --git a/main/gatts_table_creat_demo.c b/main/gatts_table_creat_demo.c index a748218..f6643df 100644 --- a/main/gatts_table_creat_demo.c +++ b/main/gatts_table_creat_demo.c @@ -195,7 +195,7 @@ static const uint8_t char_prop_crazy = ESP_GATT_CHAR_PROP_BIT_WRITE | ESP_GATT // start ctf data vars static char writeData[100]; static char flag_state[20] = {'F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F'}; -static uint8_t score_read_value[11] = {'S', 'c', 'o', 'r', 'e', ':', ' ', '0','/','2','0'}; +static uint8_t score_read_value[34] = "Score: 0/20 [FFFFFFFFFFFFFFFFFFFF]"; static const char write_any_flag[] = "Write anything here"; static const char write_ascii_flag[] = "Write the ascii value \"yo\" here"; static const char write_hex_flag[] = "Write the hex value 0x07 here"; @@ -218,7 +218,6 @@ static const uint8_t flag_read_value[16] = {'W','r','i','t','e', ' ', 'F', 'l',' int read_alot_counter = 0; int read_counter = 0; int score = 0; -static char string_score[10] = "0"; int BLINK_GPIO=2; int indicate_handle_state = 0; int send_response=0; @@ -498,13 +497,9 @@ static void set_score() } } - itoa(score, string_score, 10); - for (int i = 0 ; i < strlen(string_score) ; ++i) - { - if (strlen(string_score) == 1){ - score_read_value[7] = ' ';} - score_read_value[6+i] = string_score[i]; - } + snprintf((char * restrict)&score_read_value[6], 3, "%2d", score); + score_read_value[8] = '/'; // overwrite the null terminator + strncpy((char * restrict)&score_read_value[13], flag_state, 20); esp_ble_gatts_set_attr_value(blectf_handle_table[IDX_CHAR_SCORE]+1, sizeof score_read_value, score_read_value); } @@ -835,16 +830,16 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_ //gimmi from the hints docs or this source flag_state[0] = 'T'; } - if (strcmp(writeData,"2b00042f7481c7b056c4") == 0){ - //attributes device name - flag_state[1] = 'T'; - } if (strcmp(writeData,"d205303e099ceff44835") == 0){ //simple read - flag_state[2] = 'T'; + flag_state[1] = 'T'; } if (strcmp(writeData,"5cd56d74049ae40f442e") == 0){ //md5 of device name + flag_state[2] = 'T'; + } + if (strcmp(writeData,"2b00042f7481c7b056c4") == 0){ + //attributes device name flag_state[3] = 'T'; } if (strcmp(writeData,"3873c0270763568cf7aa") == 0){