Skip to content

Commit ebc634b

Browse files
committed
Updates Usage Docs And Shuffles Around Where Device Gets Configured
Device configuration (device_init) should not be an API that the user must call so the struct should be passed into the bristlemout_init function Updates docs to reflect this
1 parent bdb4494 commit ebc634b

4 files changed

Lines changed: 49 additions & 13 deletions

File tree

docs/api/api.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
# API
22

3-
Minimal API for the integrator is the philosophy behind Bristlemouth.
4-
The API required to start the bristlemouth stack is as follows.
5-
6-
<!--- Infomration regarding initializing the bm stack here --->
7-
8-
---
9-
10-
## Public API
11-
12-
The following provide information on the public API that can be used to interact with features of the Bristlemouth stack:
3+
The following provides information on the public API that can be used to interact with features of the Bristlemouth stack:
134

145
```{toctree}
156
:maxdepth: 1
@@ -19,4 +10,5 @@ pubsub
1910
time
2011
integrations
2112
services
13+
2214
```

docs/usage.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,46 @@ the code integration is very simple: a single call to `bristlemouth_init`.
392392

393393
```C
394394
#include "bristlemouth.h"
395+
#include "l2.h"
395396

396397
void network_device_power_callback(bool on) {
397398
// Provide or cut off power to the network chip.
398399
// On the mote, we set pin PH1 high or low.
399400
}
400401

402+
static void network_device_interrupt(void) {
403+
// Necessary logic that occurs when an interrupt from the 10Base-T1L driver
404+
// is called should be placed here (application specific), the below
405+
// function call is a must in order to inform L2 that an event must be
406+
// handled
407+
bm_l2_handle_device_interrupt();
408+
}
409+
401410
int main(void) {
411+
// User specific interrupt register code
412+
register_device_interrupt(network_device_interrupt);
413+
414+
// Information about the device must be configured
415+
DeviceCfg device = {
416+
.node_id = 0, // ID of the node being integrated
417+
.git_sha = 0, // Commit hash of the build
418+
.device_name = "dev_name", // Name of node
419+
.version_string = "v0.0.0", // Firmware version in string format
420+
.vendor_id = 0, // Vendor ID of the node
421+
.product_id = 0, // Product ID of the node
422+
.hw_ver = 0, // Hardware revision number
423+
.ver_major = 0, // Major semantic versioning of the build for the node
424+
.ver_minor = 0, // Minor semantic versioning of the build for the node
425+
.ver_patch = 0, // Patch semantic versioning of the build for the node
426+
.sn = {'0', '1', '2', '3',
427+
'4', '5', '6', '7',
428+
'8', '9', 'a', 'b',
429+
'c', 'd', 'e', 'f'}, // Serial number assigned to node
430+
};
431+
402432
// ... your other setup code...
403433

404-
BmErr err = bristlemouth_init(network_device_power_callback);
434+
BmErr err = bristlemouth_init(network_device_power_callback, device);
405435
if (err != BmOK) {
406436
// handle error appropriately for your system
407437
}

middleware/bristlemouth.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010

1111
#define BM_MIDDLEWARE_PORT 4321
1212

13-
BmErr bristlemouth_init(NetworkDevicePowerCallback net_power_cb) {
13+
BmErr bristlemouth_init(NetworkDevicePowerCallback net_power_cb,
14+
DeviceCfg device) {
1415
NetworkDevice network_device = adin2111_network_device();
1516
network_device.callbacks->power = net_power_cb;
1617

1718
BmErr err = BmOK;
19+
config_init();
20+
21+
bm_err_check(err, device_init(device));
1822
bm_err_check(err, adin2111_init());
1923
bm_err_check(err, bm_l2_init(network_device));
2024
bm_err_check(err, bm_ip_init());

middleware/bristlemouth.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
#include "device.h"
12
#include "network_device.h"
23

4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
38
typedef void (*NetworkDevicePowerCallback)(bool);
49

5-
BmErr bristlemouth_init(NetworkDevicePowerCallback net_power_cb);
10+
BmErr bristlemouth_init(NetworkDevicePowerCallback net_power_cb,
11+
DeviceCfg device);
612
NetworkDevice bristlemouth_network_device(void);
13+
14+
#ifdef __cplusplus
15+
}
16+
#endif

0 commit comments

Comments
 (0)