[GitHub] [mynewt-core] w277277w commented on issue #2189: Could not resolve app package: @mcuboot/boot/mynewt

2020-04-17 Thread GitBox
w277277w commented on issue #2189: Could not resolve app package: 
@mcuboot/boot/mynewt
URL: https://github.com/apache/mynewt-core/issues/2189#issuecomment-615525571
 
 
   it is no issue with 1.8, It's wrong that the project upgrade without 
'--escape=false' on windows, thank you
   
   
   
   --原始邮件--
   发件人: "Szymon Janc"

[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2274: [STM32F0] Fix stm32_hal_timer_get_freq

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #2274: [STM32F0] Fix 
stm32_hal_timer_get_freq
URL: https://github.com/apache/mynewt-core/pull/2274#issuecomment-615514725
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] kasjer opened a new pull request #2274: [STM32F0] Fix stm32_hal_timer_get_freq

2020-04-17 Thread GitBox
kasjer opened a new pull request #2274: [STM32F0] Fix stm32_hal_timer_get_freq
URL: https://github.com/apache/mynewt-core/pull/2274
 
 
   Case for TIM2 was missing, rendering this
   timer unusable.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #801: Prevent storing of CCCD's if peer is not bonded.

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #801: Prevent storing of CCCD's if peer is 
not bonded.
URL: https://github.com/apache/mynewt-nimble/pull/801#issuecomment-615457011
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #801: Prevent storing of CCCD's if peer is not bonded.

2020-04-17 Thread GitBox
apache-mynewt-bot removed a comment on issue #801: Prevent storing of CCCD's if 
peer is not bonded.
URL: https://github.com/apache/mynewt-nimble/pull/801#issuecomment-615429204
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    nimble/host/src/ble_gatts.c
   
   
   ```diff
   @@ -1679,7 +1679,7 @@
conn = ble_hs_conn_find(conn_handle);
BLE_HS_DBG_ASSERT(conn != NULL);

   -if(conn->bhc_sec_state.bonded) {
   +if (conn->bhc_sec_state.bonded) {
cccd_value.peer_addr = conn->bhc_peer_addr;
cccd_value.peer_addr.type =
ble_hs_misc_peer_addr_type_to_id(conn->bhc_peer_addr.type);
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] mlaz opened a new issue #2273: RFC - ADC API not abstract enough for a test app.

2020-04-17 Thread GitBox
mlaz opened a new issue #2273: RFC - ADC API not abstract enough for a test app.
URL: https://github.com/apache/mynewt-core/issues/2273
 
 
   Currently the ADC API lacks on device and channel configuration data 
structures. This led us to having drivers which work in different fashions and 
use different configuration data structures. It made us deal with manufacturer 
SDK data structures on app code and stopped us from having an adc_test app 
(like we do with pwm_test) which besides being example code is helpful to test 
the drivers during manufacturer SDK code updates.
   
   This issue aims to find an ADC API witch abstracts as much as possible the 
hardware thus allowing more homogenous usage across drivers. 
   
   At this point I did a few 
[changes](https://github.com/mlaz/mynewt-core/tree/adc_api_changes) on the ADC 
API  and nRF52 driver so it works with the test app.
   The test app is based on the one we have on this 
[tutorial](https://mynewt.apache.org/latest/tutorials/sensors/nrf52_adc.html) 
and it can improved.
   
   Please review and comment.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #801: Prevent storing of CCCD's if peer is not bonded.

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #801: Prevent storing of CCCD's if peer is 
not bonded.
URL: https://github.com/apache/mynewt-nimble/pull/801#issuecomment-615429204
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    nimble/host/src/ble_gatts.c
   
   
   ```diff
   @@ -1679,7 +1679,7 @@
conn = ble_hs_conn_find(conn_handle);
BLE_HS_DBG_ASSERT(conn != NULL);

   -if(conn->bhc_sec_state.bonded) {
   +if (conn->bhc_sec_state.bonded) {
cccd_value.peer_addr = conn->bhc_peer_addr;
cccd_value.peer_addr.type =
ble_hs_misc_peer_addr_type_to_id(conn->bhc_peer_addr.type);
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] h2zero opened a new pull request #801: Prevent storing of CCCD's if peer is not bonded.

2020-04-17 Thread GitBox
h2zero opened a new pull request #801: Prevent storing of CCCD's if peer is not 
bonded.
URL: https://github.com/apache/mynewt-nimble/pull/801
 
 
   Currently a peer that we have paired with but not bonded will have it's
   CCCD status stored. We should not store CCCD data unless bonded,
   this will prevent that.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] brianwyld commented on issue #2224: add functionality to allow low power operation for STM32L1xx

2020-04-17 Thread GitBox
brianwyld commented on issue #2224: add functionality to allow low power 
operation for STM32L1xx
URL: https://github.com/apache/mynewt-core/pull/2224#issuecomment-615304616
 
 
   Well... looks like I screwed up my git merge again - there should be about
   6 files, not all the crap that is in fact just the mynewt-core master
   updates
   
   On Fri, 17 Apr 2020 at 16:47, kasjer  wrote:
   
   > In this form it even automatic style checker give up.
   > It's hard to decide which part was actually added or changed by this PR.
   > Watchdog interval does not belong here.
   > There are conflicts reported by hithub anyway.
   > I would prefer to have this code rebased, maybe there is no 155 files to
   > review after all.
   >
   > —
   > You are receiving this because you authored the thread.
   > Reply to this email directly, view it on GitHub
   > ,
   > or unsubscribe
   > 

   > .
   >
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] brianwyld closed pull request #2224: add functionality to allow low power operation for STM32L1xx

2020-04-17 Thread GitBox
brianwyld closed pull request #2224: add functionality to allow low power 
operation for STM32L1xx
URL: https://github.com/apache/mynewt-core/pull/2224
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] kasjer commented on issue #2224: add functionality to allow low power operation for STM32L1xx

2020-04-17 Thread GitBox
kasjer commented on issue #2224: add functionality to allow low power operation 
for STM32L1xx
URL: https://github.com/apache/mynewt-core/pull/2224#issuecomment-615286276
 
 
   In this form it even automatic style checker give up.
   It's hard to decide which part was actually added or changed by this PR.
   Watchdog interval does not belong here.
   There are conflicts reported by hithub anyway.
   I would prefer to have this code rebased, maybe there is no 155 files to 
review after all.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #800: nimble/ll: Add common setting for SCA

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #800: nimble/ll: Add common 
setting for SCA
URL: https://github.com/apache/mynewt-nimble/pull/800#discussion_r410265923
 
 

 ##
 File path: nimble/controller/include/controller/ble_ll.h
 ##
 @@ -69,6 +69,29 @@ extern "C" {
 /* Timing jitter as per spec is +/16 usecs */
 #define BLE_LL_JITTER_USECS (16)
 
+
 
 Review comment:
   spare empty line


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #800: nimble/ll: Add common setting for SCA

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #800: nimble/ll: Add common setting for SCA
URL: https://github.com/apache/mynewt-nimble/pull/800#issuecomment-615279948
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #800: nimble/ll: Add common setting for SCA

2020-04-17 Thread GitBox
apache-mynewt-bot removed a comment on issue #800: nimble/ll: Add common 
setting for SCA
URL: https://github.com/apache/mynewt-nimble/pull/800#issuecomment-615166886
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    nimble/controller/src/ble_ll_adv.c
   
   
   ```diff
   @@ -4022,7 +4022,7 @@

/* SID, AType, SCA */
sync_ind[24] = (advsm->adi >> 12);
   -sync_ind[24] |= !!(advsm->flags & BLE_LL_ADV_SM_FLAG_TX_ADD) << 4 ;
   +sync_ind[24] |= !!(advsm->flags & BLE_LL_ADV_SM_FLAG_TX_ADD) << 4;
sync_ind[24] |= BLE_LL_SCA_ENUM << 5;

/* PHY */
   ```
   
   
   
    nimble/controller/src/ble_ll_sync.c
   
   
   ```diff
   @@ -2091,7 +2092,7 @@
if (syncsm->flags & BLE_LL_SYNC_SM_FLAG_ADDR_RESOLVED) {
sync_ind[24] |= 1 << 4;
} else {
   -sync_ind[24] |= (syncsm->adv_addr_type == BLE_ADDR_RANDOM) << 4 ;
   +sync_ind[24] |= (syncsm->adv_addr_type == BLE_ADDR_RANDOM) << 4;
}

sync_ind[24] |= BLE_LL_SCA_ENUM << 5;
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2224: add functionality to allow low power operation for STM32L1xx

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #2224: add functionality to allow low 
power operation for STM32L1xx
URL: https://github.com/apache/mynewt-core/pull/2224#issuecomment-615276926
 
 
   
   ## Style check fail: Payload was too large


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2224: add functionality to allow low power operation for STM32L1xx

2020-04-17 Thread GitBox
apache-mynewt-bot removed a comment on issue #2224: add functionality to allow 
low power operation for STM32L1xx
URL: https://github.com/apache/mynewt-core/pull/2224#issuecomment-606555366
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    hw/mcu/stm/stm32l1xx/src/hal_power_mgnt.c
   
   
   ```diff
   @@ -35,8 +35,8 @@
void stm32_tickless_start(uint32_t timeMS);

/* Put MCU  in lowest power stop state, exit only via POR or reset pin */
   -void 
   -hal_mcu_halt() 
   +void
   +hal_mcu_halt()
{

/* all interupts and exceptions off */
   @@ -49,7 +49,7 @@

while (1) {

   -/*Disables the Power Voltage Detector(PVD) */
   +/*Disables the Power Voltage Detector(PVD) */
HAL_PWR_DisablePVD( );
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower( );
   @@ -61,13 +61,13 @@
}
}

   -void 
   +void
stm32_tick_init(uint32_t os_ticks_per_sec, int prio)
{
/* Even for tickless we use SYSTICK for normal tick.*/
/* nb of ticks per seconds is hardcoded in HAL_InitTick(..) to have 
1ms/tick */
assert(os_ticks_per_sec == OS_TICKS_PER_SEC);
   -
   +
volatile uint32_t reload_val;

/*Reload Value = SysTick Counter Clock (Hz) x  Desired Time base (s) */
   @@ -77,8 +77,8 @@
SysTick->VAL = 0;

/* CLKSOURCE : 1 -> HCLK, 0-> AHB Clock (which is HCLK/8). Use HCLK, as 
this is the value of SystemCoreClock as used above */
   -SysTick->CTRL = (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk 
| SysTick_CTRL_ENABLE_Msk);  
   -
   +SysTick->CTRL = (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk 
| SysTick_CTRL_ENABLE_Msk);
   +
/* Set the system tick priority */
NVIC_SetPriority(SysTick_IRQn, prio);

   @@ -102,7 +102,7 @@

}

   -void 
   +void
stm32_tickless_start(uint32_t timeMS)
{

   @@ -116,10 +116,10 @@
CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
}

   -void 
   +void
stm32_tickless_stop(uint32_t timeMS)
{
   -
   +
/* add asleep duration to tick counter : how long we should have slept 
for minus any remaining time */
volatile uint32_t asleep_ms = hal_rtc_get_elapsed_wakeup_timer();
volatile int asleep_ticks = os_time_ms_to_ticks32(asleep_ms);
   @@ -133,10 +133,10 @@
NVIC_EnableIRQ(SysTick_IRQn);
/* reenable SysTick */
SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
   -
   -}
   -
   -void 
   +
   +}
   +
   +void
stm32_power_enter(int power_mode, uint32_t durationMS)
{
/* if sleep time was less than MIN_TICKS, it is 0. Just do usual WFI 
and systick will wake us in 1ms */
   @@ -147,7 +147,7 @@

if (durationMS >= 32000) {
/* 32 sec is the largest value of wakeuptimer   leave 100ms slack */
   -durationMS = (32000 - 100); 
   +durationMS = (32000 - 100);
}

/* begin tickless */
   @@ -158,7 +158,7 @@
switch (power_mode) {
case HAL_BSP_POWER_OFF:
case HAL_BSP_POWER_DEEP_SLEEP: {
   -/*Disables the Power Voltage Detector(PVD) */
   +/*Disables the Power Voltage Detector(PVD) */
HAL_PWR_DisablePVD( );
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower( );
   @@ -172,7 +172,7 @@
}
case HAL_BSP_POWER_SLEEP: {

   -/*Disables the Power Voltage Detector(PVD) */
   +/*Disables the Power Voltage Detector(PVD) */
HAL_PWR_DisablePVD( );
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower( );
   @@ -191,11 +191,11 @@
}
case HAL_BSP_POWER_ON:
default: {
   -
   -break;
   -}
   -}
   -
   +
   +break;
   +}
   +}
   +
#if MYNEWT_VAL(OS_TICKLESS_RTC)
/* exit tickless low power mode */
stm32_tickless_stop(durationMS);
   ```
   
   
   
    hw/mcu/stm/stm32l1xx/src/rtc_utils.c
   
   
   ```diff
   @@ -1,13 +1,13 @@
/**
 * Copyright 2019 Wyres
   - * Licensed under the Apache License, Version 2.0 (the "License"); 
   - * you may not use this file except in compliance with the License. 
   + * Licensed under the Apache License, Version 2.0 (the "License");
   + * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *http://www.apache.org/licenses/LICENSE-2.0
   - * Unless required by applicable law or agreed to in writing, 
   - * software distributed under the License is distributed on 
   - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
   - * either express or implied. See the License for 

[mynewt-nimble] branch master updated (6661a51 -> 6ec9b6b)

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 6661a51  nimble/store: Fix store behavior when CCCDs exceed maximum 
limit
 add 6ec9b6b  nimble/host: Improve find conn by ble_addr_t

No new revisions were added by this update.

Summary of changes:
 nimble/host/src/ble_hs_conn.c | 9 +
 1 file changed, 9 insertions(+)



[GitHub] [mynewt-nimble] rymanluk merged pull request #792: nimble/host: Improve find conn by ble_addr_t

2020-04-17 Thread GitBox
rymanluk merged pull request #792: nimble/host: Improve find conn by ble_addr_t
URL: https://github.com/apache/mynewt-nimble/pull/792
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] sjanc commented on issue #2189: Could not resolve app package: @mcuboot/boot/mynewt

2020-04-17 Thread GitBox
sjanc commented on issue #2189: Could not resolve app package: 
@mcuboot/boot/mynewt
URL: https://github.com/apache/mynewt-core/issues/2189#issuecomment-615268020
 
 
   is this stil an issue with 1.8 ?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk merged pull request #790: nimble/store: Fix nimble store behavior when CCCDs exceed static defined limit

2020-04-17 Thread GitBox
rymanluk merged pull request #790: nimble/store: Fix nimble store behavior when 
CCCDs exceed static defined limit
URL: https://github.com/apache/mynewt-nimble/pull/790
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[mynewt-nimble] branch master updated (bb0fcde -> 6661a51)

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from bb0fcde  nimble/socket: Enhance error log with hci dev num
 new 7260a4e  nimble/host: Fix return code in `ble_gap_unpair_oldest_peer` 
when no bonded peer exist
 new 6661a51  nimble/store: Fix store behavior when CCCDs exceed maximum 
limit

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/host/include/host/ble_gap.h | 14 ++
 nimble/host/src/ble_gap.c  | 32 +++-
 nimble/host/src/ble_store_util.c   | 16 +---
 3 files changed, 54 insertions(+), 8 deletions(-)



[mynewt-nimble] 02/02: nimble/store: Fix store behavior when CCCDs exceed maximum limit

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 6661a5139ae3bce4b123b7089cf6f6d61ee6764d
Author: Prasad Alatkar 
AuthorDate: Wed Apr 1 00:08:29 2020 +0530

nimble/store: Fix store behavior when CCCDs exceed maximum limit

- Add supporting API to skip input peer while unpairing oldest peer
---
 nimble/host/include/host/ble_gap.h | 14 ++
 nimble/host/src/ble_gap.c  | 30 ++
 nimble/host/src/ble_store_util.c   | 16 +---
 3 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/nimble/host/include/host/ble_gap.h 
b/nimble/host/include/host/ble_gap.h
index 20e7dab..b58f350 100644
--- a/nimble/host/include/host/ble_gap.h
+++ b/nimble/host/include/host/ble_gap.h
@@ -1896,6 +1896,20 @@ int ble_gap_unpair(const ble_addr_t *peer_addr);
  */
 int ble_gap_unpair_oldest_peer(void);
 
+/**
+ * Similar to `ble_gap_unpair_oldest_peer()`, except it makes sure that the
+ * peer received in input parameters is not deleted.
+ *
+ * @param peer_addr Address of the peer (not to be deleted)
+ *
+ * @return  0 on success;
+ *  A BLE host HCI return code if the controller
+ *  rejected the request;
+ *  A BLE host core return code on unexpected
+ *  error.
+ */
+int ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr);
+
 #define BLE_GAP_PRIVATE_MODE_NETWORK0
 #define BLE_GAP_PRIVATE_MODE_DEVICE 1
 
diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index b44012d..53c6bf3 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -5605,6 +5605,36 @@ ble_gap_unpair_oldest_peer(void)
 return 0;
 }
 
+int
+ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr)
+{
+ble_addr_t peer_id_addrs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)];
+int num_peers;
+int rc, i;
+
+rc = ble_store_util_bonded_peers(
+_id_addrs[0], _peers, MYNEWT_VAL(BLE_STORE_MAX_BONDS));
+if (rc != 0) {
+return rc;
+}
+
+if (num_peers == 0) {
+return BLE_HS_ENOENT;
+}
+
+for (i = 0; i < num_peers; i++) {
+if (ble_addr_cmp(peer_addr, _id_addrs[i]) != 0) {
+break;
+}
+}
+
+if (i >= num_peers) {
+return BLE_HS_ENOMEM;
+}
+
+return ble_gap_unpair(_id_addrs[i]);
+}
+
 void
 ble_gap_passkey_event(uint16_t conn_handle,
   struct ble_gap_passkey_params *passkey_params)
diff --git a/nimble/host/src/ble_store_util.c b/nimble/host/src/ble_store_util.c
index 444cc55..7de4827 100644
--- a/nimble/host/src/ble_store_util.c
+++ b/nimble/host/src/ble_store_util.c
@@ -233,13 +233,15 @@ ble_store_util_status_rr(struct ble_store_status_event 
*event, void *arg)
 switch (event->event_code) {
 case BLE_STORE_EVENT_OVERFLOW:
 switch (event->overflow.obj_type) {
-case BLE_STORE_OBJ_TYPE_OUR_SEC:
-case BLE_STORE_OBJ_TYPE_PEER_SEC:
-case BLE_STORE_OBJ_TYPE_CCCD:
-return ble_gap_unpair_oldest_peer();
-
-default:
-return BLE_HS_EUNKNOWN;
+case BLE_STORE_OBJ_TYPE_OUR_SEC:
+case BLE_STORE_OBJ_TYPE_PEER_SEC:
+return ble_gap_unpair_oldest_peer();
+case BLE_STORE_OBJ_TYPE_CCCD:
+/* Try unpairing oldest peer except current peer */
+return 
ble_gap_unpair_oldest_except(>overflow.value->cccd.peer_addr);
+
+default:
+return BLE_HS_EUNKNOWN;
 }
 
 case BLE_STORE_EVENT_FULL:



[mynewt-nimble] 01/02: nimble/host: Fix return code in `ble_gap_unpair_oldest_peer` when no bonded peer exist

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 7260a4efdb72ab8e1db1767c4f1e502876d8c378
Author: Prasad Alatkar 
AuthorDate: Fri Apr 3 18:42:05 2020 +0530

nimble/host: Fix return code in `ble_gap_unpair_oldest_peer` when no bonded 
peer exist
---
 nimble/host/src/ble_gap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 4729dd0..b44012d 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -5594,7 +5594,7 @@ ble_gap_unpair_oldest_peer(void)
 }
 
 if (num_peers == 0) {
-return 0;
+return BLE_HS_ENOENT;
 }
 
 rc = ble_gap_unpair(_peer_id_addr);



[mynewt-nimble] 01/04: nimble/sm: Minor coding style fix

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit c6eddb058e38cc8faf45d013dc21d7dd53ef7eb7
Author: Łukasz Rymanowski 
AuthorDate: Wed Aug 28 07:42:46 2019 +0200

nimble/sm: Minor coding style fix
---
 nimble/host/src/ble_sm_alg.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/nimble/host/src/ble_sm_alg.c b/nimble/host/src/ble_sm_alg.c
index 50fd77e..148995c 100644
--- a/nimble/host/src/ble_sm_alg.c
+++ b/nimble/host/src/ble_sm_alg.c
@@ -68,8 +68,6 @@ ble_sm_alg_encrypt(const uint8_t *key, const uint8_t 
*plaintext,
 
 swap_buf(tmp, plaintext, 16);
 
-
-
 if (tc_aes_encrypt(enc_data, tmp, ) == TC_CRYPTO_FAIL) {
 return BLE_HS_EUNKNOWN;
 }



[mynewt-nimble] 02/04: nimble/l2cap: Minor coding style fix

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 77bca6bc8fcf9e9341c207eff5107b6af625c91d
Author: Łukasz Rymanowski 
AuthorDate: Thu Jan 2 12:23:34 2020 +0100

nimble/l2cap: Minor coding style fix
---
 nimble/host/src/ble_l2cap_coc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c
index 41a8315..54ea321 100644
--- a/nimble/host/src/ble_l2cap_coc.c
+++ b/nimble/host/src/ble_l2cap_coc.c
@@ -73,7 +73,7 @@ ble_l2cap_coc_create_server(uint16_t psm, uint16_t mtu,
 
 srv = ble_l2cap_coc_srv_alloc();
 if (!srv) {
-return BLE_HS_ENOMEM;
+return BLE_HS_ENOMEM;
 }
 
 srv->psm = psm;
@@ -453,7 +453,7 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
 len - sdu_size_offset);
 if (rc) {
 BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
-   goto failed;
+goto failed;
 }
 
 ble_hs_lock();



[GitHub] [mynewt-nimble] rymanluk merged pull request #799: nimble/host: Minor fixes around the host.

2020-04-17 Thread GitBox
rymanluk merged pull request #799: nimble/host: Minor fixes around the host.
URL: https://github.com/apache/mynewt-nimble/pull/799
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[mynewt-nimble] 04/04: nimble/socket: Enhance error log with hci dev num

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit bb0fcde212146894431732ee87601784cac5d444
Author: Łukasz Rymanowski 
AuthorDate: Wed Aug 14 14:44:02 2019 +0200

nimble/socket: Enhance error log with hci dev num
---
 nimble/transport/socket/src/ble_hci_socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/transport/socket/src/ble_hci_socket.c 
b/nimble/transport/socket/src/ble_hci_socket.c
index 863d0fb..8bf56f3 100644
--- a/nimble/transport/socket/src/ble_hci_socket.c
+++ b/nimble/transport/socket/src/ble_hci_socket.c
@@ -540,7 +540,7 @@ ble_hci_sock_config(void)
 
 rc = bind(s, (struct sockaddr *), sizeof(shci));
 if (rc) {
-dprintf(1, "bind() failed %d\n", errno);
+dprintf(1, "bind() failed %d hci%d\n", errno, shci.hci_dev);
 goto err;
 }
 



[mynewt-nimble] 03/04: nimble/l2cap: Fix return error code

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit ee42c7979eae4f7444ec2678463961521c79fd8a
Author: Łukasz Rymanowski 
AuthorDate: Fri Sep 27 10:15:56 2019 +0200

nimble/l2cap: Fix return error code

os_mbuf_foo() returns OS_ERR codes and we want to return BLE_HS_ERR
codes.
This patch fixes it
---
 nimble/host/src/ble_l2cap_coc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c
index 54ea321..b15646f 100644
--- a/nimble/host/src/ble_l2cap_coc.c
+++ b/nimble/host/src/ble_l2cap_coc.c
@@ -440,6 +440,7 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
 BLE_HS_LOG(DEBUG, "Sending SDU len=%d\n", OS_MBUF_PKTLEN(tx->sdu));
 rc = os_mbuf_append(txom, , sizeof(uint16_t));
 if (rc) {
+rc = BLE_HS_ENOMEM;
 BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
 goto failed;
 }
@@ -452,6 +453,7 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
 rc = os_mbuf_appendfrom(txom, tx->sdu, tx->data_offset,
 len - sdu_size_offset);
 if (rc) {
+rc = BLE_HS_ENOMEM;
 BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
 goto failed;
 }



[mynewt-nimble] branch master updated (822d6f7 -> bb0fcde)

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 822d6f7  Fixes for 1.3.0 release
 new c6eddb0  nimble/sm: Minor coding style fix
 new 77bca6b  nimble/l2cap: Minor coding style fix
 new ee42c79  nimble/l2cap: Fix return error code
 new bb0fcde  nimble/socket: Enhance error log with hci dev num

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/host/src/ble_l2cap_coc.c  | 6 --
 nimble/host/src/ble_sm_alg.c | 2 --
 nimble/transport/socket/src/ble_hci_socket.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)



[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #796: Apps: central added

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-615212074
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #796: Apps: central added

2020-04-17 Thread GitBox
apache-mynewt-bot removed a comment on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-615210009
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    apps/central/src/main.c
   
   
   ```diff
   @@ -145,7 +145,7 @@
{
int rc;

   -/* set scan parameters: 
   +/* set scan parameters:
- scan interval in 0.625ms units
- scan window in 0.625ms units
- filter policy - 0 if whitelisting not used
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #796: Apps: central added

2020-04-17 Thread GitBox
apache-mynewt-bot removed a comment on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-615203118
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    apps/central/src/main.c
   
   
   ```diff
   @@ -141,14 +141,14 @@
{
int rc;

   -/* set scan parameters: 
   +/* set scan parameters:
- scan interval in 0.625ms units
- scan window in 0.625ms units
- filter policy - 0 if whitelisting not used
- limited - should limited discovery be used
- passive - should passive scan be used
- filter duplicates - 1 enables filtering duplicated advertisements
   -*/
   + */
const struct ble_gap_disc_params scan_params = {1, 200, 0, 0, 0, 1};

/* performs discovery procedure */
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #796: Apps: central added

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-615210009
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    apps/central/src/main.c
   
   
   ```diff
   @@ -145,7 +145,7 @@
{
int rc;

   -/* set scan parameters: 
   +/* set scan parameters:
- scan interval in 0.625ms units
- scan window in 0.625ms units
- filter policy - 0 if whitelisting not used
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2272: watchdog: Fix places that ignore WATCHDOG_INTERVAL=0

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #2272: watchdog: Fix places that ignore 
WATCHDOG_INTERVAL=0
URL: https://github.com/apache/mynewt-core/pull/2272#issuecomment-615205800
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] kasjer opened a new pull request #2272: watchdog: Fix places that ignore WATCHDOG_INTERVAL=0

2020-04-17 Thread GitBox
kasjer opened a new pull request #2272: watchdog: Fix places that ignore 
WATCHDOG_INTERVAL=0
URL: https://github.com/apache/mynewt-core/pull/2272
 
 
   When WATCHDOG_INTERVAL is set to zero
   - flash loader would try to initialize watchdog with 0 value
 that would most likely not work
   - hal_flash for STM MCUs would try to tickle uninitialized
 watchdog and that would result in hard fault


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] Reynevan94 commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
Reynevan94 commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410174035
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
 
 Review comment:
   As far as I understand, this GAP event should be handled by peripheral and 
on central side we don't have easy way to find out if it completed, but if I'm 
mistaken, I'm happy to change that.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #796: Apps: central added

2020-04-17 Thread GitBox
apache-mynewt-bot removed a comment on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-615190375
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    apps/central/src/main.c
   
   
   ```diff
   @@ -141,14 +141,14 @@
{
int rc;

   -/* set scan parameters: 
   +/* set scan parameters:
- scan interval in 0.625ms units
- scan window in 0.625ms units
- filter policy - 0 if whitelisting not used
- limited - should limited discovery be used
- passive - should passive scan be used
- filter duplicates - 1 enables filtering duplicated advertisements
   -*/
   + */
const struct ble_gap_disc_params scan_params = {1, 200, 0, 0, 0, 1};

/* performs discovery procedure */
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #796: Apps: central added

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-615203118
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    apps/central/src/main.c
   
   
   ```diff
   @@ -141,14 +141,14 @@
{
int rc;

   -/* set scan parameters: 
   +/* set scan parameters:
- scan interval in 0.625ms units
- scan window in 0.625ms units
- filter policy - 0 if whitelisting not used
- limited - should limited discovery be used
- passive - should passive scan be used
- filter duplicates - 1 enables filtering duplicated advertisements
   -*/
   + */
const struct ble_gap_disc_params scan_params = {1, 200, 0, 0, 0, 1};

/* performs discovery procedure */
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #796: Apps: central added

2020-04-17 Thread GitBox
apache-mynewt-bot removed a comment on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-614542392
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #796: Apps: central added

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-615190375
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    apps/central/src/main.c
   
   
   ```diff
   @@ -141,14 +141,14 @@
{
int rc;

   -/* set scan parameters: 
   +/* set scan parameters:
- scan interval in 0.625ms units
- scan window in 0.625ms units
- filter policy - 0 if whitelisting not used
- limited - should limited discovery be used
- passive - should passive scan be used
- filter duplicates - 1 enables filtering duplicated advertisements
   -*/
   + */
const struct ble_gap_disc_params scan_params = {1, 200, 0, 0, 0, 1};

/* performs discovery procedure */
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] sjanc commented on a change in pull request #2269: hw/drivers/i2s: Add I2S driver for NRF52 family

2020-04-17 Thread GitBox
sjanc commented on a change in pull request #2269: hw/drivers/i2s: Add I2S 
driver for NRF52 family
URL: https://github.com/apache/mynewt-core/pull/2269#discussion_r410138688
 
 

 ##
 File path: hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c
 ##
 @@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct nrf52_i2s {
+nrfx_i2s_config_t nrfx_i2s_cfg;
+bool running;
+int8_t nrfx_queued_count;
+struct i2s *i2s;
+struct i2s_sample_buffer *nrfx_buffers[2];
+};
+
+static struct nrf52_i2s nrf52_i2s;
+
+static void
+nrfx_add_buffer(struct i2s *i2s, struct i2s_sample_buffer *buffer)
+{
+nrfx_i2s_buffers_t nrfx_buffers = {0};
+nrfx_err_t err;
+
+assert(i2s != NULL);
+if (buffer == NULL) {
+return;
+}
+
+if (i2s->direction == I2S_OUT || i2s->direction == I2S_OUT_IN) {
+nrfx_buffers.p_tx_buffer = buffer->sample_data;
+}
+if (i2s->direction == I2S_IN || i2s->direction == I2S_OUT_IN) {
+nrfx_buffers.p_rx_buffer = buffer->sample_data;
+}
+
+assert(nrf52_i2s.nrfx_queued_count < 2);
+assert(nrf52_i2s.nrfx_buffers[nrf52_i2s.nrfx_queued_count] == NULL);
+
+nrf52_i2s.nrfx_buffers[nrf52_i2s.nrfx_queued_count] = buffer;
+nrf52_i2s.nrfx_queued_count++;
+if (nrf52_i2s.nrfx_queued_count == 1) {
+i2s_driver_state_changed (i2s, I2S_STATE_RUNNING);
+err = nrfx_i2s_start(_buffers, buffer->sample_count * 
i2s->sample_size_in_bytes / 4, 0);
+} else {
+err = nrfx_i2s_next_buffers_set(_buffers);
+}
+
+assert(err == NRFX_SUCCESS);
+}
+
+static void
+feed_nrfx(void)
+{
+struct i2s_sample_buffer *buffer;
+
+buffer = i2s_driver_buffer_get(nrf52_i2s.i2s);
+nrfx_add_buffer(nrf52_i2s.i2s, buffer);
+}
+
+static void
+nrf52_i2s_data_handler(const nrfx_i2s_buffers_t *p_released, uint32_t status)
+{
+struct i2s_sample_buffer *buffer;
+
+if (p_released != NULL &&
+(p_released->p_rx_buffer != NULL || p_released->p_tx_buffer != NULL)) {
+nrf52_i2s.nrfx_queued_count--;
+assert(nrf52_i2s.nrfx_queued_count >= 0);
+buffer = nrf52_i2s.nrfx_buffers[0];
+assert(buffer->sample_data == p_released->p_tx_buffer || 
buffer->sample_data == p_released->p_rx_buffer);
+nrf52_i2s.nrfx_buffers[0] = nrf52_i2s.nrfx_buffers[1];
+nrf52_i2s.nrfx_buffers[1] = NULL;
+i2s_driver_buffer_put(nrf52_i2s.i2s, buffer);
+}
+if (nrf52_i2s.running && nrf52_i2s.nrfx_queued_count < 2) {
+assert(nrf52_i2s.nrfx_buffers[1] == NULL);
+feed_nrfx();
+}
+if (status == NRFX_I2S_STATUS_TRANSFER_STOPPED) {
+i2s_driver_state_changed(nrf52_i2s.i2s, I2S_STATE_STOPPED);
+}
+}
+
+static int
+nrf52_i2s_init(struct i2s *i2s, const struct i2s_cfg *cfg)
+{
+int rc;
+
+nrf52_i2s.i2s = i2s;
+
+NVIC_SetVector(nrfx_get_irq_number(NRF_I2S), (uint32_t) 
nrfx_i2s_irq_handler);
+
+nrf52_i2s.nrfx_i2s_cfg = cfg->nrfx_i2s_cfg;
+switch (cfg->nrfx_i2s_cfg.sample_width) {
+case NRF_I2S_SWIDTH_8BIT:
+i2s->sample_size_in_bytes = 1;
+break;
+case NRF_I2S_SWIDTH_16BIT:
+i2s->sample_size_in_bytes = 2;
+break;
+case NRF_I2S_SWIDTH_24BIT:
+i2s->sample_size_in_bytes = 4;
+break;
+}
+
+i2s->direction = I2S_INVALID;
+if (cfg->nrfx_i2s_cfg.sdin_pin != NRFX_I2S_PIN_NOT_USED) {
+i2s->direction = I2S_IN;
+}
+if (cfg->nrfx_i2s_cfg.sdout_pin != NRFX_I2S_PIN_NOT_USED) {
+i2s->direction |= I2S_OUT;
 
 Review comment:
   ok, fair enough :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2271: hw/drivers/i2s: Add I2S driver for STM32F1 family

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #2271: hw/drivers/i2s: Add I2S driver for 
STM32F1 family
URL: https://github.com/apache/mynewt-core/pull/2271#issuecomment-615171769
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2271: hw/drivers/i2s: Add I2S driver for STM32F1 family

2020-04-17 Thread GitBox
apache-mynewt-bot removed a comment on issue #2271: hw/drivers/i2s: Add I2S 
driver for STM32F1 family
URL: https://github.com/apache/mynewt-core/pull/2271#issuecomment-615164869
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #800: nimble/ll: Add common setting for SCA

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #800: nimble/ll: Add common setting for SCA
URL: https://github.com/apache/mynewt-nimble/pull/800#issuecomment-615166886
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    nimble/controller/src/ble_ll_adv.c
   
   
   ```diff
   @@ -4022,7 +4022,7 @@

/* SID, AType, SCA */
sync_ind[24] = (advsm->adi >> 12);
   -sync_ind[24] |= !!(advsm->flags & BLE_LL_ADV_SM_FLAG_TX_ADD) << 4 ;
   +sync_ind[24] |= !!(advsm->flags & BLE_LL_ADV_SM_FLAG_TX_ADD) << 4;
sync_ind[24] |= BLE_LL_SCA_ENUM << 5;

/* PHY */
   ```
   
   
   
    nimble/controller/src/ble_ll_sync.c
   
   
   ```diff
   @@ -2091,7 +2092,7 @@
if (syncsm->flags & BLE_LL_SYNC_SM_FLAG_ADDR_RESOLVED) {
sync_ind[24] |= 1 << 4;
} else {
   -sync_ind[24] |= (syncsm->adv_addr_type == BLE_ADDR_RANDOM) << 4 ;
   +sync_ind[24] |= (syncsm->adv_addr_type == BLE_ADDR_RANDOM) << 4;
}

sync_ind[24] |= BLE_LL_SCA_ENUM << 5;
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] andrzej-kaczmarek opened a new pull request #800: nimble/ll: Add common setting for SCA

2020-04-17 Thread GitBox
andrzej-kaczmarek opened a new pull request #800: nimble/ll: Add common setting 
for SCA
URL: https://github.com/apache/mynewt-nimble/pull/800
 
 
   Currently we have two separate SCA settings: actual SCA as ppm value and
   enumerated one based on ranges of SCA value. This means user needs to
   update both values and they ideally should be in sync.
   
   To make our life easier, we can just have single BLE_LL_SCA setting to
   provide ppm value and enumerated one can be easily determined at build
   time.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2271: hw/drivers/i2s: Add I2S driver for STM32F1 family

2020-04-17 Thread GitBox
apache-mynewt-bot commented on issue #2271: hw/drivers/i2s: Add I2S driver for 
STM32F1 family
URL: https://github.com/apache/mynewt-core/pull/2271#issuecomment-615164869
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] kasjer opened a new pull request #2271: hw/drivers/i2s: Add I2S driver for STM32F1 family

2020-04-17 Thread GitBox
kasjer opened a new pull request #2271: hw/drivers/i2s: Add I2S driver for 
STM32F1 family
URL: https://github.com/apache/mynewt-core/pull/2271
 
 
   Code implements I2S driver for STM32F1xx MCUs that have it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] kasjer commented on a change in pull request #2269: hw/drivers/i2s: Add I2S driver for NRF52 family

2020-04-17 Thread GitBox
kasjer commented on a change in pull request #2269: hw/drivers/i2s: Add I2S 
driver for NRF52 family
URL: https://github.com/apache/mynewt-core/pull/2269#discussion_r410126971
 
 

 ##
 File path: hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c
 ##
 @@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct nrf52_i2s {
+nrfx_i2s_config_t nrfx_i2s_cfg;
+bool running;
+int8_t nrfx_queued_count;
+struct i2s *i2s;
+struct i2s_sample_buffer *nrfx_buffers[2];
+};
+
+static struct nrf52_i2s nrf52_i2s;
+
+static void
+nrfx_add_buffer(struct i2s *i2s, struct i2s_sample_buffer *buffer)
+{
+nrfx_i2s_buffers_t nrfx_buffers = {0};
+nrfx_err_t err;
+
+assert(i2s != NULL);
+if (buffer == NULL) {
+return;
+}
+
+if (i2s->direction == I2S_OUT || i2s->direction == I2S_OUT_IN) {
+nrfx_buffers.p_tx_buffer = buffer->sample_data;
+}
+if (i2s->direction == I2S_IN || i2s->direction == I2S_OUT_IN) {
+nrfx_buffers.p_rx_buffer = buffer->sample_data;
+}
+
+assert(nrf52_i2s.nrfx_queued_count < 2);
+assert(nrf52_i2s.nrfx_buffers[nrf52_i2s.nrfx_queued_count] == NULL);
+
+nrf52_i2s.nrfx_buffers[nrf52_i2s.nrfx_queued_count] = buffer;
+nrf52_i2s.nrfx_queued_count++;
+if (nrf52_i2s.nrfx_queued_count == 1) {
+i2s_driver_state_changed (i2s, I2S_STATE_RUNNING);
+err = nrfx_i2s_start(_buffers, buffer->sample_count * 
i2s->sample_size_in_bytes / 4, 0);
+} else {
+err = nrfx_i2s_next_buffers_set(_buffers);
+}
+
+assert(err == NRFX_SUCCESS);
+}
+
+static void
+feed_nrfx(void)
+{
+struct i2s_sample_buffer *buffer;
+
+buffer = i2s_driver_buffer_get(nrf52_i2s.i2s);
+nrfx_add_buffer(nrf52_i2s.i2s, buffer);
+}
+
+static void
+nrf52_i2s_data_handler(const nrfx_i2s_buffers_t *p_released, uint32_t status)
+{
+struct i2s_sample_buffer *buffer;
+
+if (p_released != NULL &&
+(p_released->p_rx_buffer != NULL || p_released->p_tx_buffer != NULL)) {
+nrf52_i2s.nrfx_queued_count--;
+assert(nrf52_i2s.nrfx_queued_count >= 0);
+buffer = nrf52_i2s.nrfx_buffers[0];
+assert(buffer->sample_data == p_released->p_tx_buffer || 
buffer->sample_data == p_released->p_rx_buffer);
+nrf52_i2s.nrfx_buffers[0] = nrf52_i2s.nrfx_buffers[1];
+nrf52_i2s.nrfx_buffers[1] = NULL;
+i2s_driver_buffer_put(nrf52_i2s.i2s, buffer);
+}
+if (nrf52_i2s.running && nrf52_i2s.nrfx_queued_count < 2) {
+assert(nrf52_i2s.nrfx_buffers[1] == NULL);
+feed_nrfx();
+}
+if (status == NRFX_I2S_STATUS_TRANSFER_STOPPED) {
+i2s_driver_state_changed(nrf52_i2s.i2s, I2S_STATE_STOPPED);
+}
+}
+
+static int
+nrf52_i2s_init(struct i2s *i2s, const struct i2s_cfg *cfg)
+{
+int rc;
+
+nrf52_i2s.i2s = i2s;
+
+NVIC_SetVector(nrfx_get_irq_number(NRF_I2S), (uint32_t) 
nrfx_i2s_irq_handler);
+
+nrf52_i2s.nrfx_i2s_cfg = cfg->nrfx_i2s_cfg;
+switch (cfg->nrfx_i2s_cfg.sample_width) {
+case NRF_I2S_SWIDTH_8BIT:
+i2s->sample_size_in_bytes = 1;
+break;
+case NRF_I2S_SWIDTH_16BIT:
+i2s->sample_size_in_bytes = 2;
+break;
+case NRF_I2S_SWIDTH_24BIT:
+i2s->sample_size_in_bytes = 4;
+break;
+}
+
+i2s->direction = I2S_INVALID;
+if (cfg->nrfx_i2s_cfg.sdin_pin != NRFX_I2S_PIN_NOT_USED) {
+i2s->direction = I2S_IN;
+}
+if (cfg->nrfx_i2s_cfg.sdout_pin != NRFX_I2S_PIN_NOT_USED) {
+i2s->direction |= I2S_OUT;
 
 Review comment:
   Values were designed that way so I2S_IN and I2S_OUT have separate bits and 
it's easier to check if it's input, output or both for duplex mode.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[mynewt-core] branch master updated: hw/mcu/nordic: Remove old entries for ignored files

2020-04-17 Thread janc
This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 09eb98f  hw/mcu/nordic: Remove old entries for ignored files
09eb98f is described below

commit 09eb98f3a39994dc0e15a94d067b28721c92d51c
Author: Szymon Janc 
AuthorDate: Wed Apr 15 14:44:36 2020 +0200

hw/mcu/nordic: Remove old entries for ignored files

Modified copies of those are no longer present in tree.
---
 hw/mcu/nordic/pkg.yml | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/hw/mcu/nordic/pkg.yml b/hw/mcu/nordic/pkg.yml
index 2234d7b..5bb74b5 100644
--- a/hw/mcu/nordic/pkg.yml
+++ b/hw/mcu/nordic/pkg.yml
@@ -28,25 +28,6 @@ pkg.keywords:
 
 pkg.type: sdk
 
-pkg.ign_files.BSP_NRF52:
-- "nrfx_power_clock.c"
-- "nrfx_saadc.c"
-
-pkg.ign_files.BSP_NRF52810:
-- "nrfx_power.c"
-- "nrfx_power_clock.c"
-
-pkg.ign_files.BSP_NRF52811:
-- "nrfx_power.c"
-- "nrfx_power_clock.c"
-
-pkg.ign_files.BSP_NRF52840:
-- "nrfx_power.c"
-- "nrfx_power_clock.c"
-
-pkg.ign_files.BSP_NRF51:
-- "nrfx_power_clock.c"
-
 pkg.ign_dirs:
 - "soc"
 - "templates"



[GitHub] [mynewt-core] sjanc merged pull request #2270: hw/mcu/nordic: Remove old entries for ignored files

2020-04-17 Thread GitBox
sjanc merged pull request #2270: hw/mcu/nordic: Remove old entries for ignored 
files
URL: https://github.com/apache/mynewt-core/pull/2270
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410023250
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
 
 Review comment:
   **BLE_ERR_REM_USER_CONN_TERM**


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410021105
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
+os_time_ms_to_ticks(delay_ms, );
+os_time_delay(ticks);
+scan();
+} else {
+MODLOG_DFLT(INFO,"Connection failed, error code: %i\n",
+event->connect.status);
+}
+break;
+case BLE_GAP_EVENT_DISCONNECT:
+MODLOG_DFLT(INFO,"Disconnected, reason code: %i\n",
+event->disconnect.reason);
+default:
+MODLOG_DFLT(INFO,"Connection event type not supported\n");
+break;
+}
+return 0;
+}
+
+static int
+scan_event(struct ble_gap_event *event, void *arg)
+{
+struct ble_hs_adv_fields parsed_fields;
+memset(_fields, 0, sizeof(parsed_fields));
+
+/*predef_uuid stores information about UUID of device, that we connect to*/
+const uint8_t predef_uuid[16] = {
+0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
+};
+
+switch (event->type) {
+/* advertising report has been received during discovery procedure */
+case BLE_GAP_EVENT_DISC:
+MODLOG_DFLT(INFO, "Advertising report received! Checking UUID...\n");
+ble_hs_adv_parse_fields(_fields, event->disc.data,
+event->disc.length_data);
+/* Predefined UUID is compared to recieved one;
+   if doesn't fit - end procedure and go back to scanning,
+   else - connect. */
+for (int i = 0; i < sizeof(predef_uuid); i++) {
 
 Review comment:
   https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md
   
   local variable shall be on top


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410021918
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
+os_time_ms_to_ticks(delay_ms, );
+os_time_delay(ticks);
+scan();
+} else {
+MODLOG_DFLT(INFO,"Connection failed, error code: %i\n",
+event->connect.status);
+}
+break;
+case BLE_GAP_EVENT_DISCONNECT:
+MODLOG_DFLT(INFO,"Disconnected, reason code: %i\n",
+event->disconnect.reason);
+default:
+MODLOG_DFLT(INFO,"Connection event type not supported\n");
+break;
+}
+return 0;
+}
+
+static int
+scan_event(struct ble_gap_event *event, void *arg)
+{
+struct ble_hs_adv_fields parsed_fields;
+memset(_fields, 0, sizeof(parsed_fields));
+
+/*predef_uuid stores information about UUID of device, that we connect to*/
+const uint8_t predef_uuid[16] = {
+0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
+};
+
+switch (event->type) {
+/* advertising report has been received during discovery procedure */
+case BLE_GAP_EVENT_DISC:
+MODLOG_DFLT(INFO, "Advertising report received! Checking UUID...\n");
+ble_hs_adv_parse_fields(_fields, event->disc.data,
+event->disc.length_data);
+/* Predefined UUID is compared to recieved one;
+   if doesn't fit - end procedure and go back to scanning,
+   else - connect. */
+for (int i = 0; i < sizeof(predef_uuid); i++) {
+if (parsed_fields.uuids128->value[i] != predef_uuid[i]) {
+MODLOG_DFLT(INFO, "doesn't fit\n");
+return 0;
+}
+}
+
+MODLOG_DFLT(INFO, "UUID ");
+for (int i = 0; i < sizeof(predef_uuid); i++) {
+MODLOG_DFLT(INFO, "%d, ", parsed_fields.uuids128->value[i]);
+}
+MODLOG_DFLT(INFO, "fits, connecting... \n");
+ble_gap_disc_cancel();
+ble_gap_connect(g_own_addr_type, &(event->disc.addr), 1,
+NULL, conn_event, NULL);
+break;
+/* discovery procedure has terminated */
+case BLE_GAP_EVENT_DISC_COMPLETE:
+MODLOG_DFLT(INFO,"Code of termination reason: %d\n",
 
 Review comment:
   "Discovery completed, reason: "


This is an automated message from the Apache Git Service.
To respond 

[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410019122
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
+os_time_ms_to_ticks(delay_ms, );
+os_time_delay(ticks);
+scan();
+} else {
+MODLOG_DFLT(INFO,"Connection failed, error code: %i\n",
+event->connect.status);
+}
+break;
+case BLE_GAP_EVENT_DISCONNECT:
+MODLOG_DFLT(INFO,"Disconnected, reason code: %i\n",
+event->disconnect.reason);
+default:
+MODLOG_DFLT(INFO,"Connection event type not supported\n");
+break;
+}
+return 0;
+}
+
+static int
+scan_event(struct ble_gap_event *event, void *arg)
+{
+struct ble_hs_adv_fields parsed_fields;
+memset(_fields, 0, sizeof(parsed_fields));
+
+/*predef_uuid stores information about UUID of device, that we connect to*/
+const uint8_t predef_uuid[16] = {
+0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
+};
+
+switch (event->type) {
+/* advertising report has been received during discovery procedure */
+case BLE_GAP_EVENT_DISC:
+MODLOG_DFLT(INFO, "Advertising report received! Checking UUID...\n");
+ble_hs_adv_parse_fields(_fields, event->disc.data,
+event->disc.length_data);
+/* Predefined UUID is compared to recieved one;
+   if doesn't fit - end procedure and go back to scanning,
+   else - connect. */
+for (int i = 0; i < sizeof(predef_uuid); i++) {
+if (parsed_fields.uuids128->value[i] != predef_uuid[i]) {
+MODLOG_DFLT(INFO, "doesn't fit\n");
+return 0;
+}
+}
+
+MODLOG_DFLT(INFO, "UUID ");
+for (int i = 0; i < sizeof(predef_uuid); i++) {
+MODLOG_DFLT(INFO, "%d, ", parsed_fields.uuids128->value[i]);
+}
+MODLOG_DFLT(INFO, "fits, connecting... \n");
+ble_gap_disc_cancel();
+ble_gap_connect(g_own_addr_type, &(event->disc.addr), 1,
+NULL, conn_event, NULL);
+break;
+/* discovery procedure has terminated */
+case BLE_GAP_EVENT_DISC_COMPLETE:
+MODLOG_DFLT(INFO,"Code of termination reason: %d\n",
+event->disc_complete.reason);
+scan();
+break;
+default:
+MODLOG_DFLT(ERROR, "Discovery event not handled\n");
+break;
+}
+

[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410029832
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
+os_time_ms_to_ticks(delay_ms, );
 
 Review comment:
   os_time_delay(os_time_ms_to_ticks32(2000)); ?
   Also please write comment why it is here.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410022133
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
 
 Review comment:
   nitpick: add empty line after declarations


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410024440
 
 

 ##
 File path: apps/central/syscfg.yml
 ##
 @@ -0,0 +1,25 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Settings this app defines.
+syscfg.defs:
+BLEPRPH_LE_PHY_SUPPORT:
 
 Review comment:
   this seems to be some leftover


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410022355
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
 
 Review comment:
   "fully" not needed :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410026121
 
 

 ##
 File path: apps/central/pkg.yml
 ##
 @@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: "apps/central"
+pkg.type: app
+pkg.description: "Basic central application"
+pkg.author: "Krzysztof Kopyściński 

[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410023999
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
+os_time_ms_to_ticks(delay_ms, );
+os_time_delay(ticks);
+scan();
+} else {
+MODLOG_DFLT(INFO,"Connection failed, error code: %i\n",
+event->connect.status);
+}
+break;
+case BLE_GAP_EVENT_DISCONNECT:
+MODLOG_DFLT(INFO,"Disconnected, reason code: %i\n",
+event->disconnect.reason);
 
 Review comment:
   missing break


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410019532
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
+os_time_ms_to_ticks(delay_ms, );
+os_time_delay(ticks);
+scan();
+} else {
+MODLOG_DFLT(INFO,"Connection failed, error code: %i\n",
+event->connect.status);
+}
+break;
+case BLE_GAP_EVENT_DISCONNECT:
+MODLOG_DFLT(INFO,"Disconnected, reason code: %i\n",
+event->disconnect.reason);
+default:
+MODLOG_DFLT(INFO,"Connection event type not supported\n");
+break;
+}
+return 0;
+}
+
+static int
+scan_event(struct ble_gap_event *event, void *arg)
+{
+struct ble_hs_adv_fields parsed_fields;
+memset(_fields, 0, sizeof(parsed_fields));
+
+/*predef_uuid stores information about UUID of device, that we connect to*/
+const uint8_t predef_uuid[16] = {
+0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
+};
+
+switch (event->type) {
+/* advertising report has been received during discovery procedure */
+case BLE_GAP_EVENT_DISC:
+MODLOG_DFLT(INFO, "Advertising report received! Checking UUID...\n");
+ble_hs_adv_parse_fields(_fields, event->disc.data,
+event->disc.length_data);
+/* Predefined UUID is compared to recieved one;
+   if doesn't fit - end procedure and go back to scanning,
+   else - connect. */
+for (int i = 0; i < sizeof(predef_uuid); i++) {
+if (parsed_fields.uuids128->value[i] != predef_uuid[i]) {
+MODLOG_DFLT(INFO, "doesn't fit\n");
+return 0;
+}
+}
+
+MODLOG_DFLT(INFO, "UUID ");
+for (int i = 0; i < sizeof(predef_uuid); i++) {
+MODLOG_DFLT(INFO, "%d, ", parsed_fields.uuids128->value[i]);
+}
+MODLOG_DFLT(INFO, "fits, connecting... \n");
+ble_gap_disc_cancel();
+ble_gap_connect(g_own_addr_type, &(event->disc.addr), 1,
+NULL, conn_event, NULL);
+break;
+/* discovery procedure has terminated */
+case BLE_GAP_EVENT_DISC_COMPLETE:
+MODLOG_DFLT(INFO,"Code of termination reason: %d\n",
+event->disc_complete.reason);
+scan();
+break;
+default:
+MODLOG_DFLT(ERROR, "Discovery event not handled\n");
+break;
+}
+

[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410024995
 
 

 ##
 File path: nimble/host/include/host/ble_gap.h
 ##
 @@ -1984,6 +1984,8 @@ int ble_gap_set_prefered_default_le_phy(uint8_t 
tx_phys_mask,
  *  - BLE_GAP_LE_PHY_CODED_S8
  *
  * @return   0 on success; nonzero on failure.
+ *
+ * When PHY is successfully changed, phy_updated event is occurs.
 
 Review comment:
   This could go up to the function description.
   
   We can even say what even exactly which is  
BLE_GAP_EVENT_PHY_UPDATE_COMPLETE. 
   
   Also this should go as separate patch


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410020093
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
+os_time_ms_to_ticks(delay_ms, );
+os_time_delay(ticks);
+scan();
+} else {
+MODLOG_DFLT(INFO,"Connection failed, error code: %i\n",
+event->connect.status);
+}
+break;
+case BLE_GAP_EVENT_DISCONNECT:
+MODLOG_DFLT(INFO,"Disconnected, reason code: %i\n",
+event->disconnect.reason);
+default:
+MODLOG_DFLT(INFO,"Connection event type not supported\n");
+break;
+}
+return 0;
+}
+
+static int
+scan_event(struct ble_gap_event *event, void *arg)
+{
+struct ble_hs_adv_fields parsed_fields;
+memset(_fields, 0, sizeof(parsed_fields));
+
+/*predef_uuid stores information about UUID of device, that we connect to*/
+const uint8_t predef_uuid[16] = {
 
 Review comment:
   declarations should be on top as per coding style guidelines


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #796: Apps: central added

2020-04-17 Thread GitBox
rymanluk commented on a change in pull request #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r410023741
 
 

 ##
 File path: apps/central/src/main.c
 ##
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+static void
+ble_app_set_addr(void)
+{
+ble_addr_t addr;
+int rc;
+
+/* generate new non-resolvable private address */
+rc = ble_hs_id_gen_rnd(0, );
+assert(rc == 0);
+
+/* set generated address */
+rc = ble_hs_id_set_rnd(addr.val);
+assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+int rc;
+switch (event->type) {
+case BLE_GAP_EVENT_CONNECT:
+if (event->connect.status == 0) {
+MODLOG_DFLT(INFO,"Connection was fully established\n");
+/* Set PHY for established conection */
+rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_2M_MASK,
+ BLE_GAP_LE_PHY_CODED_ANY);
+if (rc == 0) {
+MODLOG_DFLT(INFO, "rx and tx PHYs set to 2M\n");
+} else {
+MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+}
+ble_gap_terminate(event->connect.conn_handle, 0x13);
 
 Review comment:
   not sure what is a purpose of this app, but if we are changing PHY, maybe 
before disconnecting we could wait until PHY is really changed?
   
   BLE_GAP_EVENT_PHY_UPDATE_COMPLETE


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services