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.
Fork of my_eeprom_funcs by
Diff: my_eeprom_funcs.cpp
- Revision:
- 14:17a44517b13d
- Parent:
- 13:7ffbbfe999c5
- Child:
- 15:126b1eb74709
diff -r 7ffbbfe999c5 -r 17a44517b13d my_eeprom_funcs.cpp
--- a/my_eeprom_funcs.cpp Thu Jun 16 19:20:49 2016 +0000
+++ b/my_eeprom_funcs.cpp Thu Jun 16 21:43:32 2016 +0000
@@ -130,7 +130,7 @@
sprintf(str_ip_addr, "%d.%d.%d.%d", u8ip_addr[0], u8ip_addr[1], u8ip_addr[2], u8ip_addr[3]);
sprintf(str_ip_subnet, "%d.%d.%d.%d", (uint8_t)u16ip_subnet[0], (uint8_t)u16ip_subnet[1], (uint8_t)u16ip_subnet[2], (uint8_t)u16ip_subnet[3]);
sprintf(str_ip_gateway, "%d.%d.%d.%d", (uint8_t)u16ip_gateway[0], (uint8_t)u16ip_gateway[1], (uint8_t)u16ip_gateway[2], (uint8_t)u16ip_gateway[3]);
- sprintf(str_ip_gateway, "%x:%x:%x:%x:%x:%x", (uint8_t)u8mac[0], (uint8_t)u8mac[1], (uint8_t)u8mac[2], (uint8_t)u8mac[3], (uint8_t)u8mac[4], (uint8_t)u8mac[5]);
+ sprintf(str_mac_addr, "%02X:%02X:%02X:%02X:%02X:%02X", (uint8_t)u8mac[0], (uint8_t)u8mac[1], (uint8_t)u8mac[2], (uint8_t)u8mac[3], (uint8_t)u8mac[4], (uint8_t)u8mac[5]);
}
// if ip is not configured, use default addresses
else {
@@ -233,4 +233,45 @@
else {
DBG("No auto update using TCP client");
}
-}
\ No newline at end of file
+}
+
+/*!
+ * Function to save device IP address only
+ */
+void save_ip_addr(char *buf) {
+ DBG("Saving device IP address...");
+
+ // Unlock the Flash Program Erase controller */
+ FLASH_Unlock();
+ // EEPROM Init
+ EE_Init();
+
+ // IP address
+ EE_WriteVariable(VirtAddVarTab[IP_ADDRESS_POS+0], *buf++);
+ EE_WriteVariable(VirtAddVarTab[IP_ADDRESS_POS+1], *buf++);
+ EE_WriteVariable(VirtAddVarTab[IP_ADDRESS_POS+2], *buf++);
+ EE_WriteVariable(VirtAddVarTab[IP_ADDRESS_POS+3], *buf++);
+
+ FLASH_Lock();
+
+ DBG("Successful");
+}
+
+/*!
+ * Function to disable the flag indicates a static IP address has been assigned
+ */
+void reset_conf() {
+ DBG("Disable device configured flag...");
+
+ // Unlock the Flash Program Erase controller */
+ FLASH_Unlock();
+ // EEPROM Init
+ EE_Init();
+
+ // erase first_run flag
+ EE_WriteVariable(VirtAddVarTab[CONFIGURED_IP_FLAG_POS], DEFAULT_DISABLE_FLAG_VALUE);
+
+ FLASH_Lock();
+
+ DBG("Successful");
+}
