aboutsummaryrefslogtreecommitdiffstats
path: root/dfu.c
diff options
context:
space:
mode:
Diffstat (limited to 'dfu.c')
-rw-r--r--dfu.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/dfu.c b/dfu.c
index 89b2b10..29dc4cd 100644
--- a/dfu.c
+++ b/dfu.c
@@ -100,27 +100,30 @@ dfu (const char *bdaddr, const char *type, const char *version, uint8_t * dat,
{
BLE *b;
uint8_t buf[32];
- uint32_t u32;
uint16_t u16;
- uint32_t start_data[3];
- uint8_t dfu_type;
+ uint32_t start_data[3];
+ uint8_t dfu_type;
if (!strcmp (type, "application"))
{
- dfu_type=DFU_UPDATE_APP; /*bit field */
- start_data[0]=0;
- start_data[1]=0;
- start_data[2]=bin_sz;
-
- }else if (!strcmp (type, "bootloader")) {
- dfu_type=DFU_UPDATE_BL; /*bit field */
- start_data[0]=0;
- start_data[1]=bin_sz;
- start_data[2]=0;
- } else {
- fprintf("No idea how to upload %s\n",type);
- exit(EXIT_FAILURE);
+ dfu_type = DFU_UPDATE_APP; /*bit field */
+ start_data[0] = 0;
+ start_data[1] = 0;
+ start_data[2] = bin_sz;
+
+ }
+ else if (!strcmp (type, "bootloader"))
+ {
+ dfu_type = DFU_UPDATE_BL; /*bit field */
+ start_data[0] = 0;
+ start_data[1] = bin_sz;
+ start_data[2] = 0;
+ }
+ else
+ {
+ fprintf (stderr, "No idea how to upload %s\n", type);
+ exit (EXIT_FAILURE);
}
ble_init ();
@@ -138,7 +141,7 @@ dfu (const char *bdaddr, const char *type, const char *version, uint8_t * dat,
break;
buf[0] = OP_CODE_START_DFU;
- buf[1] = dfu_type; /*bit field */
+ buf[1] = dfu_type; /*bit field */
ble_wait_setup (b, OP_CODE_START_DFU);
@@ -148,7 +151,7 @@ dfu (const char *bdaddr, const char *type, const char *version, uint8_t * dat,
/*4 bytes sd size, 4 bytes bl size, 4 bytes app size */
- if (ble_send_data (b, start_data, sizeof(start_data)))
+ if (ble_send_data (b, (uint8_t *) start_data, sizeof (start_data)))
break;
if (ble_wait_run (b) != BLE_DFU_RESP_VAL_SUCCESS)
@@ -222,7 +225,7 @@ dfu (const char *bdaddr, const char *type, const char *version, uint8_t * dat,
break;
buf[0] = OP_CODE_ACTIVATE_N_RESET;
- if (ble_send_cp (b, buf, 1))
+ if (ble_send_cp_noresp (b, buf, 1))
break;
ble_close (b);