Skip to content

Commit c756236

Browse files
authored
Fixes to coco wifi functions, and to fujinet-fuji.h (FujiNetWIFI#33)
* Fixes to coco wifi functions, and to allow compiling with the standard fujinet-fuji.h header in the release.
1 parent 217748b commit c756236

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

coco/src/fn_fuji/fuji_get_wifi_enabled.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ bool fuji_get_wifi_enabled()
2323
if (fuji_get_error())
2424
return false;
2525

26-
return fuji_get_response((uint8_t *)&enabled, sizeof(bool));
26+
if (fuji_get_response((uint8_t *)&enabled, sizeof(bool)) == BUS_ERROR)
27+
{
28+
// Set enabled = false on error
29+
enabled = false;
30+
}
31+
32+
return enabled;
2733
}

coco/src/fn_fuji/fuji_set_ssid.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ bool fuji_set_ssid(NetConfig *nc)
1010
{
1111
uint8_t opcode;
1212
uint8_t cmd;
13+
char ssid[SSID_MAXLEN];
14+
char password[MAX_PASSWORD_LEN];
1315
} ss;
1416

1517
ss.opcode = OP_FUJI;
1618
ss.cmd = FUJICMD_SET_SSID;
19+
memcpy(ss.ssid, nc->ssid, SSID_MAXLEN);
20+
memcpy(ss.password, nc->password, MAX_PASSWORD_LEN);
1721

1822
bus_ready();
1923
dwwrite((uint8_t *)&ss, sizeof(ss));
20-
dwwrite((uint8_t *)&nc, sizeof(NetConfig));
2124

2225
return !fuji_get_error();
2326
}

coco/src/include/fujinet-fuji-coco.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef FUJINET_FUJI_COCO_H
1010
#define FUJINET_FUJI_COCO_H
1111

12-
#include "stdbool-coco.h"
12+
#include "fujinet-fuji.h"
1313

1414
/**
1515
* @brief Error code for success

coco/src/include/stdbool-coco.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

fujinet-fuji.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
#ifdef _CMOC_VERSION_
99
#include <cmoc.h>
10-
#include "stdbool-coco.h"
10+
11+
#ifndef bool
12+
#define bool _FNBool
13+
typedef unsigned char _FNBool;
14+
#endif /* bool */
15+
16+
#define true 1
17+
#define false 0
1118
#else
1219
#include <stddef.h>
1320
#include <stdbool.h>

0 commit comments

Comments
 (0)