Microbug / MicroBitDAL_SB2_TEST

Fork of MicroBitDALImageRewrite by Joe Finney

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main_FOTA_test.cpp Source File

main_FOTA_test.cpp

00001 #include "inc/MicroBitTest.h"
00002 
00003 #ifdef MAIN_FOTA_TEST
00004 
00005 #include "MicroBit.h"
00006 
00007 extern "C" void bootloader_start(void);
00008 
00009 MicroBit uBit;
00010 
00011 
00012 
00013 Serial pc(USBTX, USBRX);
00014 char version[] = "1.1";
00015 
00016 void dfuCallbackFn()
00017 {
00018     pc.printf("=== DFU Callback ===\n");   
00019 }
00020 
00021 int
00022 ble_pair()
00023 {
00024     pc.printf("=== Entering FOTA Pairing Mode ===\n");   
00025     while(1)
00026     {
00027         //uBit.ble->waitForEvent();
00028         wait(1.0);
00029     }
00030 }
00031 
00032 int main()
00033 { 
00034     // Set up debug console.
00035     pc.baud (115200);
00036 
00037     wait(10.0);
00038     
00039     pc.printf("=== Starting FOTA Test ===\n");
00040     for (int i=5; i>0; i--)
00041     {
00042         pc.printf("%d...\n",i);
00043         wait(1.0);
00044     }
00045 
00046     
00047     //if(uBit.leftButton.isPressed())
00048     //{
00049     //    ble_pair(); 
00050     //}    
00051     
00052     pc.printf("=== Starting Bootloader ===\n");    
00053     bootloader_start();
00054     
00055     pc.printf("=== Starting Application ===\n");    
00056     while(1)
00057     {
00058         //pc.printf("Running: %s\n", version);
00059         uBit.ble->waitForEvent();
00060     }
00061 }
00062 
00063 #endif