From 8493626b86142a693097969cb15f1a2b3700bb20 Mon Sep 17 00:00:00 2001
From: Matthias Ringwald <matthias@ringwald.ch>
Date: Sat, 31 Mar 2018 22:06:04 +0200
Subject: [PATCH] pts/sm_test: suppprt numeric comparison failed. SCJW tests
 complete

---
 test/pts/sm_test.c   | 4 +++-
 test/pts/sm_test.csv | 6 ++++--
 test/pts/sm_test.py  | 8 ++++++++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/test/pts/sm_test.c b/test/pts/sm_test.c
index 1052d9918..fc8eb9bc1 100644
--- a/test/pts/sm_test.c
+++ b/test/pts/sm_test.c
@@ -271,7 +271,9 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
                     break;
                 case SM_EVENT_JUST_WORKS_REQUEST:
                     printf("JUST_WORKS_REQUEST\n");
-                    // sm_just_works_confirm(little_endian_read_16(packet, 2));
+                    break;
+                case SM_EVENT_NUMERIC_COMPARISON_REQUEST:
+                    printf("NUMERIC_COMPARISON_REQUEST\n");
                     break;
                 case SM_EVENT_PASSKEY_INPUT_NUMBER:
                     // display number
diff --git a/test/pts/sm_test.csv b/test/pts/sm_test.csv
index e96537397..61e2f799e 100644
--- a/test/pts/sm_test.csv
+++ b/test/pts/sm_test.csv
@@ -57,8 +57,10 @@ SM/MAS/SCJW/BI-01-C/02,0,0,8,8,0,0,8
 SM/MAS/SCJW/BI-01-C/03,0,0,8,8,0,0,5
 SM/MAS/SCJW/BI-01-C/04,0,0,8,8,0,0,9
 
-# TODO: tester responds with pairing failure during phase 2
-SM/MAS/SCJW/BI-01-C/05,0,0,8,8,0,0,12
+SM/MAS/SCJW/BI-01-C/05,1,1,12,12,0,0,12
+
+# IO Cababilities + MITM -> Numeric Comparison -> Numeric Comparison Failed
+SM/MAS/SCJW/BI-01-C/05,1,1,12,12,0,0,12
 
 # tester responds with pairing failure during phase 2
 SM/SLA/SCJW/BI-02-C,0,3,8,8,0,0,4
diff --git a/test/pts/sm_test.py b/test/pts/sm_test.py
index cb8c9911e..1e4e400c3 100755
--- a/test/pts/sm_test.py
+++ b/test/pts/sm_test.py
@@ -196,6 +196,14 @@ def run(test_descriptor, nodes):
                     else:
                         print('Accept bonding')
                         node.write('a')
+                elif line.startswith('NUMERIC_COMPARISON_REQUEST'):
+                    print('%s numeric comparison requested' % node.get_name())
+                    if node.get_name() == 'tester' and  test_descriptor['tester_failure'] == '12':
+                        print('Decline bonding')
+                        node.write('d')
+                    else:
+                        print('Accept bonding')
+                        node.write('a')
                 elif line.startswith('PASSKEY_DISPLAY_NUMBER'):
                     passkey = line.split(': ')[1]
                     print('%s passkey display %s' % (node.get_name(), passkey))