I am developing my first BLE Server application with the nRF52832 and using VSC/nRF Connect/Zephyr ROTS. I come from a Cypress/PSOC Creator background, and am struggling a bit to get up to speed with the Nordic stuff.
Using the peripheral_dis example, I put together the following code. Initially everything was stuffed into main.c, but once I had it working OK, I decided to modularise it to make it easier to read, and also so I can reuse some of the code segments more easily.
I'm having issues moving the Advertising Packet and Scan Response Packet definitions, and also the connection and disconnection call back functions and declarations into my ble_config.c and ble_config.h files. The moment I do that, I get a bunch of compile errors.
I'm sure I'm doing something obviously wrong, but in my inexperience, I'm stuffed if I can work out what!
I've included my project files in the attached .zip The functions/declarations I'm trying to put into ble_config.c/h are:
// Bluetooth Advertising data
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), // Sets up advertising parameters
BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_LPI_DEVICE), // Defines any Service UUIDs to include in advertising packet
};
// Bluetooth Scan Response data (initially empty)
static struct bt_data sd[] = {
BT_DATA(BT_DATA_MANUFACTURER_DATA, NULL, BT_GAP_ADV_MAX_ADV_DATA_LEN-2),
};
static void connected(struct bt_conn *conn, uint8_t err)
{
if (err) {
printk("Connection failed (err 0x%02x)\n", err);
} else {
printk("Connected\n");
}
}
static void disconnected(struct bt_conn *conn, uint8_t reason)
{
printk("Disconnected (reason 0x%02x)\n", reason);
}
BT_CONN_CB_DEFINE(conn_callbacks) = {
.connected = connected,
.disconnected = disconnected,
};