Skip to content

Commit

Permalink
Merge pull request #483 from sonydevworld/develop
Browse files Browse the repository at this point in the history
Merge develop into master for v2.6.0 release
  • Loading branch information
SPRESENSE authored Aug 5, 2022
2 parents dd422f9 + 1ddbe6c commit 556c296
Show file tree
Hide file tree
Showing 192 changed files with 60,960 additions and 298 deletions.
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -1623,3 +1623,30 @@ This software includes open source software subject to the licensing
described in the following file:

externals/websocket/cwebsocket/LICENSE

========================================================================


14. License of nRF52

========================================================================
externals/nrf52/nRF5_SDK17.1.0_ddde560

This software includes open source software subject to the licensing
described in the following file:

externals/nrf52/nRF5_SDK17.1.0_ddde560/nRF5_Nordic_license.txt


The original codes can be downloaded as a zip file from the following site:

Download:
https://www.nordicsemi.com/Products/Development-software/nRF5-SDK/Download
Version: 17.1.0
SoftDevice: SI32
Target: nRF52840
File name: nRF5_SDK_17.1.0_ddde560.zip

Notice:
The software under the nRF5_Nordic_licence here must only be used with
a Noridic Semiconductor ASA integrated circuit.
112 changes: 0 additions & 112 deletions examples/bluetooth_le_central/bluetooth_le_central_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,6 @@
* Private Function Prototypes
****************************************************************************/

/* BT common callbacks */

static void on_command_status(BT_CMD_STATUS status); /**< Command status */
static void on_pairing_complete(BT_ADDR addr, BT_PAIR_STATUS status); /**< Pairing complete */
static void on_inquiry_result(BT_ADDR addr, char *name); /**< Inquiry data result */
static void on_inquiry_complete(void); /**< Coplete inquiry */
static void on_connect_status_changed(struct bt_acl_state_s *bt_acl_state,
bool connected, int status); /**< Connection status change */
static void on_connected_device_name(const char *name); /**< Device name change */
static void on_bond_info(BT_ADDR addr); /**< Bonding information */

/* BLE common callbacks */

static void on_le_connect_status_change(struct ble_state_s *ble_state,
Expand All @@ -85,17 +74,6 @@ static void on_db_discovery(struct ble_gatt_event_db_discovery_t *db_disc); /**<
* Private Data
****************************************************************************/

static struct bt_common_ops_s bt_common_ops =
{
.command_status = on_command_status,
.pairing_complete = on_pairing_complete,
.inquiry_result = on_inquiry_result,
.inquiry_complete = on_inquiry_complete,
.connect_status_changed = on_connect_status_changed,
.connected_device_name = on_connected_device_name,
.bond_info = on_bond_info
};

static struct ble_common_ops_s ble_common_ops =
{
.connect_status_changed = on_le_connect_status_change,
Expand All @@ -113,7 +91,6 @@ static struct ble_gatt_central_ops_s ble_gatt_central_ops =

static BT_ADDR local_addr = {{0x19, 0x84, 0x06, 0x14, 0xAB, 0xCD}};

static char local_bt_name[BT_NAME_LEN] = "SONY_BT";
static char local_ble_name[BT_NAME_LEN] = "SONY_BLE";
static struct ble_state_s *s_ble_state = NULL;
#if 0
Expand Down Expand Up @@ -166,68 +143,6 @@ static void ble_state_add_bt_addr(struct ble_state_s *state, BT_ADDR *addr)
memcpy(&state->bt_target_addr, addr, sizeof(state->bt_target_addr));
}

static void on_command_status(BT_CMD_STATUS status)
{
/* If receive command status event, this function will call. */

printf("%s [BT] Command status = %d\n", __func__, status);
}

static void on_pairing_complete(BT_ADDR addr, BT_PAIR_STATUS status)
{
/* If pairing task complete, this function will call.
* Print receive event data.
*/

printf("[BT] Pairing complete ADDR:%02X:%02X:%02X:%02X:%02X:%02X, status=%d\n",
addr.address[0], addr.address[1], addr.address[2],
addr.address[3], addr.address[4], addr.address[5],
status);
}

static void on_inquiry_result(BT_ADDR addr, char *name)
{
/* If receive inquiry search result, this function will call. */

printf("[BT] Inquiry result ADDR:%02X:%02X:%02X:%02X:%02X:%02X, name:%s\n",
addr.address[0], addr.address[1], addr.address[2],
addr.address[3], addr.address[4], addr.address[5],
name);
}

static void on_inquiry_complete(void)
{
/* If receive inquiry complete event, this function will call. */

printf("%s [BT] Inquiry complete\n", __func__);
}

static void on_connect_status_changed(struct bt_acl_state_s *bt_acl_state,
bool connected, int status)
{
/* If conection status changed, this function will call. */

printf("%s [BT] Connect status changed\n", __func__);
}

static void on_connected_device_name(const char *name)
{
/* If receive connected device name data, this function will call. */

printf("%s [BT] Receive connected device name = %s\n", __func__, name);
}

static void on_bond_info(BT_ADDR addr)
{
/* If new bonding is comming, this function will call.
* Print new bonding information.
*/

printf("[BLE_GATT] Bonding information ADDR:%02X:%02X:%02X:%02X:%02X:%02X\n",
addr.address[0], addr.address[1], addr.address[2],
addr.address[3], addr.address[4], addr.address[5]);
}

static void on_le_connect_status_change(struct ble_state_s *ble_state,
bool connected)
{
Expand Down Expand Up @@ -372,15 +287,6 @@ int main(int argc, FAR char *argv[])
{
int ret = 0;

/* Register BT event callback function */

ret = bt_register_common_cb(&bt_common_ops);
if (ret != BT_SUCCESS)
{
printf("%s [BT] Register common call back failed. ret = %d\n", __func__, ret);
goto error;
}

/* Initialize BT HAL */

ret = bt_init();
Expand All @@ -390,24 +296,6 @@ int main(int argc, FAR char *argv[])
goto error;
}

/* Set local device address */

ret = bt_set_address(&local_addr);
if (ret != BT_SUCCESS)
{
printf("%s [BT] Set local address failed. ret = %d\n", __func__, ret);
goto error;
}

/* Set local device name */

ret = bt_set_name(local_bt_name);
if (ret != BT_SUCCESS)
{
printf("%s [BT] Set local name failed. ret = %d\n", __func__, ret);
goto error;
}

/* Turn ON BT */

ret = bt_enable();
Expand Down
122 changes: 8 additions & 114 deletions examples/bluetooth_le_peripheral/bluetooth_le_peripheral_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,6 @@
* Private Function Prototypes
****************************************************************************/

/* BT common callbacks */

static void onCommandStatus(BT_CMD_STATUS status); /**< Command status */
static void onPairingComplete(BT_ADDR addr, BT_PAIR_STATUS status); /**< Pairing complete */
static void onInquiryResult(BT_ADDR addr, char *name); /**< Inquiry data result */
static void onInquiryComplete(void); /**< Coplete inquiry */
static void onConnectStatusChanged(struct bt_acl_state_s *bt_acl_state,
bool connected, int status); /**< Connection status change */
static void onConnectedDeviceName(const char *name); /**< Device name change */
static void onBondInfo(BT_ADDR addr); /**< Bonding information */

/* BLE common callbacks */

static void onLeConnectStatusChanged(struct ble_state_s *ble_state,
Expand All @@ -84,17 +73,6 @@ static void onNotify(struct ble_gatt_char_s *ble_gatt_char, bool enable); /**< N
* Private Data
****************************************************************************/

static struct bt_common_ops_s bt_common_ops =
{
.command_status = onCommandStatus,
.pairing_complete = onPairingComplete,
.inquiry_result = onInquiryResult,
.inquiry_complete = onInquiryComplete,
.connect_status_changed = onConnectStatusChanged,
.connected_device_name = onConnectedDeviceName,
.bond_info = onBondInfo
};

static struct ble_common_ops_s ble_common_ops =
{
.connect_status_changed = onLeConnectStatusChanged,
Expand All @@ -111,10 +89,9 @@ static struct ble_gatt_peripheral_ops_s ble_gatt_peripheral_ops =

static BT_ADDR local_addr = {{0x19, 0x84, 0x06, 0x14, 0xAB, 0xCD}};

static char local_bt_name[BT_NAME_LEN] = "SONY_BT";
static char local_ble_name[BT_NAME_LEN] = "SONY_BLE";

static struct bt_acl_state_s *s_bt_acl_state = NULL;
static bool ble_is_connected = false;

static struct ble_gatt_service_s *g_ble_gatt_service;

Expand Down Expand Up @@ -158,68 +135,6 @@ static struct ble_gatt_char_s g_ble_gatt_char =
* Private Functions
****************************************************************************/

static void onCommandStatus(BT_CMD_STATUS status)
{
/* If receive command status event, this function will call. */

printf("%s [BT] Command status = %d\n", __func__, status);
}

static void onPairingComplete(BT_ADDR addr, BT_PAIR_STATUS status)
{
/* If pairing task complete, this function will call.
* Print receive event data.
*/

printf("[BT] Pairing complete ADDR:%02X:%02X:%02X:%02X:%02X:%02X, status=%d\n",
addr.address[0], addr.address[1], addr.address[2],
addr.address[3], addr.address[4], addr.address[5],
status);
}

static void onInquiryResult(BT_ADDR addr, char *name)
{
/* If receive inquiry search result, this function will call. */

printf("[BT] Inquiry result ADDR:%02X:%02X:%02X:%02X:%02X:%02X, name:%s\n",
addr.address[0], addr.address[1], addr.address[2],
addr.address[3], addr.address[4], addr.address[5],
name);
}

static void onInquiryComplete(void)
{
/* If receive inquiry complete event, this function will call. */

printf("%s [BT] Inquiry complete\n", __func__);
}

static void onConnectStatusChanged(struct bt_acl_state_s *bt_acl_state,
bool connected, int status)
{
/* If ACL is connected, SPP can start connect */

s_bt_acl_state = bt_acl_state;
}

static void onConnectedDeviceName(const char *name)
{
/* If receive connected device name data, this function will call. */

printf("%s [BT] Receive connected device name = %s\n", __func__, name);
}

static void onBondInfo(BT_ADDR addr)
{
/* If new bonding is comming, this function will call.
* Print new bonding information.
*/

printf("[BLE_GATT] Bonding information ADDR:%02X:%02X:%02X:%02X:%02X:%02X\n",
addr.address[0], addr.address[1], addr.address[2],
addr.address[3], addr.address[4], addr.address[5]);
}

static void onLeConnectStatusChanged(struct ble_state_s *ble_state,
bool connected)
{
Expand All @@ -231,6 +146,8 @@ static void onLeConnectStatusChanged(struct ble_state_s *ble_state,
addr.address[0], addr.address[1], addr.address[2],
addr.address[3], addr.address[4], addr.address[5],
connected ? "Connected" : "Disconnected");

ble_is_connected = connected;
}

static void onConnectedDeviceNameResp(const char *name)
Expand Down Expand Up @@ -278,6 +195,10 @@ static void ble_peripheral_exit(void)
{
int ret;

/* Update connection status */

ble_is_connected = false;

/* Turn OFF BT */

ret = bt_disable();
Expand Down Expand Up @@ -311,15 +232,6 @@ int main(int argc, FAR char *argv[])
BLE_UUID *s_uuid;
BLE_UUID *c_uuid;

/* Register BT event callback function */

ret = bt_register_common_cb(&bt_common_ops);
if (ret != BT_SUCCESS)
{
printf("%s [BT] Register common call back failed. ret = %d\n", __func__, ret);
goto error;
}

/* Initialize BT HAL */

ret = bt_init();
Expand All @@ -329,24 +241,6 @@ int main(int argc, FAR char *argv[])
goto error;
}

/* Set local device address */

ret = bt_set_address(&local_addr);
if (ret != BT_SUCCESS)
{
printf("%s [BT] Set local address failed. ret = %d\n", __func__, ret);
goto error;
}

/* Set local device name */

ret = bt_set_name(local_bt_name);
if (ret != BT_SUCCESS)
{
printf("%s [BT] Set local name failed. ret = %d\n", __func__, ret);
goto error;
}

/* Turn ON BT */

ret = bt_enable();
Expand Down Expand Up @@ -477,7 +371,7 @@ int main(int argc, FAR char *argv[])

len = readline(buffer, sizeof(buffer) - 1, stdin, stdout);

if (s_bt_acl_state && s_bt_acl_state->bt_acl_connection == BT_CONNECTED)
if (ble_is_connected)
{
ret = ble_characteristic_notify(&g_ble_gatt_char, (uint8_t *) buffer, len);
if (ret != BT_SUCCESS)
Expand Down
Loading

0 comments on commit 556c296

Please sign in to comment.