Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed EthernetInterface mbed-rtos
Fork of FOTA_K64F by
Revision 11:0f4df7636ef7, committed 2017-03-14
- Comitter:
- wmmihaa
- Date:
- Tue Mar 14 14:06:21 2017 +0000
- Parent:
- 10:fb5121bcc468
- Commit message:
- microServiceBus.node
Changed in this revision
--- a/Bootloader/bootloader.h Sun Apr 24 12:46:37 2016 +0000
+++ b/Bootloader/bootloader.h Tue Mar 14 14:06:21 2017 +0000
@@ -1,7 +1,7 @@
#include "mbed.h"
#include "EthernetInterface.h"
#include "rtos.h"
-
+#include <string>
#define START_ADDRESS 0x80000
#define NUM_SECTORS 120
#define SECTOR_SIZE 4096
@@ -15,7 +15,6 @@
int *(*erase_sector_boot)(int) = (int *(*)(int))0x79465;
void *(*bootloader)(int) = (void *(*)(int))0x79121;
-
/*************************************************************/
// Retrieving binary from server
/*************************************************************/
@@ -28,18 +27,44 @@
printf("Connecting ethernet\r\n");
EthernetInterface eth;
- eth.init(); //Use DHCP
- eth.connect();
+ //eth.init(); //Use DHCP
+ if(eth.connect() != 0){
+ printf("Unable to connect");
+ }
+
printf("IP Address is %s\r\n", eth.getIPAddress());
TCPSocketConnection sock;
//----------------YOUR SERVER DETAILS-----------------------//
- sock.connect("192.168.0.18", 80);
- char http_cmd[] = "GET /loader_test.bin HTTP/1.1\r\nHost: 192.168.0.18 80\r\n\r\n";
+ //sock.connect("192.168.1.64", 80);
+ sock.connect("microservicebus-northeurope-stage.azurewebsites.net",80);
+/*
+ std::string str;
+ str = "GET /api/mbed?id=";
+ str.append(eth.getMACAddress());
+
+ size_t start_pos = 0;
+ std::string from(":");
+ std::string to("");
+
+ while((start_pos = str.find(from, start_pos)) != std::string::npos) {
+ str.replace(start_pos, from.length(), to);
+ start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
+ }
+
+ str.append( " HTTP/1.1\r\nHost: 192.168.1.64\r\n\r\n" );
+
+ char *http_cmd = &str[0u];
+*/
+ char http_cmd[] = "GET /api/mbed?id=36:41:55:13:08:16 HTTP/1.1\r\nHost: 192.168.1.64\r\n\r\n";
//----------------YOUR SERVER DETAILS-----------------------//
+ printf("Registing at ");
+ printf(http_cmd);
+ printf("\r\n");
+
sock.send_all(http_cmd, sizeof(http_cmd)-1);
char buffer[BUFFER_SIZE];
@@ -67,6 +92,7 @@
}
//Determine size of the file
char *temp = strstr(buffer, "Content-Length: ") + 16; //'16' is size of "Content-Length: "
+ printf(buffer);
sscanf(temp, "%d", &binsize);
printf("Size of the binary = %d bytes\r\n", binsize);
@@ -95,7 +121,8 @@
while (bufcount < sizeof(buffer)) {
//Try to receive remainder of the buffer
received = sock.receive(&buffer[bufcount], sizeof(buffer)-bufcount);
- printf("Received %d\r\n", received);
+ //printf("Received %d\r\n", received);
+ printf(".");
if (received <= 0) {
printf("Error, should not happen\r\n");
while(1);
@@ -127,5 +154,4 @@
eth.disconnect();
bootloader(count);
-
-}
\ No newline at end of file
+}
--- a/FreescaleIAP/bootloader.cpp Sun Apr 24 12:46:37 2016 +0000
+++ b/FreescaleIAP/bootloader.cpp Tue Mar 14 14:06:21 2017 +0000
@@ -25,12 +25,14 @@
erase_sector(SECTOR_SIZE * i);
}
- write("Done erasing, reading file!\r\n");
+ write("\r\nDone erasing, reading file!\r\n");
char buffer[BUFFER_SIZE];
char *source = (char*)0x80000;
+ write("Flashing device\r\n");
+
//Data receive loop
for(int count = 0; count<size; count+=BUFFER_SIZE) {
for (int i = 0; i<BUFFER_SIZE; i++)
@@ -40,12 +42,13 @@
write("Error!\r\n");
break;
}
-
+ //write(".");
+
//Reset buffercount for next buffer
- write("%");
+
}
- write("Done programming!\r\n");
+ write("\r\nDone programming!\r\n");
NVIC_SystemReset();
//Shouldn't arrive here
--- a/main.cpp Sun Apr 24 12:46:37 2016 +0000
+++ b/main.cpp Tue Mar 14 14:06:21 2017 +0000
@@ -1,4 +1,5 @@
#include "mbed.h"
+#include "EthernetInterface.h"
#include "bootloader.h"
DigitalIn sw(PTA4);
@@ -6,8 +7,16 @@
int main()
{
- printf("Hello :)\r\n");
-
+ EthernetInterface eth;
+ eth.init(); //Use DHCP
+ eth.connect();
+ printf("Welcome to microServiceBus Start up\r\n");
+ while (1) {
+ printf("Entering bootloader\r\n");
+ write_flash();
+ }
+
+ /*
//Blink LED, and when SW3 is pressed go to bootloader
//I don't know atm if the bootloader would work from interrupt context
while (1) {
@@ -17,7 +26,7 @@
printf("Entering bootloader\r\n");
write_flash();
}
- }
+ }*/
}
