As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.
Most of these changes were automated using coccinelle with the following
script:
@@
@@
- void
+ int
main(...) {
...
- return;
+ return 0;
...
}
Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.
Signed-off-by: Keith Packard <keithp@keithp.com>
64 lines
1.1 KiB
C
64 lines
1.1 KiB
C
/* main.c - Application main entry point */
|
|
|
|
/*
|
|
* Copyright (c) 2015-2016 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/types.h>
|
|
#include <stddef.h>
|
|
#include <zephyr/sys/printk.h>
|
|
#include <zephyr/sys/util.h>
|
|
|
|
#include <zephyr/bluetooth/bluetooth.h>
|
|
#include <zephyr/bluetooth/hci.h>
|
|
|
|
static uint8_t mfg_data[] = { 0xff, 0xff, 0x00 };
|
|
|
|
static const struct bt_data ad[] = {
|
|
BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, 3),
|
|
};
|
|
|
|
int main(void)
|
|
{
|
|
int err;
|
|
|
|
printk("Starting Broadcaster\n");
|
|
|
|
/* Initialize the Bluetooth Subsystem */
|
|
err = bt_enable(NULL);
|
|
if (err) {
|
|
printk("Bluetooth init failed (err %d)\n", err);
|
|
return 0;
|
|
}
|
|
|
|
printk("Bluetooth initialized\n");
|
|
|
|
do {
|
|
k_msleep(1000);
|
|
|
|
printk("Sending advertising data: 0x%02X\n", mfg_data[2]);
|
|
|
|
/* Start advertising */
|
|
err = bt_le_adv_start(BT_LE_ADV_NCONN, ad, ARRAY_SIZE(ad),
|
|
NULL, 0);
|
|
if (err) {
|
|
printk("Advertising failed to start (err %d)\n", err);
|
|
return 0;
|
|
}
|
|
|
|
k_msleep(1000);
|
|
|
|
err = bt_le_adv_stop();
|
|
if (err) {
|
|
printk("Advertising failed to stop (err %d)\n", err);
|
|
return 0;
|
|
}
|
|
|
|
mfg_data[2]++;
|
|
|
|
} while (1);
|
|
return 0;
|
|
}
|