Skip to content

Show flags #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified build/ble_ctf.bin
Binary file not shown.
Binary file modified build/bootloader/bootloader.bin
Binary file not shown.
23 changes: 9 additions & 14 deletions main/gatts_table_creat_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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){
Expand Down