static int parse_hex(uint8_t * buffer, const char * hex_string){ int len = 0; while (*hex_string){ if (*hex_string == ' '){ hex_string++; continue; } int high_nibble = nibble_for_char(*hex_string++); int low_nibble = nibble_for_char(*hex_string++); *buffer++ = (high_nibble << 4) | low_nibble; len++; } return len; }
static void stdin_process(char c){ // passkey input if (ui_digits_for_passkey && c >= '0' && c <= '9'){ printf("%c", c); fflush(stdout); ui_passkey = ui_passkey * 10 + c - '0'; ui_digits_for_passkey--; sm_keypress_notification(connection_handle, SM_KEYPRESS_PASSKEY_DIGIT_ENTERED); if (ui_digits_for_passkey == 0){ printf("\n"); fflush(stdout); sm_keypress_notification(connection_handle, SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED); sm_passkey_input(connection_handle, ui_passkey); } return; } if (ui_oob_confirm){ if (c == ' ') return; ui_oob_nibble = (ui_oob_nibble << 4) | nibble_for_char(c); if ((ui_oob_pos & 1) == 1){ sm_oob_peer_confirm[ui_oob_pos >> 1] = ui_oob_nibble; ui_oob_nibble = 0; } ui_oob_pos++; if (ui_oob_pos == 32){ ui_oob_confirm = 0; printf("PEER_OOB_CONFIRM: "); printf_hexdump(sm_oob_peer_confirm, 16); fflush(stdout); } return; }