Skip to content

Commit

Permalink
Move reset into pairing mode to Microbit.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-sam committed Oct 5, 2018
1 parent 8b2e142 commit cf11a85
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion source/MicroBit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void MicroBit::init()
// Create an event handler to trap any handlers being created for I2C services.
// We do this to enable initialisation of those services only when they're used,
// which saves processor time, memeory and battery life.
messageBus.listen(MICROBIT_ID_MESSAGE_BUS_LISTENER, MICROBIT_EVT_ANY, this, &MicroBit::onListenerRegisteredEvent);
messageBus.listen(MICROBIT_ID_ANY, MICROBIT_EVT_ANY, this, &MicroBit::onListenerRegisteredEvent);

status |= MICROBIT_INITIALIZED;

Expand Down Expand Up @@ -232,5 +232,17 @@ void MicroBit::onListenerRegisteredEvent(MicroBitEvent evt)
// The thermometer uses lazy instantiation, we just need to read the data once to start it running.
thermometer.updateSample();
break;
#ifdef MICROBIT_BLE_PAIRING_MODE
case MICROBIT_ID_RESET_INTO_PAIRING:
// Reset the micro:bit into pairing mode
KeyValuePair* RebootMode = storage.get("RebootMode");
if(RebootMode == NULL){
uint8_t RebootModeValue = MICROBIT_MODE_PAIRING;
storage.put("RebootMode", &RebootModeValue, sizeof(RebootMode));
delete RebootMode;
}
microbit_reset();
break;
#endif
}
}

0 comments on commit cf11a85

Please sign in to comment.