Merge pull request #6461 from ARMmbed/release-candidate

Release candidate for mbed-os-5.8.1
pull/6414/merge mbed-os-5.8.1
Martin Kojtal 2018-03-27 17:41:03 +02:00 committed by GitHub
commit addec7ba10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
289 changed files with 24718 additions and 21735 deletions

View File

@ -11,11 +11,17 @@
<!-- <!--
Required Required
Please tick one of the following types Please tick only one of the following types. Do not tick more or change the layout.
[X] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change
--> -->
- [ ] Fix [ ] Fix
- [ ] Refactor [ ] Refactor
- [ ] New target [ ] New target
- [ ] Feature [ ] Feature
- [ ] Breaking change [ ] Breaking change

View File

@ -31,7 +31,7 @@ before_install:
# Setup ppa to make sure arm-none-eabi-gcc is correct version # Setup ppa to make sure arm-none-eabi-gcc is correct version
- sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa - sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
# Loop until update succeeds (timeouts can occur) # Loop until update succeeds (timeouts can occur)
- while [ -n "$(sudo apt-get update 2>&1 |grep Failed)" ]; do :; done - travis_retry $(! sudo apt-get update 2>&1 |grep Failed)
after_success: after_success:
- bash -c "$STATUS" success "Local $NAME testing has passed" - bash -c "$STATUS" success "Local $NAME testing has passed"
@ -115,6 +115,24 @@ matrix:
- python tools/make.py -t GCC_ARM -m DISCO_F401VC --source=. --build=BUILD/DISCO_F401VC/GCC_ARM -j0 - python tools/make.py -t GCC_ARM -m DISCO_F401VC --source=. --build=BUILD/DISCO_F401VC/GCC_ARM -j0
# Run local equeue tests # Run local equeue tests
- make -C $EVENTS/equeue test - make -C $EVENTS/equeue test
# Run profiling tests
- make -C $EVENTS/equeue prof | tee prof
after_success:
# update status if we succeeded, compare with master if possible
- |
CURR=$(grep -o '[0-9]\+ cycles' prof | awk '{sum += $1} END {print sum}')
PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
| .statuses[] | select(.context == \"travis-ci/$NAME\").description
| capture(\"runtime is (?<runtime>[0-9]+)\").runtime" \
|| echo 0)
STATUSM="Passed, runtime is ${CURR} cycles"
if [ "$PREV" -ne 0 ]
then
STATUSM="$STATUSM ($(python -c "print '%+d' % ($CURR-$PREV)") cycles)"
fi
- bash -c "$STATUS" success "$STATUSM"
- env: - env:
- NAME=littlefs - NAME=littlefs
@ -187,37 +205,3 @@ matrix:
STATUSM="$STATUSM ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)" STATUSM="$STATUSM ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
fi fi
- bash -c "$STATUS" success "$STATUSM" - bash -c "$STATUS" success "$STATUSM"
- &mbed-2
env: NAME=mbed2-NXP
install:
# Install dependencies
- export GCC_DIR=$HOME/gcc-arm-none-eabi-6-2017-q2-update
- export GCC_ARCHIVE=$HOME/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2
- export GCC_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2?revision=2cc92fb5-3e0e-402d-9197-bdfc8224d8a5?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,6-2017-q2-update
- if [ ! -e $GCC_DIR/bin/arm-none-eabi-gcc ]; then wget $GCC_URL -O $GCC_ARCHIVE; tar xfj $GCC_ARCHIVE -C $HOME; fi
- export PATH=$PATH:$GCC_DIR/bin
- pip install -r requirements.txt
# Print versions we use
- arm-none-eabi-gcc --version
- python --version
before_script:
# Create BUILD directory for tests
- mkdir BUILD
script:
# Run local mbed 2 testing
- python -u tools/build_travis.py --vendor "${NAME#mbed2-}"
- <<: *mbed-2
env: NAME=mbed2-STM
- <<: *mbed-2
env: NAME=mbed2-NORDIC
- <<: *mbed-2
env: NAME=mbed2-SILICON_LABS
- <<: *mbed-2
env: NAME=mbed2-MAXIM
- <<: *mbed-2
env: NAME=mbed2-ATMEL
- <<: *mbed-2
env: NAME=mbed2-NUVOTON
- <<: *mbed-2
env: NAME=mbed2-RENESAS

View File

@ -15,138 +15,79 @@
*/ */
#if !DEVICE_LOWPOWERTIMER #if !DEVICE_LOWPOWERTIMER
#error [NOT_SUPPORTED] Low power timer not supported for this target #error [NOT_SUPPORTED] Low power timer not supported for this target
#endif #endif
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "utest/utest.h" #include "utest/utest.h"
#include "unity/unity.h" #include "unity/unity.h"
#include "greentea-client/test_env.h" #include "../timeout/timeout_tests.h"
#include "mbed.h"
using namespace utest::v1; using namespace utest::v1;
volatile static bool complete; utest::v1::status_t greentea_failure_handler(const Case * const source, const failure_t reason)
static LowPowerTimeout lpt;
/* Timeouts are quite arbitrary due to large number of boards with varying level of accuracy */
#define LONG_TIMEOUT (100000)
#define SHORT_TIMEOUT (600)
void cb_done() {
complete = true;
}
#if DEVICE_SLEEP
void lp_timeout_1s_deepsleep(void)
{ {
complete = false;
LowPowerTimer timer;
/*
* Since deepsleep() may shut down the UART peripheral, we wait for 10ms
* to allow for hardware serial buffers to completely flush.
* This should be replaced with a better function that checks if the
* hardware buffers are empty. However, such an API does not exist now,
* so we'll use the wait_ms() function for now.
*/
wait_ms(10);
/*
* We use here the low power timer instead of microsecond timer for start and
* end because the microseconds timer might be disable during deepsleep.
*/
timer.start();
lpt.attach(&cb_done, 1);
/* Make sure deepsleep is allowed, to go to deepsleep */
bool deep_sleep_allowed = sleep_manager_can_deep_sleep();
TEST_ASSERT_TRUE_MESSAGE(deep_sleep_allowed, "Deep sleep should be allowed");
sleep();
while (!complete);
/* It takes longer to wake up from deep sleep */
TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, timer.read_us());
TEST_ASSERT_TRUE(complete);
}
void lp_timeout_1s_sleep(void)
{
complete = false;
Timer timer;
timer.start();
sleep_manager_lock_deep_sleep();
lpt.attach(&cb_done, 1);
bool deep_sleep_allowed = sleep_manager_can_deep_sleep();
TEST_ASSERT_FALSE_MESSAGE(deep_sleep_allowed, "Deep sleep should be disallowed");
sleep();
while (!complete);
sleep_manager_unlock_deep_sleep();
TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, timer.read_us());
TEST_ASSERT_TRUE(complete);
}
#endif /* DEVICE_SLEEP */
void lp_timeout_us(uint32_t delay_us, uint32_t tolerance)
{
complete = false;
Timer timer;
timer.start();
lpt.attach_us(&cb_done, delay_us);
while (!complete);
/* Using RTC which is less accurate */
TEST_ASSERT_UINT32_WITHIN(tolerance, delay_us, timer.read_us());
TEST_ASSERT_TRUE(complete);
}
void lp_timeout_5s(void)
{
lp_timeout_us(5000000, LONG_TIMEOUT);
}
void lp_timeout_1s(void)
{
lp_timeout_us(1000000, LONG_TIMEOUT);
}
void lp_timeout_1ms(void)
{
lp_timeout_us(1000, SHORT_TIMEOUT);
}
void lp_timeout_500us(void)
{
lp_timeout_us(500, SHORT_TIMEOUT);
}
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason); greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
Case cases[] = { Case cases[] = {
Case("500us LowPowerTimeout", lp_timeout_500us, greentea_failure_handler), Case("Callback called once (attach)", test_single_call<AttachTester<LowPowerTimeout> >),
Case("1ms LowPowerTimeout", lp_timeout_1ms, greentea_failure_handler), Case("Callback called once (attach_us)", test_single_call<AttachUSTester<LowPowerTimeout> >),
Case("1sec LowPowerTimeout", lp_timeout_1s, greentea_failure_handler),
Case("5sec LowPowerTimeout", lp_timeout_5s, greentea_failure_handler), Case("Callback not called when cancelled (attach)", test_cancel<AttachTester<LowPowerTimeout> >),
Case("Callback not called when cancelled (attach_us)", test_cancel<AttachUSTester<LowPowerTimeout> >),
Case("Callback override (attach)", test_override<AttachTester<LowPowerTimeout> >),
Case("Callback override (attach_us)", test_override<AttachUSTester<LowPowerTimeout> >),
Case("Multiple timeouts running in parallel (attach)", test_multiple<AttachTester<LowPowerTimeout> >),
Case("Multiple timeouts running in parallel (attach_us)", test_multiple<AttachUSTester<LowPowerTimeout> >),
Case("Zero delay (attach)", test_no_wait<AttachTester<LowPowerTimeout> >),
Case("Zero delay (attach_us)", test_no_wait<AttachUSTester<LowPowerTimeout> >),
Case("10 ms delay accuracy (attach)", test_delay_accuracy<AttachTester<LowPowerTimeout>, 10000, SHORT_DELTA_US>,
greentea_failure_handler),
Case("10 ms delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<LowPowerTimeout>, 10000, SHORT_DELTA_US>,
greentea_failure_handler),
Case("1 s delay accuracy (attach)", test_delay_accuracy<AttachTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("1 s delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("5 s delay accuracy (attach)", test_delay_accuracy<AttachTester<LowPowerTimeout>, 5000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("5 s delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<LowPowerTimeout>, 5000000, LONG_DELTA_US>,
greentea_failure_handler),
#if DEVICE_SLEEP #if DEVICE_SLEEP
Case("1sec LowPowerTimeout from sleep", lp_timeout_1s_sleep, greentea_failure_handler), Case("1 s delay during sleep (attach)", test_sleep<AttachTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
Case("1sec LowPowerTimeout from deepsleep", lp_timeout_1s_deepsleep, greentea_failure_handler), greentea_failure_handler),
#endif /* DEVICE_SLEEP */ Case("1 s delay during sleep (attach_us)", test_sleep<AttachUSTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("1 s delay during deepsleep (attach)", test_deepsleep<AttachTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("1 s delay during deepsleep (attach_us)", test_deepsleep<AttachUSTester<LowPowerTimeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
#endif
Case("Timing drift (attach)", test_drift<AttachTester<LowPowerTimeout> >),
Case("Timing drift (attach_us)", test_drift<AttachUSTester<LowPowerTimeout> >),
}; };
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
GREENTEA_SETUP(20, "default_auto"); {
GREENTEA_SETUP(240, "timing_drift_auto");
return greentea_test_setup_handler(number_of_cases); return greentea_test_setup_handler(number_of_cases);
} }
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
int main() { int main()
{
Harness::run(specification); Harness::run(specification);
} }

View File

@ -1,91 +1,83 @@
/* /* mbed Microcontroller Library
* Copyright (c) 2013-2016, ARM Limited, All Rights Reserved * Copyright (c) 2017 ARM Limited
* SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may * Licensed under the Apache License, Version 2.0 (the "License");
* not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS,
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/*
* Tests is to measure the accuracy of Timeout over a period of time
*
*
* 1) DUT would start to update callback_trigger_count every milli sec
* 2) Host would query what is current count base_time, Device responds by the callback_trigger_count
* 3) Host after waiting for measurement stretch. It will query for device time again final_time.
* 4) Host computes the drift considering base_time, final_time, transport delay and measurement stretch
* 5) Finally host send the results back to device pass/fail based on tolerance.
* 6) More details on tests can be found in timing_drift_auto.py
*
*/
#include "mbed.h" #include "mbed.h"
#include "greentea-client/test_env.h" #include "greentea-client/test_env.h"
#include "utest/utest.h" #include "utest/utest.h"
#include "unity/unity.h" #include "unity/unity.h"
#include "timeout_tests.h"
using namespace utest::v1; using namespace utest::v1;
#define PERIOD_US 10000 utest::v1::status_t greentea_failure_handler(const Case * const source, const failure_t reason)
{
volatile int ticker_count = 0; greentea_case_failure_abort_handler(source, reason);
volatile uint32_t callback_trigger_count = 0; return STATUS_CONTINUE;
static const int test_timeout = 240;
Timeout timeout;
void set_incremeant_count() {
timeout.attach_us(set_incremeant_count, PERIOD_US);
++callback_trigger_count;
} }
void test_case_timeout() { Case cases[] = {
Case("Callback called once (attach)", test_single_call<AttachTester<Timeout> >),
Case("Callback called once (attach_us)", test_single_call<AttachUSTester<Timeout> >),
char _key[11] = { }; Case("Callback not called when cancelled (attach)", test_cancel<AttachTester<Timeout> >),
char _value[128] = { }; Case("Callback not called when cancelled (attach_us)", test_cancel<AttachUSTester<Timeout> >),
int expected_key = 1;
uint8_t results_size = 0;
greentea_send_kv("timing_drift_check_start", 0); Case("Callback override (attach)", test_override<AttachTester<Timeout> >),
timeout.attach_us(set_incremeant_count, PERIOD_US); Case("Callback override (attach_us)", test_override<AttachUSTester<Timeout> >),
// wait for 1st signal from host Case("Multiple timeouts running in parallel (attach)", test_multiple<AttachTester<Timeout> >),
do { Case("Multiple timeouts running in parallel (attach_us)", test_multiple<AttachUSTester<Timeout> >),
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
expected_key = strcmp(_key, "base_time");
} while (expected_key);
greentea_send_kv(_key, callback_trigger_count * PERIOD_US); Case("Zero delay (attach)", test_no_wait<AttachTester<Timeout> >),
Case("Zero delay (attach_us)", test_no_wait<AttachUSTester<Timeout> >),
// wait for 2nd signal from host Case("10 ms delay accuracy (attach)", test_delay_accuracy<AttachTester<Timeout>, 10000, SHORT_DELTA_US>,
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_failure_handler),
greentea_send_kv(_key, callback_trigger_count * PERIOD_US); Case("10 ms delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<Timeout>, 10000, SHORT_DELTA_US>,
greentea_failure_handler),
//get the results from host Case("1 s delay accuracy (attach)", test_delay_accuracy<AttachTester<Timeout>, 1000000, LONG_DELTA_US>,
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_failure_handler),
Case("1 s delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<Timeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key,"Host side script reported a fail..."); Case("5 s delay accuracy (attach)", test_delay_accuracy<AttachTester<Timeout>, 5000000, LONG_DELTA_US>,
} greentea_failure_handler),
Case("5 s delay accuracy (attach_us)", test_delay_accuracy<AttachUSTester<Timeout>, 5000000, LONG_DELTA_US>,
greentea_failure_handler),
// Test casess #if DEVICE_SLEEP
Case cases[] = { Case("Timers: toggle on/off", test_case_timeout), }; Case("1 s delay during sleep (attach)", test_sleep<AttachTester<Timeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
Case("1 s delay during sleep (attach_us)", test_sleep<AttachUSTester<Timeout>, 1000000, LONG_DELTA_US>,
greentea_failure_handler),
#endif
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { Case("Timing drift (attach)", test_drift<AttachTester<Timeout> >),
GREENTEA_SETUP(test_timeout, "timing_drift_auto"); Case("Timing drift (attach_us)", test_drift<AttachUSTester<Timeout> >),
};
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
{
GREENTEA_SETUP(240, "timing_drift_auto");
return greentea_test_setup_handler(number_of_cases); return greentea_test_setup_handler(number_of_cases);
} }
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
int main() { int main()
{
Harness::run(specification); Harness::run(specification);
} }

View File

@ -0,0 +1,415 @@
/* mbed Microcontroller Library
* Copyright (c) 2017 ARM Limited
*
* 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 the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_TIMEOUT_TESTS_H
#define MBED_TIMEOUT_TESTS_H
#include "mbed.h"
#include "unity/unity.h"
#define NUM_TIMEOUTS 16
#define DRIFT_TEST_PERIOD_US 10000
const float TEST_DELAY_S = 0.01;
const uint32_t TEST_DELAY_MS = 1000.0F * TEST_DELAY_S;
const us_timestamp_t TEST_DELAY_US = 1000000.0F * TEST_DELAY_S;
/* Timeouts are quite arbitrary due to large number of boards with varying level of accuracy */
#define LONG_DELTA_US (100000)
#define SHORT_DELTA_US (2000)
void sem_callback(Semaphore *sem)
{
sem->release();
}
void cnt_callback(volatile uint32_t *cnt)
{
(*cnt)++;
}
template<typename TimeoutType>
class AttachTester: public TimeoutType {
public:
void attach_callback(Callback<void()> func, us_timestamp_t delay_us)
{
TimeoutType::attach(func, (float) delay_us / 1000000.0f);
}
};
template<typename TimeoutType>
class AttachUSTester: public TimeoutType {
public:
void attach_callback(Callback<void()> func, us_timestamp_t delay_us)
{
TimeoutType::attach_us(func, delay_us);
}
};
/** Template for tests: callback called once
*
* Test callback called once
* Given a Timeout object with a callback attached with @a attach()
* When given time elapses
* Then the callback is called exactly one time
*
* Test callback called once
* Given a Timeout object with a callback attached with @a attach_us()
* When given time elapses
* Then the callback is called exactly one time
*/
template<typename T>
void test_single_call(void)
{
Semaphore sem(0, 1);
T timeout;
timeout.attach_callback(mbed::callback(sem_callback, &sem), TEST_DELAY_US);
int32_t sem_slots = sem.wait(0);
TEST_ASSERT_EQUAL(0, sem_slots);
sem_slots = sem.wait(TEST_DELAY_MS + 1);
TEST_ASSERT_EQUAL(1, sem_slots);
sem_slots = sem.wait(TEST_DELAY_MS + 1);
TEST_ASSERT_EQUAL(0, sem_slots);
timeout.detach();
}
/** Template for tests: callback not called when cancelled
*
* Test callback not called when cancelled
* Given a Timeout object with a callback attached with @a attach()
* When the callback is detached before being called
* Then the callback is never called
*
* Test callback not called when cancelled
* Given a Timeout object with a callback attached with @a attach_us()
* When the callback is detached before being called
* Then the callback is never called
*/
template<typename T>
void test_cancel(void)
{
Semaphore sem(0, 1);
T timeout;
timeout.attach_callback(mbed::callback(sem_callback, &sem), 2.0f * TEST_DELAY_US);
int32_t sem_slots = sem.wait(TEST_DELAY_MS);
TEST_ASSERT_EQUAL(0, sem_slots);
timeout.detach();
sem_slots = sem.wait(TEST_DELAY_MS + 1);
TEST_ASSERT_EQUAL(0, sem_slots);
}
/** Template for tests: callback override
*
* Test callback override
* Given a Timeout object with a callback attached with @a attach()
* When another callback is attached before first one is called
* and second callback's delay elapses
* Then the second callback is called
* and the first callback is never called
*
* Test callback override
* Given a Timeout object with a callback attached with @a attach_us()
* When another callback is attached before first one is called
* and second callback's delay elapses
* Then the second callback is called
* and the first callback is never called
*/
template<typename T>
void test_override(void)
{
Semaphore sem1(0, 1);
Semaphore sem2(0, 1);
T timeout;
timeout.attach_callback(mbed::callback(sem_callback, &sem1), 2.0f * TEST_DELAY_US);
int32_t sem_slots = sem1.wait(TEST_DELAY_MS);
TEST_ASSERT_EQUAL(0, sem_slots);
timeout.attach_callback(mbed::callback(sem_callback, &sem2), 2.0f * TEST_DELAY_US);
sem_slots = sem2.wait(2 * TEST_DELAY_MS + 1);
TEST_ASSERT_EQUAL(1, sem_slots);
sem_slots = sem1.wait(0);
TEST_ASSERT_EQUAL(0, sem_slots);
timeout.detach();
}
/** Template for tests: multiple Timeouts
*
* Test multiple Timeouts
* Given multiple separate Timeout objects
* When a callback is attached to all of these Timeout objects with @a attach()
* and delay for every Timeout elapses
* Then all callbacks are called
*
* Test multiple Timeouts
* Given multiple separate Timeout objects
* When a callback is attached to all of these Timeout objects with @a attach_us()
* and delay for every Timeout elapses
* Then all callbacks are called
*/
template<typename T>
void test_multiple(void)
{
volatile uint32_t callback_count = 0;
T timeouts[NUM_TIMEOUTS];
for (size_t i = 0; i < NUM_TIMEOUTS; i++) {
timeouts[i].attach_callback(mbed::callback(cnt_callback, &callback_count), TEST_DELAY_US);
}
Thread::wait(TEST_DELAY_MS + 1);
TEST_ASSERT_EQUAL(NUM_TIMEOUTS, callback_count);
}
/** Template for tests: zero delay
*
* Test zero delay
* Given a Timeout object
* When a callback is attached with 0.0 s delay, with @a attach()
* Then the callback is called instantly
*
* Test zero delay
* Given a Timeout object
* When a callback is attached with 0.0 s delay, with @a attach_us()
* Then the callback is called instantly
*/
template<typename T>
void test_no_wait(void)
{
Semaphore sem(0, 1);
T timeout;
timeout.attach_callback(mbed::callback(sem_callback, &sem), 0ULL);
int32_t sem_slots = sem.wait(0);
TEST_ASSERT_EQUAL(1, sem_slots);
timeout.detach();
}
/** Template for tests: accuracy of timeout delay
*
* Test delay accuracy
* Given a Timeout object with a callback attached with @a attach()
* When the callback is called
* Then elapsed time matches given delay
*
* Test delay accuracy
* Given a Timeout object with a callback attached with @a attach_us()
* When the callback is called
* Then elapsed time matches given delay
*/
template<typename T, us_timestamp_t delay_us, us_timestamp_t delta_us>
void test_delay_accuracy(void)
{
Semaphore sem(0, 1);
T timeout;
Timer timer;
timer.start();
timeout.attach_callback(mbed::callback(sem_callback, &sem), delay_us);
int32_t sem_slots = sem.wait(osWaitForever);
timer.stop();
TEST_ASSERT_EQUAL(1, sem_slots);
TEST_ASSERT_UINT64_WITHIN(delta_us, delay_us, timer.read_high_resolution_us());
timeout.detach();
}
#if DEVICE_SLEEP
/** Template for tests: timeout during sleep
*
* Test timeout during sleep
* Given a Timeout object with a callback attached with @a attach()
* and the uC in a sleep mode
* When given delay elapses
* Then the callback is called
* and elapsed time matches given delay
*
* Test timeout during sleep
* Given a Timeout object with a callback attached with @a attach_us()
* and the uC in a sleep mode
* When given delay elapses
* Then the callback is called
* and elapsed time matches given delay
*/
template<typename T, us_timestamp_t delay_us, us_timestamp_t delta_us>
void test_sleep(void)
{
Semaphore sem(0, 1);
T timeout;
Timer timer;
sleep_manager_lock_deep_sleep();
timer.start();
timeout.attach_callback(mbed::callback(sem_callback, &sem), delay_us);
bool deep_sleep_allowed = sleep_manager_can_deep_sleep();
TEST_ASSERT_FALSE_MESSAGE(deep_sleep_allowed, "Deep sleep should be disallowed");
while (sem.wait(0) != 1) {
sleep();
}
timer.stop();
sleep_manager_unlock_deep_sleep();
TEST_ASSERT_UINT64_WITHIN(delta_us, delay_us, timer.read_high_resolution_us());
timeout.detach();
}
#if DEVICE_LOWPOWERTIMER
/** Template for tests: timeout during deepsleep
*
* Test timeout during deepsleep
* Given a LowPowerTimeout object with a callback attached with @a attach()
* and the uC in a deepsleep mode
* When given delay elapses
* Then the callback is called
* and elapsed time matches given delay
*
* Test timeout during deepsleep
* Given a LowPowerTimeout object with a callback attached with @a attach_us()
* and the uC in a deepsleep mode
* When given delay elapses
* Then the callback is called
* and elapsed time matches given delay
*/
template<typename T, us_timestamp_t delay_us, us_timestamp_t delta_us>
void test_deepsleep(void)
{
Semaphore sem(0, 1);
T timeout;
/*
* We use here the low power timer instead of microsecond timer for start and
* end because the microseconds timer might be disabled during deepsleep.
*/
LowPowerTimer timer;
/*
* Since deepsleep() may shut down the UART peripheral, we wait for 10ms
* to allow for hardware serial buffers to completely flush.
* This should be replaced with a better function that checks if the
* hardware buffers are empty. However, such an API does not exist now,
* so we'll use the wait_ms() function for now.
*/
wait_ms(10);
timer.start();
timeout.attach_callback(mbed::callback(sem_callback, &sem), delay_us);
bool deep_sleep_allowed = sleep_manager_can_deep_sleep();
TEST_ASSERT_TRUE_MESSAGE(deep_sleep_allowed, "Deep sleep should be allowed");
while (sem.wait(0) != 1) {
sleep();
}
timer.stop();
TEST_ASSERT_UINT64_WITHIN(delta_us, delay_us, timer.read_high_resolution_us());
timeout.detach();
}
#endif
#endif
template<typename TimeoutTesterType>
class TimeoutDriftTester {
public:
TimeoutDriftTester(us_timestamp_t period = 1000) :
_callback_count(0), _period(period), _timeout()
{
}
void reschedule_callback(void)
{
_timeout.attach_callback(mbed::callback(this, &TimeoutDriftTester::reschedule_callback), _period);
_callback_count++;
}
void detach_callback(void)
{
_timeout.detach();
}
uint32_t get_callback_count(void)
{
return _callback_count;
}
private:
volatile uint32_t _callback_count;
us_timestamp_t _period;
TimeoutTesterType _timeout;
};
/** Template for tests: accuracy of timeout delay scheduled repeatedly
*
* Test time drift -- device part
* Given a Timeout object with a callback repeatedly attached with @a attach()
* When the testing host computes test duration based on values received from uC
* Then computed time and actual time measured by host are equal within given tolerance
*
* Test time drift -- device part
* Given a Timeout object with a callback repeatedly attached with @a attach_us()
* When the testing host computes test duration based on values received from uC
* Then computed time and actual time measured by host are equal within given tolerance
*
* Original description:
* 1) DUT would start to update callback_trigger_count every milli sec
* 2) Host would query what is current count base_time, Device responds by the callback_trigger_count
* 3) Host after waiting for measurement stretch. It will query for device time again final_time.
* 4) Host computes the drift considering base_time, final_time, transport delay and measurement stretch
* 5) Finally host send the results back to device pass/fail based on tolerance.
* 6) More details on tests can be found in timing_drift_auto.py
*/
template<typename T>
void test_drift(void)
{
char _key[11] = { };
char _value[128] = { };
int expected_key = 1;
TimeoutDriftTester<T> timeout(DRIFT_TEST_PERIOD_US);
greentea_send_kv("timing_drift_check_start", 0);
timeout.reschedule_callback();
// wait for 1st signal from host
do {
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
expected_key = strcmp(_key, "base_time");
} while (expected_key);
greentea_send_kv(_key, timeout.get_callback_count() * DRIFT_TEST_PERIOD_US);
// wait for 2nd signal from host
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
greentea_send_kv(_key, timeout.get_callback_count() * DRIFT_TEST_PERIOD_US);
timeout.detach_callback();
//get the results from host
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key, "Host script reported a failure");
}
#endif

View File

@ -279,7 +279,9 @@ Case cases[] = {
Case("Flash - erase sector", flash_erase_sector_test), Case("Flash - erase sector", flash_erase_sector_test),
Case("Flash - program page", flash_program_page_test), Case("Flash - program page", flash_program_page_test),
Case("Flash - buffer alignment test", flash_buffer_alignment_test), Case("Flash - buffer alignment test", flash_buffer_alignment_test),
#ifndef MCU_NRF52
Case("Flash - clock and cache test", flash_clock_and_cache_test), Case("Flash - clock and cache test", flash_clock_and_cache_test),
#endif
}; };
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {

View File

@ -2,7 +2,7 @@
#define THE_ANSWER 42 #define THE_ANSWER 42
// Tests for static asserts in different contexts // Tests for static asserts in different contexts
// multiple asserts are used to garuntee no conflicts occur in generated labels // multiple asserts are used to guarantee no conflicts occur in generated labels
// Test for static asserts in global context // Test for static asserts in global context
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),

View File

@ -2,7 +2,7 @@
#define THE_ANSWER 42 #define THE_ANSWER 42
// Tests for static asserts in different contexts // Tests for static asserts in different contexts
// multiple asserts are used to garuntee no conflicts occur in generated labels // multiple asserts are used to guarantee no conflicts occur in generated labels
// Test for static asserts in global context // Test for static asserts in global context
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),

View File

@ -34,7 +34,7 @@ class UDPEchoClientHandler(BaseRequestHandler):
data, sock = self.request data, sock = self.request
pattern = [ord(d) << 4 for d in data] pattern = [ord(d) << 4 for d in data]
# Each byte in request indicates size of packet to recieve # Each byte in request indicates size of packet to receive
# Each packet size is shifted over by 4 to fit in a byte, which # Each packet size is shifted over by 4 to fit in a byte, which
# avoids any issues with endianess or decoding # avoids any issues with endianess or decoding
for packet in pattern: for packet in pattern:

View File

@ -226,7 +226,7 @@ void test_tcp_packet_pressure()
} }
} }
// Verify recieved data // Verify received data
while (rx_count < size) { while (rx_count < size) {
int rd = sock.recv(buffer, buffer_size); int rd = sock.recv(buffer, buffer_size);
TEST_ASSERT(rd > 0 || rd == NSAPI_ERROR_WOULD_BLOCK); TEST_ASSERT(rd > 0 || rd == NSAPI_ERROR_WOULD_BLOCK);

View File

@ -232,7 +232,7 @@ public:
} }
} }
// Verify recieved data // Verify received data
while (rx_count < size) { while (rx_count < size) {
int rd = sock.recv(buffer, buffer_size); int rd = sock.recv(buffer, buffer_size);
TEST_ASSERT(rd > 0 || rd == NSAPI_ERROR_WOULD_BLOCK); TEST_ASSERT(rd > 0 || rd == NSAPI_ERROR_WOULD_BLOCK);

View File

@ -222,7 +222,7 @@ void test_udp_packet_pressure()
} }
} }
// Prioritize recieving over sending packets to avoid flooding // Prioritize receiving over sending packets to avoid flooding
// the network while handling erronous packets // the network while handling erronous packets
while (rx_count < size) { while (rx_count < size) {
int rd = sock.recvfrom(NULL, buffer, buffer_size); int rd = sock.recvfrom(NULL, buffer, buffer_size);

View File

@ -229,7 +229,7 @@ public:
} }
} }
// Prioritize recieving over sending packets to avoid flooding // Prioritize receiving over sending packets to avoid flooding
// the network while handling erronous packets // the network while handling erronous packets
while (rx_count < size) { while (rx_count < size) {
int rd = sock.recvfrom(NULL, buffer, buffer_size); int rd = sock.recvfrom(NULL, buffer, buffer_size);

View File

@ -2070,6 +2070,7 @@ PREDEFINED = DOXYGEN_ONLY \
DEVICE_I2CSLAVE \ DEVICE_I2CSLAVE \
DEVICE_I2C_ASYNCH \ DEVICE_I2C_ASYNCH \
DEVICE_INTERRUPTIN \ DEVICE_INTERRUPTIN \
DEVICE_ITM \
DEVICE_LOWPOWERTIMER \ DEVICE_LOWPOWERTIMER \
DEVICE_PORTIN \ DEVICE_PORTIN \
DEVICE_PORTINOUT \ DEVICE_PORTINOUT \

View File

@ -6,7 +6,7 @@
"SEARCH_INCLUDES": "YES", "SEARCH_INCLUDES": "YES",
"INCLUDE_PATH": "", "INCLUDE_PATH": "",
"INCLUDE_FILE_PATTERNS": "", "INCLUDE_FILE_PATTERNS": "",
"PREDEFINED": "DOXYGEN_ONLY DEVICE_ANALOGIN DEVICE_ANALOGOUT DEVICE_CAN DEVICE_ETHERNET DEVICE_EMAC DEVICE_FLASH DEVICE_I2C DEVICE_I2CSLAVE DEVICE_I2C_ASYNCH DEVICE_INTERRUPTIN DEVICE_LOWPOWERTIMER DEVICE_PORTIN DEVICE_PORTINOUT DEVICE_PORTOUT DEVICE_PWMOUT DEVICE_RTC DEVICE_TRNG DEVICE_SERIAL DEVICE_SERIAL_ASYNCH DEVICE_SERIAL_FC DEVICE_SLEEP DEVICE_SPI DEVICE_SPI_ASYNCH DEVICE_SPISLAVE DEVICE_STORAGE \"MBED_DEPRECATED_SINCE(f, g)=\" \"MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, M)=\" \"MBED_DEPRECATED(s)=\"", "PREDEFINED": "DOXYGEN_ONLY DEVICE_ANALOGIN DEVICE_ANALOGOUT DEVICE_CAN DEVICE_ETHERNET DEVICE_EMAC DEVICE_FLASH DEVICE_I2C DEVICE_I2CSLAVE DEVICE_I2C_ASYNCH DEVICE_INTERRUPTIN DEVICE_ITM DEVICE_LOWPOWERTIMER DEVICE_PORTIN DEVICE_PORTINOUT DEVICE_PORTOUT DEVICE_PWMOUT DEVICE_RTC DEVICE_TRNG DEVICE_SERIAL DEVICE_SERIAL_ASYNCH DEVICE_SERIAL_FC DEVICE_SLEEP DEVICE_SPI DEVICE_SPI_ASYNCH DEVICE_SPISLAVE DEVICE_STORAGE \"MBED_DEPRECATED_SINCE(f, g)=\" \"MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, M)=\" \"MBED_DEPRECATED(s)=\"",
"EXPAND_AS_DEFINED": "", "EXPAND_AS_DEFINED": "",
"SKIP_FUNCTION_MACROS": "NO", "SKIP_FUNCTION_MACROS": "NO",
"EXCLUDE_PATTERNS": "*/tools/* */targets/* */features/mbedtls/* */features/storage/* */features/unsupported/* */BUILD/* */rtos/TARGET_CORTEX/rtx*/* */cmsis/* */features/FEATURE_COMMON_PAL/* */features/FEATURE_LWIP/* */features/FEATURE_UVISOR/* */features/nanostack/* */ble/generic/* */ble/pal/*" "EXCLUDE_PATTERNS": "*/tools/* */targets/* */features/mbedtls/* */features/storage/* */features/unsupported/* */BUILD/* */rtos/TARGET_CORTEX/rtx*/* */cmsis/* */features/FEATURE_COMMON_PAL/* */features/FEATURE_LWIP/* */features/FEATURE_UVISOR/* */features/nanostack/* */ble/generic/* */ble/pal/*"

View File

@ -98,7 +98,7 @@ public:
*/ */
int send(); int send();
/** Recevies an arrived ethernet packet. /** Receives an arrived ethernet packet.
* *
* Receiving an ethernet packet will drop the last received ethernet packet * Receiving an ethernet packet will drop the last received ethernet packet
* and make a new ethernet packet ready to read. * and make a new ethernet packet ready to read.
@ -110,7 +110,7 @@ public:
*/ */
int receive(); int receive();
/** Read from an recevied ethernet packet. /** Read from an received ethernet packet.
* *
* After receive returned a number bigger than 0 it is * After receive returned a number bigger than 0 it is
* possible to read bytes from this packet. * possible to read bytes from this packet.
@ -131,11 +131,11 @@ public:
*/ */
void address(char *mac); void address(char *mac);
/** Returns if an ethernet link is pressent or not. It takes a wile after Ethernet initializion to show up. /** Returns if an ethernet link is present or not. It takes a while after Ethernet initialization to show up.
* *
* @returns * @returns
* 0 if no ethernet link is pressent, * 0 if no ethernet link is present,
* 1 if an ethernet link is pressent. * 1 if an ethernet link is present.
* *
* Example: * Example:
* @code * @code

View File

@ -81,7 +81,7 @@ int I2C::write(int data) {
return ret; return ret;
} }
// read - Master Reciever Mode // read - Master Receiver Mode
int I2C::read(int address, char* data, int length, bool repeated) { int I2C::read(int address, char* data, int length, bool repeated) {
lock(); lock();
aquire(); aquire();

View File

@ -159,9 +159,9 @@ public:
/** Start non-blocking I2C transfer. /** Start non-blocking I2C transfer.
* *
* This function locks the deep sleep until any event has occured * This function locks the deep sleep until any event has occurred
* *
* @param address 8/10 bit I2c slave address * @param address 8/10 bit I2C slave address
* @param tx_buffer The TX buffer with data to be transfered * @param tx_buffer The TX buffer with data to be transfered
* @param tx_length The length of TX buffer in bytes * @param tx_length The length of TX buffer in bytes
* @param rx_buffer The RX buffer which is used for received data * @param rx_buffer The RX buffer which is used for received data

View File

@ -68,7 +68,7 @@ public:
* *
* @param c The char to write * @param c The char to write
* *
* @returns The written char or -1 if an error occured * @returns The written char or -1 if an error occurred
*/ */
int putc(int c); int putc(int c);

View File

@ -49,8 +49,8 @@ void SPI::format(int bits, int mode) {
lock(); lock();
_bits = bits; _bits = bits;
_mode = mode; _mode = mode;
// If changing format while you are the owner than just // If changing format while you are the owner then just
// update format, but if owner is changed than even frequency should be // update format, but if owner is changed then even frequency should be
// updated which is done by acquire. // updated which is done by acquire.
if (_owner == this) { if (_owner == this) {
spi_format(&_spi, _bits, _mode, 0); spi_format(&_spi, _bits, _mode, 0);
@ -63,8 +63,8 @@ void SPI::format(int bits, int mode) {
void SPI::frequency(int hz) { void SPI::frequency(int hz) {
lock(); lock();
_hz = hz; _hz = hz;
// If changing format while you are the owner than just // If changing format while you are the owner then just
// update frequency, but if owner is changed than even frequency should be // update frequency, but if owner is changed then even frequency should be
// updated which is done by acquire. // updated which is done by acquire.
if (_owner == this) { if (_owner == this) {
spi_frequency(&_spi, _hz); spi_frequency(&_spi, _hz);
@ -77,7 +77,7 @@ void SPI::frequency(int hz) {
SPI* SPI::_owner = NULL; SPI* SPI::_owner = NULL;
SingletonPtr<PlatformMutex> SPI::_mutex; SingletonPtr<PlatformMutex> SPI::_mutex;
// ignore the fact there are multiple physical spis, and always update if it wasnt us last // ignore the fact there are multiple physical spis, and always update if it wasn't us last
void SPI::aquire() { void SPI::aquire() {
lock(); lock();
if (_owner != this) { if (_owner != this) {
@ -252,7 +252,7 @@ void SPI::irq_handler_asynch(void)
} }
#if TRANSACTION_QUEUE_SIZE_SPI #if TRANSACTION_QUEUE_SIZE_SPI
if (event & (SPI_EVENT_ALL | SPI_EVENT_INTERNAL_TRANSFER_COMPLETE)) { if (event & (SPI_EVENT_ALL | SPI_EVENT_INTERNAL_TRANSFER_COMPLETE)) {
// SPI peripheral is free (event happend), dequeue transaction // SPI peripheral is free (event happened), dequeue transaction
dequeue_transaction(); dequeue_transaction();
} }
#endif #endif

View File

@ -79,7 +79,7 @@ public:
/** Create a SPI master connected to the specified pins /** Create a SPI master connected to the specified pins
* *
* mosi or miso can be specfied as NC if not used * mosi or miso can be specified as NC if not used
* *
* @param mosi SPI Master Out, Slave In pin * @param mosi SPI Master Out, Slave In pin
* @param miso SPI Master In, Slave Out pin * @param miso SPI Master In, Slave Out pin
@ -121,7 +121,7 @@ public:
/** Write to the SPI Slave and obtain the response /** Write to the SPI Slave and obtain the response
* *
* The total number of bytes sent and recieved will be the maximum of * The total number of bytes sent and received will be the maximum of
* tx_length and rx_length. The bytes written will be padded with the * tx_length and rx_length. The bytes written will be padded with the
* value 0xff. * value 0xff.
* *
@ -156,7 +156,7 @@ public:
/** Start non-blocking SPI transfer using 8bit buffers. /** Start non-blocking SPI transfer using 8bit buffers.
* *
* This function locks the deep sleep until any event has occured * This function locks the deep sleep until any event has occurred
* *
* @param tx_buffer The TX buffer with data to be transfered. If NULL is passed, * @param tx_buffer The TX buffer with data to be transfered. If NULL is passed,
* the default SPI value is sent * the default SPI value is sent

View File

@ -59,7 +59,7 @@ public:
/** Create a SPI slave connected to the specified pins /** Create a SPI slave connected to the specified pins
* *
* mosi or miso can be specfied as NC if not used * mosi or miso can be specified as NC if not used
* *
* @param mosi SPI Master Out, Slave In pin * @param mosi SPI Master Out, Slave In pin
* @param miso SPI Master In, Slave Out pin * @param miso SPI Master In, Slave Out pin

View File

@ -167,7 +167,7 @@ public:
/** Begin asynchronous write using 8bit buffer. The completition invokes registered TX event callback /** Begin asynchronous write using 8bit buffer. The completition invokes registered TX event callback
* *
* This function locks the deep sleep until any event has occured * This function locks the deep sleep until any event has occurred
* *
* @param buffer The buffer where received data will be stored * @param buffer The buffer where received data will be stored
* @param length The buffer length in bytes * @param length The buffer length in bytes
@ -178,7 +178,7 @@ public:
/** Begin asynchronous write using 16bit buffer. The completition invokes registered TX event callback /** Begin asynchronous write using 16bit buffer. The completition invokes registered TX event callback
* *
* This function locks the deep sleep until any event has occured * This function locks the deep sleep until any event has occurred
* *
* @param buffer The buffer where received data will be stored * @param buffer The buffer where received data will be stored
* @param length The buffer length in bytes * @param length The buffer length in bytes
@ -193,7 +193,7 @@ public:
/** Begin asynchronous reading using 8bit buffer. The completition invokes registred RX event callback. /** Begin asynchronous reading using 8bit buffer. The completition invokes registred RX event callback.
* *
* This function locks the deep sleep until any event has occured * This function locks the deep sleep until any event has occurred
* *
* @param buffer The buffer where received data will be stored * @param buffer The buffer where received data will be stored
* @param length The buffer length in bytes * @param length The buffer length in bytes
@ -205,7 +205,7 @@ public:
/** Begin asynchronous reading using 16bit buffer. The completition invokes registred RX event callback. /** Begin asynchronous reading using 16bit buffer. The completition invokes registred RX event callback.
* *
* This function locks the deep sleep until any event has occured * This function locks the deep sleep until any event has occurred
* *
* @param buffer The buffer where received data will be stored * @param buffer The buffer where received data will be stored
* @param length The buffer length in bytes * @param length The buffer length in bytes

View File

@ -172,7 +172,7 @@ public:
* The cancel function is irq safe. * The cancel function is irq safe.
* *
* If called while the event queue's dispatch loop is active, the cancel * If called while the event queue's dispatch loop is active, the cancel
* function does not garuntee that the event will not execute after it * function does not guarantee that the event will not execute after it
* returns, as the event may have already begun executing. * returns, as the event may have already begun executing.
*/ */
void cancel() const { void cancel() const {
@ -590,7 +590,7 @@ public:
* The cancel function is irq safe. * The cancel function is irq safe.
* *
* If called while the event queue's dispatch loop is active, the cancel * If called while the event queue's dispatch loop is active, the cancel
* function does not garuntee that the event will not execute after it * function does not guarantee that the event will not execute after it
* returns, as the event may have already begun executing. * returns, as the event may have already begun executing.
*/ */
void cancel() const { void cancel() const {
@ -1008,7 +1008,7 @@ public:
* The cancel function is irq safe. * The cancel function is irq safe.
* *
* If called while the event queue's dispatch loop is active, the cancel * If called while the event queue's dispatch loop is active, the cancel
* function does not garuntee that the event will not execute after it * function does not guarantee that the event will not execute after it
* returns, as the event may have already begun executing. * returns, as the event may have already begun executing.
*/ */
void cancel() const { void cancel() const {
@ -1426,7 +1426,7 @@ public:
* The cancel function is irq safe. * The cancel function is irq safe.
* *
* If called while the event queue's dispatch loop is active, the cancel * If called while the event queue's dispatch loop is active, the cancel
* function does not garuntee that the event will not execute after it * function does not guarantee that the event will not execute after it
* returns, as the event may have already begun executing. * returns, as the event may have already begun executing.
*/ */
void cancel() const { void cancel() const {
@ -1844,7 +1844,7 @@ public:
* The cancel function is irq safe. * The cancel function is irq safe.
* *
* If called while the event queue's dispatch loop is active, the cancel * If called while the event queue's dispatch loop is active, the cancel
* function does not garuntee that the event will not execute after it * function does not guarantee that the event will not execute after it
* returns, as the event may have already begun executing. * returns, as the event may have already begun executing.
*/ */
void cancel() const { void cancel() const {
@ -2262,7 +2262,7 @@ public:
* The cancel function is irq safe. * The cancel function is irq safe.
* *
* If called while the event queue's dispatch loop is active, the cancel * If called while the event queue's dispatch loop is active, the cancel
* function does not garuntee that the event will not execute after it * function does not guarantee that the event will not execute after it
* returns, as the event may have already begun executing. * returns, as the event may have already begun executing.
*/ */
void cancel() const { void cancel() const {

View File

@ -117,7 +117,7 @@ public:
* The cancel function is irq safe. * The cancel function is irq safe.
* *
* If called while the event queue's dispatch loop is active, the cancel * If called while the event queue's dispatch loop is active, the cancel
* function does not garuntee that the event will not execute after it * function does not guarantee that the event will not execute after it
* returns, as the event may have already begun executing. * returns, as the event may have already begun executing.
* *
* @param id Unique id of the event * @param id Unique id of the event
@ -701,6 +701,9 @@ public:
} }
/** Calls an event on the queue periodically /** Calls an event on the queue periodically
*
* @note The first call_every event occurs after the specified delay.
* To create a periodic event that fires immediately, @see Event.
* *
* The specified callback will be executed in the context of the event * The specified callback will be executed in the context of the event
* queue's dispatch loop. * queue's dispatch loop.

View File

@ -113,7 +113,7 @@ queue.dispatch();
// Events can also pass arguments to the underlying callback when both // Events can also pass arguments to the underlying callback when both
// initially constructed and posted. // initially constructed and posted.
Event<void(int, int)> event(&queue, printf, "recieved %d and %d\n"); Event<void(int, int)> event(&queue, printf, "received %d and %d\n");
// Events can be posted multiple times and enqueue gracefully until // Events can be posted multiple times and enqueue gracefully until
// the dispatch function is called. // the dispatch function is called.

View File

@ -37,7 +37,7 @@ static inline int equeue_clampdiff(unsigned a, unsigned b) {
// Increment the unique id in an event, hiding the event from cancel // Increment the unique id in an event, hiding the event from cancel
static inline void equeue_incid(equeue_t *q, struct equeue_event *e) { static inline void equeue_incid(equeue_t *q, struct equeue_event *e) {
e->id += 1; e->id += 1;
if (!(e->id << q->npw2)) { if ((e->id << q->npw2) == 0) {
e->id = 1; e->id = 1;
} }
} }
@ -469,7 +469,7 @@ void equeue_event_dtor(void *p, void (*dtor)(void *)) {
} }
// simple callbacks // simple callbacks
struct ecallback { struct ecallback {
void (*cb)(void*); void (*cb)(void*);
void *data; void *data;

View File

@ -1,10 +1,10 @@
# BLE API Cordio Implementation # BLE API Cordio Implementation
The BLE API Cordio implementation allows Cordio licensee to easily deliver a The BLE API Cordio implementation allows Cordio licensee to easily deliver a
complete and up to date implementation of mbed BLE to their custommers using complete and up to date implementation of mbed BLE to their customers using
mbed OS. mbed OS.
To deliver a BLE port, vendors simply have to provide an HCI driver taillored To deliver a BLE port, vendors simply have to provide an HCI driver tailored
for the BLE module present on the board they want to support. for the BLE module present on the board they want to support.
## Source Organization ## Source Organization

View File

@ -8,7 +8,7 @@ The files are kept the same as much as possible to the Nordic SDK. Modifications
## Porting new versions of Nordic SDK ## Porting new versions of Nordic SDK
A list of files currently requierd by mbed is maintained in [script/required_files.txt](https://github.com/ARMmbed/nrf51-sdk/blob/master/script/required_files.txt). [A python script](https://github.com/ARMmbed/nrf51-sdk/blob/master/script/pick_nrf51_files.py) is written to help porting from nordic sdk releases. **required_files.txt** is parsed to find a list of filenames. The script searches for these filenames in the sdk folder, and copy then into the yotta module mirroring the folder structure in the sdk. **extraIncludes** is automatically added to module.json to allow direct inclusion of noridc headers with just the filename. A list of files currently required by mbed is maintained in [script/required_files.txt](https://github.com/ARMmbed/nrf51-sdk/blob/master/script/required_files.txt). [A python script](https://github.com/ARMmbed/nrf51-sdk/blob/master/script/pick_nrf51_files.py) is written to help porting from nordic sdk releases. **required_files.txt** is parsed to find a list of filenames. The script searches for these filenames in the sdk folder, and copy then into the yotta module mirroring the folder structure in the sdk. **extraIncludes** is automatically added to module.json to allow direct inclusion of noridc headers with just the filename.
### Script usage ### Script usage
``` ```

View File

@ -1,5 +1,18 @@
# Change Log # Change Log
## [v4.4.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.4.0)
**New feature:**
- Make sn_coap_protocol_send_rst as public needed for CoAP ping sending
- Allow disabling resendings by defining SN_COAP_DISABLE_RESENDINGS
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.3.0...v4.4.0)
## [v4.3.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.3.0)
**New feature:**
- Add new API which clears the whole sent blockwise message list
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.2.0...v4.3.0)
## [v4.2.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.2.0) ## [v4.2.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.2.0)
**New feature:** **New feature:**
- Add new API to remove sent blockwise message from the linked list - Add new API to remove sent blockwise message from the linked list

View File

@ -247,6 +247,27 @@ extern int8_t sn_coap_convert_block_size(uint16_t block_size);
*/ */
extern int8_t sn_coap_protocol_handle_block2_response_internally(struct coap_s *handle, uint8_t handle_response); extern int8_t sn_coap_protocol_handle_block2_response_internally(struct coap_s *handle, uint8_t handle_response);
/**
* \fn void sn_coap_protocol_clear_sent_blockwise_messages(struct coap_s *handle)
*
* \brief This function clears all the sent blockwise messages from the linked list.
*
* \param *handle Pointer to CoAP library handle
*/
extern void sn_coap_protocol_clear_sent_blockwise_messages(struct coap_s *handle);
/**
* \fn void sn_coap_protocol_send_rst(struct coap_s *handle, uint16_t msg_id, sn_nsdl_addr_s *addr_ptr, void *param)
*
* \brief This function sends a RESET message.
*
* \param *handle Pointer to CoAP library handle
* \param msg_id Message id.
* \param addr_ptr Pointer to destination address where CoAP message will be sent
* \param param Pointer that will be passed to tx function callback
*/
extern void sn_coap_protocol_send_rst(struct coap_s *handle, uint16_t msg_id, sn_nsdl_addr_s *addr_ptr, void *param);
#endif /* SN_COAP_PROTOCOL_H_ */ #endif /* SN_COAP_PROTOCOL_H_ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -54,6 +54,15 @@
*/ */
#undef COAP_DISABLE_OBS_FEATURE #undef COAP_DISABLE_OBS_FEATURE
/**
* \def SN_COAP_DISABLE_RESENDINGS
*
* \brief Disables resending feature. Resending feature should not be needed
* when using CoAP with TCP transport for example. By default resendings are
* enabled. Set to 1 to disable.
*/
#undef SN_COAP_DISABLE_RESENDINGS /* 0 */ // < Default re-sending are not disabled. Set to 1 to disable re-sendings
/** /**
* \def SN_COAP_RESENDING_QUEUE_SIZE_MSGS * \def SN_COAP_RESENDING_QUEUE_SIZE_MSGS
* *

View File

@ -1,6 +1,6 @@
{ {
"name": "mbed-coap", "name": "mbed-coap",
"version": "4.2.0", "version": "4.4.0",
"description": "COAP library", "description": "COAP library",
"keywords": [ "keywords": [
"coap", "coap",

View File

@ -39,7 +39,11 @@ struct sn_coap_hdr_;
/* * * * * * * * * * * */ /* * * * * * * * * * * */
/* * For Message resending * */ /* * For Message resending * */
#ifdef SN_COAP_DISABLE_RESENDINGS
#define ENABLE_RESENDINGS 0 /* Disable resendings */
#else
#define ENABLE_RESENDINGS 1 /**< Enable / Disable resending from library in building */ #define ENABLE_RESENDINGS 1 /**< Enable / Disable resending from library in building */
#endif
#define SN_COAP_RESENDING_MAX_COUNT 3 /**< Default number of re-sendings */ #define SN_COAP_RESENDING_MAX_COUNT 3 /**< Default number of re-sendings */

View File

@ -47,7 +47,6 @@
/* * * * LOCAL FUNCTION PROTOTYPES * * * */ /* * * * LOCAL FUNCTION PROTOTYPES * * * */
/* * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * */
static void sn_coap_protocol_send_rst(struct coap_s *handle, uint16_t msg_id, sn_nsdl_addr_s *addr_ptr, void *param);
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT/* If Message duplication detection is not used at all, this part of code will not be compiled */ #if SN_COAP_DUPLICATION_MAX_MSGS_COUNT/* If Message duplication detection is not used at all, this part of code will not be compiled */
static void sn_coap_protocol_linked_list_duplication_info_store(struct coap_s *handle, sn_nsdl_addr_s *src_addr_ptr, uint16_t msg_id, void *param); static void sn_coap_protocol_linked_list_duplication_info_store(struct coap_s *handle, sn_nsdl_addr_s *src_addr_ptr, uint16_t msg_id, void *param);
static coap_duplication_info_s *sn_coap_protocol_linked_list_duplication_info_search(struct coap_s *handle, sn_nsdl_addr_s *scr_addr_ptr, uint16_t msg_id); static coap_duplication_info_s *sn_coap_protocol_linked_list_duplication_info_search(struct coap_s *handle, sn_nsdl_addr_s *scr_addr_ptr, uint16_t msg_id);
@ -256,6 +255,27 @@ int8_t sn_coap_protocol_set_block_size(struct coap_s *handle, uint16_t block_siz
} }
void sn_coap_protocol_clear_sent_blockwise_messages(struct coap_s *handle)
{
(void) handle;
#if SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
if (handle == NULL) {
return;
}
/* Loop all stored Blockwise messages in Linked list */
ns_list_foreach_safe(coap_blockwise_msg_s, removed_blocwise_msg_ptr, &handle->linked_list_blockwise_sent_msgs) {
if (removed_blocwise_msg_ptr->coap_msg_ptr) {
handle->sn_coap_protocol_free(removed_blocwise_msg_ptr->coap_msg_ptr->payload_ptr);
removed_blocwise_msg_ptr->coap_msg_ptr->payload_ptr = 0;
sn_coap_parser_release_allocated_coap_msg_mem(handle, removed_blocwise_msg_ptr->coap_msg_ptr);
removed_blocwise_msg_ptr->coap_msg_ptr = 0;
}
sn_coap_protocol_linked_list_blockwise_msg_remove(handle, removed_blocwise_msg_ptr);
}
#endif
}
int8_t sn_coap_protocol_set_duplicate_buffer_size(struct coap_s *handle, uint8_t message_count) int8_t sn_coap_protocol_set_duplicate_buffer_size(struct coap_s *handle, uint8_t message_count)
{ {
(void) handle; (void) handle;
@ -646,6 +666,8 @@ sn_coap_hdr_s *sn_coap_protocol_parse(struct coap_s *handle, sn_nsdl_addr_s *src
/* Check if there is no room to store message for duplication detection purposes */ /* Check if there is no room to store message for duplication detection purposes */
if (stored_duplication_msgs_count >= handle->sn_coap_duplication_buffer_size) { if (stored_duplication_msgs_count >= handle->sn_coap_duplication_buffer_size) {
tr_debug("sn_coap_protocol_parse - duplicate list full, dropping oldest");
/* Get oldest stored duplication message */ /* Get oldest stored duplication message */
coap_duplication_info_s *stored_duplication_info_ptr = ns_list_get_first(&handle->linked_list_duplication_msgs); coap_duplication_info_s *stored_duplication_info_ptr = ns_list_get_first(&handle->linked_list_duplication_msgs);
@ -1007,7 +1029,7 @@ uint32_t sn_coap_calculate_new_resend_time(const uint32_t current_time, const ui
#endif /* ENABLE_RESENDINGS */ #endif /* ENABLE_RESENDINGS */
static void sn_coap_protocol_send_rst(struct coap_s *handle, uint16_t msg_id, sn_nsdl_addr_s *addr_ptr, void *param) void sn_coap_protocol_send_rst(struct coap_s *handle, uint16_t msg_id, sn_nsdl_addr_s *addr_ptr, void *param)
{ {
uint8_t packet_ptr[4]; uint8_t packet_ptr[4];

View File

@ -1145,6 +1145,7 @@ static nsapi_error_t mbed_lwip_socket_bind(nsapi_stack_t *stack, nsapi_socket_t
static nsapi_error_t mbed_lwip_socket_listen(nsapi_stack_t *stack, nsapi_socket_t handle, int backlog) static nsapi_error_t mbed_lwip_socket_listen(nsapi_stack_t *stack, nsapi_socket_t handle, int backlog)
{ {
#if LWIP_TCP
struct lwip_socket *s = (struct lwip_socket *)handle; struct lwip_socket *s = (struct lwip_socket *)handle;
if (s->conn->pcb.tcp->local_port == 0) { if (s->conn->pcb.tcp->local_port == 0) {
@ -1153,6 +1154,9 @@ static nsapi_error_t mbed_lwip_socket_listen(nsapi_stack_t *stack, nsapi_socket_
err_t err = netconn_listen_with_backlog(s->conn, backlog); err_t err = netconn_listen_with_backlog(s->conn, backlog);
return mbed_lwip_err_remap(err); return mbed_lwip_err_remap(err);
#else
return NSAPI_ERROR_UNSUPPORTED;
#endif
} }
static nsapi_error_t mbed_lwip_socket_connect(nsapi_stack_t *stack, nsapi_socket_t handle, nsapi_addr_t addr, uint16_t port) static nsapi_error_t mbed_lwip_socket_connect(nsapi_stack_t *stack, nsapi_socket_t handle, nsapi_addr_t addr, uint16_t port)
@ -1173,6 +1177,7 @@ static nsapi_error_t mbed_lwip_socket_connect(nsapi_stack_t *stack, nsapi_socket
static nsapi_error_t mbed_lwip_socket_accept(nsapi_stack_t *stack, nsapi_socket_t server, nsapi_socket_t *handle, nsapi_addr_t *addr, uint16_t *port) static nsapi_error_t mbed_lwip_socket_accept(nsapi_stack_t *stack, nsapi_socket_t server, nsapi_socket_t *handle, nsapi_addr_t *addr, uint16_t *port)
{ {
#if LWIP_TCP
struct lwip_socket *s = (struct lwip_socket *)server; struct lwip_socket *s = (struct lwip_socket *)server;
struct lwip_socket *ns = mbed_lwip_arena_alloc(); struct lwip_socket *ns = mbed_lwip_arena_alloc();
if (!ns) { if (!ns) {
@ -1199,6 +1204,9 @@ static nsapi_error_t mbed_lwip_socket_accept(nsapi_stack_t *stack, nsapi_socket_
netconn_set_nonblocking(ns->conn, true); netconn_set_nonblocking(ns->conn, true);
return 0; return 0;
#else
return NSAPI_ERROR_UNSUPPORTED;
#endif
} }
static nsapi_size_or_error_t mbed_lwip_socket_send(nsapi_stack_t *stack, nsapi_socket_t handle, const void *data, nsapi_size_t size) static nsapi_size_or_error_t mbed_lwip_socket_send(nsapi_stack_t *stack, nsapi_socket_t handle, const void *data, nsapi_size_t size)

View File

@ -68,38 +68,37 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_send_sms()
ATHandler at(&fh1, que, 0, ","); ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at); AT_CellularSMS sms(at);
CHECK(NSAPI_ERROR_PARAMETER == sms.send_sms(NULL, "2", 1)); LONGS_EQUAL(NSAPI_ERROR_PARAMETER, sms.send_sms(NULL, "2", 1));
sms.initialize(CellularSMS::CellularSMSMmodeText); sms.initialize(CellularSMS::CellularSMSMmodeText);
ATHandler_stub::size_value = 1; ATHandler_stub::size_value = 1;
CHECK(1 == sms.send_sms("1", "22", 2)); LONGS_EQUAL(1, sms.send_sms("1", "22", 2));
ATHandler_stub::size_value = 2; ATHandler_stub::size_value = 2;
CHECK(2 == sms.send_sms("1", "22", 2)); LONGS_EQUAL(2, sms.send_sms("1", "22", 2));
ATHandler_stub::return_given_size = true; // PDU mode write is much longer than than msg len
sms.initialize(CellularSMS::CellularSMSMmodePDU); sms.initialize(CellularSMS::CellularSMSMmodePDU);
CHECK(2 == sms.send_sms("1", "23", 2)); LONGS_EQUAL(2, sms.send_sms("1", "23", 2));;
ATHandler_stub::nsapi_error_ok_counter = 1; ATHandler_stub::nsapi_error_ok_counter = 1;
ATHandler_stub::size_value = 32; ATHandler_stub::size_value = 32;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE; ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
CHECK(NSAPI_ERROR_AUTH_FAILURE == sms.send_sms("1", "23232323", 8)); LONGS_EQUAL(NSAPI_ERROR_AUTH_FAILURE, sms.send_sms("1", "23232323", 8));
ATHandler_stub::nsapi_error_ok_counter = 2; ATHandler_stub::nsapi_error_ok_counter = 2;
ATHandler_stub::size_value = 32; ATHandler_stub::size_value = 32;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE; ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
CHECK(NSAPI_ERROR_AUTH_FAILURE == sms.send_sms("1", "23232323", 8)); LONGS_EQUAL(NSAPI_ERROR_AUTH_FAILURE, sms.send_sms("1", "23232323", 8));
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK; ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
char table[] = "232323232323232323232323232323232323232323232323232323\ char table[] = "232323232323232323232323232323232323232323232323232323\
232323232323232323232323232323232323232323232323232323\ 232323232323232323232323232323232323232323232323232323\
232323232323232323232323232323232323232323232323232323\ 232323232323232323232323232323232323232323232323232323\
23232323232323232323232323232323232323\0"; 23232323232323232323232323232323232323\0";
ATHandler_stub::size_value = 0;
ATHandler_stub::return_given_size = true;
CHECK(218 == sms.send_sms("1", table, strlen(table)));
CHECK(218 == sms.send_sms("12", table, strlen(table))); LONGS_EQUAL(strlen(table), sms.send_sms("1", table, strlen(table)));
LONGS_EQUAL(strlen(table), sms.send_sms("12", table, strlen(table)));
} }

View File

@ -35,6 +35,7 @@ public:
bool max_sock_value; bool max_sock_value;
nsapi_error_t create_error; nsapi_error_t create_error;
int max_packet_size; int max_packet_size;
CellularSocket socket;
MyStack(ATHandler &atr, int cid, nsapi_ip_stack_t typ) : AT_CellularStack(atr, cid, typ) MyStack(ATHandler &atr, int cid, nsapi_ip_stack_t typ) : AT_CellularStack(atr, cid, typ)
{ {
@ -143,14 +144,14 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_open()
st.bool_value = true; st.bool_value = true;
st.max_sock_value = 0; st.max_sock_value = 0;
nsapi_socket_t sock; nsapi_socket_t sock = &st.socket;
CHECK(NSAPI_ERROR_NO_SOCKET == st.socket_open(&sock, NSAPI_TCP)); CHECK(NSAPI_ERROR_NO_SOCKET == st.socket_open(&sock, NSAPI_TCP));
MyStack st2(at, 0, IPV6_STACK); MyStack st2(at, 0, IPV6_STACK);
st2.bool_value = true; st2.bool_value = true;
st2.max_sock_value = 1; st2.max_sock_value = 1;
nsapi_socket_t sock2; sock = &st2.socket;
CHECK(NSAPI_ERROR_OK == st2.socket_open(&sock2, NSAPI_TCP)); CHECK(NSAPI_ERROR_OK == st2.socket_open(&sock, NSAPI_TCP));
} }
void Test_AT_CellularStack::test_AT_CellularStack_socket_close() void Test_AT_CellularStack::test_AT_CellularStack_socket_close()
@ -160,12 +161,11 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_close()
ATHandler at(&fh1, que, 0, ","); ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK); MyStack st(at, 0, IPV6_STACK);
nsapi_socket_t soc = NULL; CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_close(&st.socket));
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_close(soc));
nsapi_socket_t sock = &st.socket;
st.bool_value = true; st.bool_value = true;
st.max_sock_value = 1; st.max_sock_value = 1;
nsapi_socket_t sock;
CHECK(NSAPI_ERROR_OK == st.socket_open(&sock, NSAPI_TCP)); CHECK(NSAPI_ERROR_OK == st.socket_open(&sock, NSAPI_TCP));
st.max_sock_value = 0; st.max_sock_value = 0;
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_close(sock)); CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_close(sock));
@ -173,9 +173,9 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_close()
MyStack st2(at, 0, IPV6_STACK); MyStack st2(at, 0, IPV6_STACK);
st2.max_sock_value = 1; st2.max_sock_value = 1;
st2.bool_value = true; st2.bool_value = true;
nsapi_socket_t sock2; sock = &st2.socket;
CHECK(NSAPI_ERROR_OK == st2.socket_open(&sock2, NSAPI_TCP)); CHECK(NSAPI_ERROR_OK == st2.socket_open(&sock, NSAPI_TCP));
CHECK(NSAPI_ERROR_OK == st2.socket_close(sock2)); CHECK(NSAPI_ERROR_OK == st2.socket_close(sock));
} }
void Test_AT_CellularStack::test_AT_CellularStack_socket_bind() void Test_AT_CellularStack::test_AT_CellularStack_socket_bind()
@ -185,12 +185,11 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_bind()
ATHandler at(&fh1, que, 0, ","); ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK); MyStack st(at, 0, IPV6_STACK);
nsapi_socket_t sock;
SocketAddress addr; SocketAddress addr;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_ALREADY; ATHandler_stub::nsapi_error_value = NSAPI_ERROR_ALREADY;
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_bind(NULL, addr)); CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_bind(NULL, addr));
CHECK(NSAPI_ERROR_ALREADY == st.socket_bind(sock, addr)); CHECK(NSAPI_ERROR_ALREADY == st.socket_bind(&st.socket, addr));
} }
void Test_AT_CellularStack::test_AT_CellularStack_socket_listen() void Test_AT_CellularStack::test_AT_CellularStack_socket_listen()
@ -200,8 +199,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_listen()
ATHandler at(&fh1, que, 0, ","); ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK); MyStack st(at, 0, IPV6_STACK);
nsapi_socket_t sock; CHECK(NSAPI_ERROR_UNSUPPORTED == st.socket_listen(&st.socket, 4));
CHECK(0 == st.socket_listen(sock, 4));
} }
void Test_AT_CellularStack::test_AT_CellularStack_socket_connect() void Test_AT_CellularStack::test_AT_CellularStack_socket_connect()
@ -214,8 +212,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_connect()
SocketAddress addr; SocketAddress addr;
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_connect(NULL, addr)); CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_connect(NULL, addr));
nsapi_socket_t sock; CHECK(NSAPI_ERROR_OK == st.socket_connect(&st.socket, addr));
CHECK(NSAPI_ERROR_OK == st.socket_connect(sock, addr));
} }
void Test_AT_CellularStack::test_AT_CellularStack_socket_accept() void Test_AT_CellularStack::test_AT_CellularStack_socket_accept()
@ -225,8 +222,8 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_accept()
ATHandler at(&fh1, que, 0, ","); ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK); MyStack st(at, 0, IPV6_STACK);
nsapi_socket_t sock; nsapi_socket_t sock = &st.socket;
CHECK(0 == st.socket_accept(NULL, &sock)); CHECK(NSAPI_ERROR_UNSUPPORTED == st.socket_accept(NULL, &sock));
} }
void Test_AT_CellularStack::test_AT_CellularStack_socket_send() void Test_AT_CellularStack::test_AT_CellularStack_socket_send()
@ -238,12 +235,12 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_send()
MyStack st(at, 0, IPV6_STACK); MyStack st(at, 0, IPV6_STACK);
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_send(NULL, "addr", 4)); CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_send(NULL, "addr", 4));
nsapi_socket_t sock; CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_send(&st.socket, "addr", 4));
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_send(sock, "addr", 4));
SocketAddress addr; SocketAddress addr;
st.max_sock_value = 1; st.max_sock_value = 1;
st.bool_value = true; st.bool_value = true;
nsapi_socket_t sock = &st.socket;
st.socket_open(&sock, NSAPI_TCP); st.socket_open(&sock, NSAPI_TCP);
st.socket_connect(sock, addr); st.socket_connect(sock, addr);
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_send(sock, "addr", 4)); CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_send(sock, "addr", 4));
@ -257,12 +254,12 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_sendto()
MyStack st(at, 0, IPV6_STACK); MyStack st(at, 0, IPV6_STACK);
nsapi_socket_t sock;
SocketAddress addr; SocketAddress addr;
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_sendto(NULL, addr, "addr", 4)); CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_sendto(NULL, addr, "addr", 4));
st.max_sock_value = 1; st.max_sock_value = 1;
st.bool_value = true; st.bool_value = true;
nsapi_socket_t sock = &st.socket;
st.socket_open(&sock, NSAPI_TCP); st.socket_open(&sock, NSAPI_TCP);
st.socket_connect(sock, addr); st.socket_connect(sock, addr);
st.create_error = NSAPI_ERROR_CONNECTION_LOST; st.create_error = NSAPI_ERROR_CONNECTION_LOST;
@ -294,10 +291,10 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_recvfrom()
char table[4]; char table[4];
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_recvfrom(NULL, NULL, table, 4)); CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_recvfrom(NULL, NULL, table, 4));
nsapi_socket_t sock;
SocketAddress addr; SocketAddress addr;
st.max_sock_value = 1; st.max_sock_value = 1;
st.bool_value = true; st.bool_value = true;
nsapi_socket_t sock = &st.socket;
st.socket_open(&sock, NSAPI_TCP); st.socket_open(&sock, NSAPI_TCP);
st.socket_connect(sock, addr); st.socket_connect(sock, addr);
st.create_error = NSAPI_ERROR_CONNECTION_LOST; st.create_error = NSAPI_ERROR_CONNECTION_LOST;
@ -317,9 +314,9 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_attach()
MyStack st(at, 0, IPV6_STACK); MyStack st(at, 0, IPV6_STACK);
st.socket_attach(NULL, NULL, NULL); st.socket_attach(NULL, NULL, NULL);
nsapi_socket_t sock;
st.max_sock_value = 1; st.max_sock_value = 1;
st.bool_value = true; st.bool_value = true;
nsapi_socket_t sock = &st.socket;
st.socket_open(&sock, NSAPI_TCP); st.socket_open(&sock, NSAPI_TCP);
st.socket_attach(sock, NULL, NULL); st.socket_attach(sock, NULL, NULL);
} }

View File

@ -0,0 +1,17 @@
/*
* Copyright (c) , Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* 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 the specific language governing permissions and
* limitations under the License.
*/

View File

@ -29,9 +29,9 @@
#include "CellularLog.h" #include "CellularLog.h"
#include "mbed_wait_api.h" #include "mbed_wait_api.h"
#if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #if USE_APN_LOOKUP
#include "APN_db.h" #include "APN_db.h"
#endif //MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #endif //USE_APN_LOOKUP
namespace mbed { namespace mbed {
@ -59,9 +59,9 @@ EasyCellularConnection::EasyCellularConnection(bool debug) :
NSAPI_ERROR_OK) NSAPI_ERROR_OK)
{ {
tr_info("EasyCellularConnection()"); tr_info("EasyCellularConnection()");
#if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #if USE_APN_LOOKUP
_credentials_set = false; _credentials_set = false;
#endif // #if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #endif // #if USE_APN_LOOKUP
modem_debug_on(debug); modem_debug_on(debug);
} }
@ -102,11 +102,11 @@ void EasyCellularConnection::set_credentials(const char *apn, const char *uname,
CellularNetwork * network = _cellularConnectionFSM.get_network(); CellularNetwork * network = _cellularConnectionFSM.get_network();
if (network) { if (network) {
_credentials_err = network->set_credentials(apn, uname, pwd); _credentials_err = network->set_credentials(apn, uname, pwd);
#if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #if USE_APN_LOOKUP
if (_credentials_err == NSAPI_ERROR_OK) { if (_credentials_err == NSAPI_ERROR_OK) {
_credentials_set = true; _credentials_set = true;
} }
#endif // #if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #endif // #if USE_APN_LOOKUP
} else { } else {
tr_error("NO Network..."); tr_error("NO Network...");
} }
@ -163,7 +163,7 @@ nsapi_error_t EasyCellularConnection::connect()
if (err) { if (err) {
return err; return err;
} }
#if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #if USE_APN_LOOKUP
if (!_credentials_set) { if (!_credentials_set) {
_target_state = CellularConnectionFSM::STATE_SIM_PIN; _target_state = CellularConnectionFSM::STATE_SIM_PIN;
err = _cellularConnectionFSM.continue_to_state(_target_state); err = _cellularConnectionFSM.continue_to_state(_target_state);
@ -193,7 +193,7 @@ nsapi_error_t EasyCellularConnection::connect()
return err; return err;
} }
} }
#endif // MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #endif // USE_APN_LOOKUP
_target_state = CellularConnectionFSM::STATE_CONNECTED; _target_state = CellularConnectionFSM::STATE_CONNECTED;
err = _cellularConnectionFSM.continue_to_state(_target_state); err = _cellularConnectionFSM.continue_to_state(_target_state);
@ -212,9 +212,9 @@ nsapi_error_t EasyCellularConnection::disconnect()
{ {
_credentials_err = NSAPI_ERROR_OK; _credentials_err = NSAPI_ERROR_OK;
_is_connected = false; _is_connected = false;
#if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #if USE_APN_LOOKUP
_credentials_set = false; _credentials_set = false;
#endif // #if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #endif // #if USE_APN_LOOKUP
if (!_cellularConnectionFSM.get_network()) { if (!_cellularConnectionFSM.get_network()) {
return NSAPI_ERROR_NO_CONNECTION; return NSAPI_ERROR_NO_CONNECTION;
} }

View File

@ -24,6 +24,8 @@
#include "netsocket/CellularBase.h" #include "netsocket/CellularBase.h"
#define USE_APN_LOOKUP (MBED_CONF_CELLULAR_USE_APN_LOOKUP || (NSAPI_PPP_AVAILABLE && MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP))
namespace mbed namespace mbed
{ {
@ -145,9 +147,9 @@ private:
bool _is_connected; bool _is_connected;
bool _is_initialized; bool _is_initialized;
#if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #if USE_APN_LOOKUP
bool _credentials_set; bool _credentials_set;
#endif // #if MBED_CONF_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #endif // #if USE_APN_LOOKUP
CellularConnectionFSM::CellularState _target_state; CellularConnectionFSM::CellularState _target_state;
UARTSerial _cellularSerial; UARTSerial _cellularSerial;

View File

@ -18,7 +18,6 @@
#ifndef CELLULAR_NETWORK_H_ #ifndef CELLULAR_NETWORK_H_
#define CELLULAR_NETWORK_H_ #define CELLULAR_NETWORK_H_
#include "CellularInterface.h"
#include "NetworkInterface.h" #include "NetworkInterface.h"
#include "CellularList.h" #include "CellularList.h"
@ -381,6 +380,30 @@ public:
* @return NSAPI_ERROR_OK on success, negative error code on failure * @return NSAPI_ERROR_OK on success, negative error code on failure
*/ */
virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params) = 0; virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params) = 0;
/** Register callback for status reporting
*
* The specified status callback function will be called on status changes
* on the network. The parameters on the callback are the event type and
* event-type dependent reason parameter.
*
* @param status_cb The callback for status changes
*/
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb) = 0;
/** Get the connection status
*
* @return The connection status according to ConnectionStatusType
*/
virtual nsapi_connection_status_t get_connection_status() const = 0;
/** Set blocking status of connect() which by default should be blocking
*
* @param blocking true if connect is blocking
* @return 0 on success, negative error code on failure
*/
virtual nsapi_error_t set_blocking(bool blocking) = 0;
}; };
} // namespace mbed } // namespace mbed

View File

@ -314,7 +314,7 @@ void ATHandler::fill_buffer()
} while ((uint32_t)timer.read_ms() < _at_timeout); } while ((uint32_t)timer.read_ms() < _at_timeout);
set_error(NSAPI_ERROR_DEVICE_ERROR); set_error(NSAPI_ERROR_DEVICE_ERROR);
tr_error("AT TIMEOUT, scope: %d timeout: %lu", _current_scope, _at_timeout); tr_debug("AT TIMEOUT, scope: %d timeout: %lu", _current_scope, _at_timeout);
} }
int ATHandler::get_char() int ATHandler::get_char()
@ -846,7 +846,7 @@ bool ATHandler::consume_to_tag(const char *tag, bool consume_tag)
match_pos = 0; match_pos = 0;
} }
} }
tr_error("consume_to_tag not found"); tr_debug("consume_to_tag not found");
return false; return false;
} }
@ -862,7 +862,7 @@ bool ATHandler::consume_to_stop_tag()
return true; return true;
} }
tr_error("consume_to_stop_tag not found"); tr_debug("consume_to_stop_tag not found");
set_error(NSAPI_ERROR_DEVICE_ERROR); set_error(NSAPI_ERROR_DEVICE_ERROR);
return false; return false;
} }
@ -942,13 +942,7 @@ void ATHandler::cmd_start(const char* cmd)
return; return;
} }
// write command (void)write(cmd, strlen(cmd));
for (size_t i = 0; i < strlen(cmd); i++) {
if (write_char(cmd[i]) == false) {
// writing failed ---> write_char have set the last error, return...
return;
}
}
_cmd_start = true; _cmd_start = true;
} }
@ -966,12 +960,7 @@ void ATHandler::write_int(int32_t param)
char number_string[str_len]; char number_string[str_len];
int32_t result = sprintf(number_string, "%ld", param); int32_t result = sprintf(number_string, "%ld", param);
if (result > 0 && result < str_len) { if (result > 0 && result < str_len) {
for (size_t i = 0; number_string[i]; i++) { (void)write(number_string, strlen(number_string));
if (write_char(number_string[i]) == false) {
// writing failed ---> write_char have set the last error, break out
break;
}
}
} }
} }
@ -984,20 +973,15 @@ void ATHandler::write_string(const char* param, bool useQuotations)
} }
// we are writing string, surround it with quotes // we are writing string, surround it with quotes
if (useQuotations && write_char('\"') == false) { if (useQuotations && write("\"", 1) != 1) {
return; return;
} }
for (size_t i = 0; i < strlen(param); i++) { (void)write(param, strlen(param));
if (write_char(param[i]) == false) {
// writing failed ---> write_char have set the last error, return
break;
}
}
if (useQuotations) { if (useQuotations) {
// we are writing string, surround it with quotes // we are writing string, surround it with quotes
write_char('\"'); (void)write("\"", 1);
} }
} }
@ -1007,11 +991,7 @@ void ATHandler::cmd_stop()
return; return;
} }
// Finish with CR // Finish with CR
for (size_t i = 0; i < _output_delimiter_length; i++) { (void)write(_output_delimiter, _output_delimiter_length);
if (write_char(_output_delimiter[i]) == false) {
break;
}
}
} }
size_t ATHandler::write_bytes(const uint8_t *data, size_t len) size_t ATHandler::write_bytes(const uint8_t *data, size_t len)
@ -1020,36 +1000,27 @@ size_t ATHandler::write_bytes(const uint8_t *data, size_t len)
return 0; return 0;
} }
size_t i = 0; ssize_t write_len = write(data, len);
for (; i < len; i++) { return write_len < 0 ? 0 : (size_t)write_len;
if (write_char(data[i]) == false) {
// writing failed ---> write_char have set the last error, return
break;
}
}
return i;
} }
bool ATHandler::write_char(char c) ssize_t ATHandler::write(const void *data, size_t len)
{ {
pollfh fhs; pollfh fhs;
fhs.fh = _fileHandle; fhs.fh = _fileHandle;
fhs.events = POLLOUT; fhs.events = POLLOUT;
bool retVal = true; ssize_t write_len = -1;
int count = poll(&fhs, 1, _at_timeout); int count = poll(&fhs, 1, _at_timeout);
if (count > 0 && (fhs.revents & POLLOUT)) { if (count > 0 && (fhs.revents & POLLOUT)) {
retVal = _fileHandle->write(&c, 1) == 1 ? true : false; write_len = _fileHandle->write(data, len);
} else {
retVal = false;
} }
if (retVal == false) { if (write_len < 0 || (size_t)write_len != len) {
set_error(NSAPI_ERROR_DEVICE_ERROR); set_error(NSAPI_ERROR_DEVICE_ERROR);
} }
return retVal; return write_len;
} }
// do common checks before sending subparameters // do common checks before sending subparameters
@ -1063,8 +1034,8 @@ bool ATHandler::check_cmd_send()
if (_cmd_start) { if (_cmd_start) {
_cmd_start = false; _cmd_start = false;
} else { } else {
if (write_char(_delimiter) == false) { if (write(&_delimiter, 1) != 1) {
// writing of delimiter failed, return. write_char already have set the _last_err // writing of delimiter failed, return. write() already have set the _last_err
return false; return false;
} }
} }

View File

@ -446,7 +446,7 @@ private:
void set_3gpp_error(int err, DeviceErrorType error_type); void set_3gpp_error(int err, DeviceErrorType error_type);
bool check_cmd_send(); bool check_cmd_send();
bool write_char(char c); ssize_t write(const void *data, size_t len);
/** Copy content of one char buffer to another buffer and sets NULL terminator /** Copy content of one char buffer to another buffer and sets NULL terminator
* *

View File

@ -133,6 +133,7 @@ nsapi_error_t AT_CellularNetwork::connect(const char *apn,
nsapi_error_t AT_CellularNetwork::delete_current_context() nsapi_error_t AT_CellularNetwork::delete_current_context()
{ {
tr_info("Delete context %d", _cid);
_at.clear_error(); _at.clear_error();
_at.cmd_start("AT+CGDCONT="); _at.cmd_start("AT+CGDCONT=");
_at.write_int(_cid); _at.write_int(_cid);
@ -236,12 +237,14 @@ nsapi_error_t AT_CellularNetwork::open_data_channel()
int context_activation_state = _at.read_int(); int context_activation_state = _at.read_int();
if (context_id == _cid && context_activation_state == 1) { if (context_id == _cid && context_activation_state == 1) {
is_context_active = true; is_context_active = true;
tr_debug("PDP context %d is active.", _cid);
break;
} }
} }
_at.resp_stop(); _at.resp_stop();
if (!is_context_active) { if (!is_context_active) {
tr_info("Activate PDP context"); tr_info("Activate PDP context %d", _cid);
_at.cmd_start("AT+CGACT=1,"); _at.cmd_start("AT+CGACT=1,");
_at.write_int(_cid); _at.write_int(_cid);
_at.cmd_stop(); _at.cmd_stop();
@ -401,6 +404,7 @@ bool AT_CellularNetwork::set_new_context(int cid)
_ip_stack_type = tmp_stack; _ip_stack_type = tmp_stack;
_cid = cid; _cid = cid;
_new_context_set = true; _new_context_set = true;
tr_info("New PDP context id %d was created", _cid);
} }
return success; return success;
@ -408,6 +412,12 @@ bool AT_CellularNetwork::set_new_context(int cid)
bool AT_CellularNetwork::get_context() bool AT_CellularNetwork::get_context()
{ {
if (_apn) {
tr_debug("APN in use: %s", _apn);
} else {
tr_debug("NO APN");
}
_at.cmd_start("AT+CGDCONT?"); _at.cmd_start("AT+CGDCONT?");
_at.cmd_stop(); _at.cmd_stop();
_at.resp_start("+CGDCONT:"); _at.resp_start("+CGDCONT:");
@ -429,7 +439,7 @@ bool AT_CellularNetwork::get_context()
if (pdp_type_len > 0) { if (pdp_type_len > 0) {
apn_len = _at.read_string(apn, sizeof(apn) - 1); apn_len = _at.read_string(apn, sizeof(apn) - 1);
if (apn_len >= 0) { if (apn_len >= 0) {
if (_apn && strcmp(apn, _apn) != 0 ) { if (_apn && (strcmp(apn, _apn) != 0) ) {
continue; continue;
} }
nsapi_ip_stack_t pdp_stack = string_to_stack_type(pdp_type_from_context); nsapi_ip_stack_t pdp_stack = string_to_stack_type(pdp_type_from_context);
@ -546,10 +556,18 @@ nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn)
if (!plmn) { if (!plmn) {
tr_debug("Automatic network registration"); tr_debug("Automatic network registration");
_at.cmd_start("AT+COPS=0"); _at.cmd_start("AT+COPS?");
_at.cmd_stop(); _at.cmd_stop();
_at.resp_start(); _at.resp_start("AT+COPS:");
int mode = _at.read_int();
_at.resp_stop(); _at.resp_stop();
if (mode != 0) {
_at.clear_error();
_at.cmd_start("AT+COPS=0");
_at.cmd_stop();
_at.resp_start();
_at.resp_stop();
}
} else { } else {
tr_debug("Manual network registration to %s", plmn); tr_debug("Manual network registration to %s", plmn);
_at.cmd_start("AT+COPS=4,2,"); _at.cmd_start("AT+COPS=4,2,");

View File

@ -17,6 +17,7 @@
#include "QUECTEL_BC95_CellularNetwork.h" #include "QUECTEL_BC95_CellularNetwork.h"
#include "QUECTEL_BC95_CellularPower.h" #include "QUECTEL_BC95_CellularPower.h"
#include "QUECTEL_BC95_CellularSIM.h"
#include "QUECTEL_BC95.h" #include "QUECTEL_BC95.h"
@ -41,7 +42,13 @@ QUECTEL_BC95::~QUECTEL_BC95()
CellularNetwork *QUECTEL_BC95::open_network(FileHandle *fh) CellularNetwork *QUECTEL_BC95::open_network(FileHandle *fh)
{ {
if (!_network) { if (!_network) {
_network = new QUECTEL_BC95_CellularNetwork(*get_at_handler(fh)); ATHandler *atHandler = get_at_handler(fh);
if (atHandler) {
_network = new QUECTEL_BC95_CellularNetwork(*atHandler);
if (!_network) {
release_at_handler(atHandler);
}
}
} }
return _network; return _network;
} }
@ -49,7 +56,27 @@ CellularNetwork *QUECTEL_BC95::open_network(FileHandle *fh)
CellularPower *QUECTEL_BC95::open_power(FileHandle *fh) CellularPower *QUECTEL_BC95::open_power(FileHandle *fh)
{ {
if (!_power) { if (!_power) {
_power = new QUECTEL_BC95_CellularPower(*get_at_handler(fh)); ATHandler *atHandler = get_at_handler(fh);
if (atHandler) {
_power = new QUECTEL_BC95_CellularPower(*atHandler);
if (!_power) {
release_at_handler(atHandler);
}
}
} }
return _power; return _power;
} }
CellularSIM *QUECTEL_BC95::open_sim(FileHandle *fh)
{
if (!_sim) {
ATHandler *atHandler = get_at_handler(fh);
if (atHandler) {
_sim = new QUECTEL_BC95_CellularSIM(*atHandler);
if (!_sim) {
release_at_handler(atHandler);
}
}
}
return _sim;
}

View File

@ -32,6 +32,7 @@ public:
public: // CellularDevice public: // CellularDevice
virtual CellularNetwork *open_network(FileHandle *fh); virtual CellularNetwork *open_network(FileHandle *fh);
virtual CellularPower *open_power(FileHandle *fh); virtual CellularPower *open_power(FileHandle *fh);
virtual CellularSIM *open_sim(FileHandle *fh);
public: // NetworkInterface public: // NetworkInterface
void handle_urc(FileHandle *fh); void handle_urc(FileHandle *fh);

View File

@ -15,8 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef TELIT_HE910_CELLULAR_POWER_H_ #ifndef QUECTEL_BC95_CELLULAR_POWER_H_
#define TELIT_HE910_CELLULAR_POWER_H_ #define QUECTEL_BC95_CELLULAR_POWER_H_
#include "AT_CellularPower.h" #include "AT_CellularPower.h"
@ -36,4 +36,4 @@ public: //from CellularPower
} // namespace mbed } // namespace mbed
#endif // TELIT_HE910_CELLULAR_POWER_H_ #endif // QUECTEL_BC95_CELLULAR_POWER_H_

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2017, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* 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 the specific language governing permissions and
* limitations under the License.
*/
#include "QUECTEL_BC95_CellularSIM.h"
#include "CellularLog.h"
using namespace mbed;
QUECTEL_BC95_CellularSIM::QUECTEL_BC95_CellularSIM(ATHandler &atHandler) : AT_CellularSIM(atHandler)
{
}
QUECTEL_BC95_CellularSIM::~QUECTEL_BC95_CellularSIM()
{
}
nsapi_error_t QUECTEL_BC95_CellularSIM::get_sim_state(SimState &state)
{
_at.lock();
_at.flush();
_at.cmd_start("AT+NCCID?");
_at.cmd_stop();
_at.resp_start("+NCCID:");
if (_at.info_resp()) {
state = SimStateReady;
} else {
tr_warn("SIM not readable.");
state = SimStateUnknown; // SIM may not be ready yet
}
_at.resp_stop();
return _at.unlock_return_error();
}

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2017, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* 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 the specific language governing permissions and
* limitations under the License.
*/
#ifndef QUECTEL_BC95_CELLULAR_SIM_H_
#define QUECTEL_BC95_CELLULAR_SIM_H_
#include "AT_CellularSIM.h"
namespace mbed {
class QUECTEL_BC95_CellularSIM : public AT_CellularSIM
{
public:
QUECTEL_BC95_CellularSIM(ATHandler &atHandler);
virtual ~QUECTEL_BC95_CellularSIM();
public: //from CellularSIM
virtual nsapi_error_t get_sim_state(SimState &state);
};
} // namespace mbed
#endif // QUECTEL_BC95_CELLULAR_SIM_H_

View File

@ -150,7 +150,8 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc
_at.write_string(hexstr, false); _at.write_string(hexstr, false);
_at.cmd_stop(); _at.cmd_stop();
_at.resp_start(); _at.resp_start();
socket->id = _at.read_int(); // skip socket id
_at.skip_param();
sent_len = _at.read_int(); sent_len = _at.read_int();
_at.resp_stop(); _at.resp_stop();
@ -182,6 +183,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_recvfrom_impl(CellularS
_at.read_string(hexstr, sizeof(hexstr)); _at.read_string(hexstr, sizeof(hexstr));
// remaining length // remaining length
_at.skip_param(); _at.skip_param();
_at.resp_stop();
if (!recv_len || (recv_len == -1) || (_at.get_last_error() != NSAPI_ERROR_OK)) { if (!recv_len || (recv_len == -1) || (_at.get_last_error() != NSAPI_ERROR_OK)) {
return NSAPI_ERROR_WOULD_BLOCK; return NSAPI_ERROR_WOULD_BLOCK;

View File

@ -40,7 +40,13 @@ QUECTEL_BG96::~QUECTEL_BG96()
CellularNetwork *QUECTEL_BG96::open_network(FileHandle *fh) CellularNetwork *QUECTEL_BG96::open_network(FileHandle *fh)
{ {
if (!_network) { if (!_network) {
_network = new QUECTEL_BG96_CellularNetwork(*get_at_handler(fh)); ATHandler *atHandler = get_at_handler(fh);
if (atHandler) {
_network = new QUECTEL_BG96_CellularNetwork(*atHandler);
if (!_network) {
release_at_handler(atHandler);
}
}
} }
return _network; return _network;
} }

View File

@ -128,9 +128,9 @@ public:
*/ */
virtual bd_size_t get_read_size() const = 0; virtual bd_size_t get_read_size() const = 0;
/** Get the size of a programable block /** Get the size of a programmable block
* *
* @return Size of a programable block in bytes * @return Size of a programmable block in bytes
* @note Must be a multiple of the read size * @note Must be a multiple of the read size
*/ */
virtual bd_size_t get_program_size() const = 0; virtual bd_size_t get_program_size() const = 0;

View File

@ -128,9 +128,9 @@ public:
*/ */
virtual bd_size_t get_read_size() const; virtual bd_size_t get_read_size() const;
/** Get the size of a programable block /** Get the size of a programmable block
* *
* @return Size of a programable block in bytes * @return Size of a programmable block in bytes
* @note Must be a multiple of the read size * @note Must be a multiple of the read size
*/ */
virtual bd_size_t get_program_size() const; virtual bd_size_t get_program_size() const;

View File

@ -118,9 +118,9 @@ public:
*/ */
virtual bd_size_t get_read_size() const; virtual bd_size_t get_read_size() const;
/** Get the size of a programable block /** Get the size of a programmable block
* *
* @return Size of a programable block in bytes * @return Size of a programmable block in bytes
*/ */
virtual bd_size_t get_program_size() const; virtual bd_size_t get_program_size() const;

View File

@ -187,9 +187,9 @@ public:
*/ */
virtual bd_size_t get_read_size() const; virtual bd_size_t get_read_size() const;
/** Get the size of a programable block /** Get the size of a programmable block
* *
* @return Size of a programable block in bytes * @return Size of a programmable block in bytes
* @note Must be a multiple of the read size * @note Must be a multiple of the read size
*/ */
virtual bd_size_t get_program_size() const; virtual bd_size_t get_program_size() const;

View File

@ -114,9 +114,9 @@ public:
*/ */
virtual bd_size_t get_read_size() const; virtual bd_size_t get_read_size() const;
/** Get the size of a programable block /** Get the size of a programmable block
* *
* @return Size of a programable block in bytes * @return Size of a programmable block in bytes
* @note Must be a multiple of the read size * @note Must be a multiple of the read size
*/ */
virtual bd_size_t get_program_size() const; virtual bd_size_t get_program_size() const;

View File

@ -120,9 +120,9 @@ public:
*/ */
virtual bd_size_t get_read_size() const; virtual bd_size_t get_read_size() const;
/** Get the size of a programable block /** Get the size of a programmable block
* *
* @return Size of a programable block in bytes * @return Size of a programmable block in bytes
* @note Must be a multiple of the read size * @note Must be a multiple of the read size
*/ */
virtual bd_size_t get_program_size() const; virtual bd_size_t get_program_size() const;

View File

@ -724,6 +724,7 @@ void FATFileSystem::dir_seek(fs_dir_t dir, off_t offset)
FRESULT res; FRESULT res;
res = f_readdir(dh, &finfo); res = f_readdir(dh, &finfo);
dptr = dh->dptr;
if (res != FR_OK) { if (res != FR_OK) {
break; break;
} else if (finfo.fname[0] == 0) { } else if (finfo.fname[0] == 0) {

View File

@ -658,17 +658,17 @@ static int lfs_dir_append(lfs_t *lfs, lfs_dir_t *dir,
// we need to allocate a new dir block // we need to allocate a new dir block
if (!(0x80000000 & dir->d.size)) { if (!(0x80000000 & dir->d.size)) {
lfs_dir_t newdir; lfs_dir_t olddir = *dir;
int err = lfs_dir_alloc(lfs, &newdir); int err = lfs_dir_alloc(lfs, dir);
if (err) { if (err) {
return err; return err;
} }
newdir.d.tail[0] = dir->d.tail[0]; dir->d.tail[0] = olddir.d.tail[0];
newdir.d.tail[1] = dir->d.tail[1]; dir->d.tail[1] = olddir.d.tail[1];
entry->off = newdir.d.size - 4; entry->off = dir->d.size - 4;
lfs_entry_tole32(&entry->d); lfs_entry_tole32(&entry->d);
err = lfs_dir_commit(lfs, &newdir, (struct lfs_region[]){ err = lfs_dir_commit(lfs, dir, (struct lfs_region[]){
{entry->off, 0, &entry->d, sizeof(entry->d)}, {entry->off, 0, &entry->d, sizeof(entry->d)},
{entry->off, 0, data, entry->d.nlen} {entry->off, 0, data, entry->d.nlen}
}, 2); }, 2);
@ -677,10 +677,10 @@ static int lfs_dir_append(lfs_t *lfs, lfs_dir_t *dir,
return err; return err;
} }
dir->d.size |= 0x80000000; olddir.d.size |= 0x80000000;
dir->d.tail[0] = newdir.pair[0]; olddir.d.tail[0] = dir->pair[0];
dir->d.tail[1] = newdir.pair[1]; olddir.d.tail[1] = dir->pair[1];
return lfs_dir_commit(lfs, dir, NULL, 0); return lfs_dir_commit(lfs, &olddir, NULL, 0);
} }
int err = lfs_dir_fetch(lfs, dir, dir->d.tail); int err = lfs_dir_fetch(lfs, dir, dir->d.tail);

View File

@ -94,7 +94,7 @@ enum lfs_open_flags {
LFS_F_DIRTY = 0x10000, // File does not match storage LFS_F_DIRTY = 0x10000, // File does not match storage
LFS_F_WRITING = 0x20000, // File has been written since last flush LFS_F_WRITING = 0x20000, // File has been written since last flush
LFS_F_READING = 0x40000, // File has been read since last flush LFS_F_READING = 0x40000, // File has been read since last flush
LFS_F_ERRED = 0x80000, // An error occured during write LFS_F_ERRED = 0x80000, // An error occurred during write
}; };
// File seek flags // File seek flags
@ -465,7 +465,7 @@ int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir);
// Returns a negative error code on failure. // Returns a negative error code on failure.
int lfs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); int lfs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data);
// Prunes any recoverable errors that may have occured in the filesystem // Prunes any recoverable errors that may have occurred in the filesystem
// //
// Not needed to be called by user unless an operation is interrupted // Not needed to be called by user unless an operation is interrupted
// but the filesystem is still mounted. This is already called on first // but the filesystem is still mounted. This is already called on first

View File

@ -118,6 +118,7 @@ tests/test.py << TEST
sprintf((char*)buffer, "test%d", i); sprintf((char*)buffer, "test%d", i);
lfs_dir_read(&lfs, &dir[0], &info) => 1; lfs_dir_read(&lfs, &dir[0], &info) => 1;
strcmp(info.name, (char*)buffer) => 0; strcmp(info.name, (char*)buffer) => 0;
info.type => LFS_TYPE_DIR;
} }
lfs_dir_read(&lfs, &dir[0], &info) => 0; lfs_dir_read(&lfs, &dir[0], &info) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
@ -355,5 +356,70 @@ tests/test.py << TEST
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
TEST TEST
echo "--- Multi-block directory with files ---"
tests/test.py << TEST
lfs_mount(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "prickly-pear") => 0;
for (int i = 0; i < $LARGESIZE; i++) {
sprintf((char*)buffer, "prickly-pear/test%d", i);
lfs_file_open(&lfs, &file[0], (char*)buffer,
LFS_O_WRONLY | LFS_O_CREAT) => 0;
size = 6;
memcpy(wbuffer, "Hello", size);
lfs_file_write(&lfs, &file[0], wbuffer, size) => size;
lfs_file_close(&lfs, &file[0]) => 0;
}
lfs_unmount(&lfs) => 0;
TEST
tests/test.py << TEST
lfs_mount(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir[0], "prickly-pear") => 0;
lfs_dir_read(&lfs, &dir[0], &info) => 1;
strcmp(info.name, ".") => 0;
info.type => LFS_TYPE_DIR;
lfs_dir_read(&lfs, &dir[0], &info) => 1;
strcmp(info.name, "..") => 0;
info.type => LFS_TYPE_DIR;
for (int i = 0; i < $LARGESIZE; i++) {
sprintf((char*)buffer, "test%d", i);
lfs_dir_read(&lfs, &dir[0], &info) => 1;
strcmp(info.name, (char*)buffer) => 0;
info.type => LFS_TYPE_REG;
info.size => 6;
}
lfs_dir_read(&lfs, &dir[0], &info) => 0;
lfs_unmount(&lfs) => 0;
TEST
echo "--- Multi-block remove with files ---"
tests/test.py << TEST
lfs_mount(&lfs, &cfg) => 0;
lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOTEMPTY;
for (int i = 0; i < $LARGESIZE; i++) {
sprintf((char*)buffer, "prickly-pear/test%d", i);
lfs_remove(&lfs, (char*)buffer) => 0;
}
lfs_remove(&lfs, "prickly-pear") => 0;
lfs_unmount(&lfs) => 0;
TEST
tests/test.py << TEST
lfs_mount(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir[0], "/") => 0;
lfs_dir_read(&lfs, &dir[0], &info) => 1;
strcmp(info.name, ".") => 0;
info.type => LFS_TYPE_DIR;
lfs_dir_read(&lfs, &dir[0], &info) => 1;
strcmp(info.name, "..") => 0;
info.type => LFS_TYPE_DIR;
lfs_dir_read(&lfs, &dir[0], &info) => 1;
strcmp(info.name, "burito") => 0;
info.type => LFS_TYPE_REG;
lfs_dir_read(&lfs, &dir[0], &info) => 0;
lfs_dir_close(&lfs, &dir[0]) => 0;
lfs_unmount(&lfs) => 0;
TEST
echo "--- Results ---" echo "--- Results ---"
tests/stats.py tests/stats.py

View File

@ -135,5 +135,24 @@ tests/test.py << TEST
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
TEST TEST
echo "--- Many file test ---"
tests/test.py << TEST
lfs_format(&lfs, &cfg) => 0;
TEST
tests/test.py << TEST
// Create 300 files of 6 bytes
lfs_mount(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "directory") => 0;
for (unsigned i = 0; i < 300; i++) {
snprintf((char*)buffer, sizeof(buffer), "file_%03d", i);
lfs_file_open(&lfs, &file[0], (char*)buffer, LFS_O_WRONLY | LFS_O_CREAT) => 0;
size = 6;
memcpy(wbuffer, "Hello", size);
lfs_file_write(&lfs, &file[0], wbuffer, size) => size;
lfs_file_close(&lfs, &file[0]) => 0;
}
lfs_unmount(&lfs) => 0;
TEST
echo "--- Results ---" echo "--- Results ---"
tests/stats.py tests/stats.py

View File

@ -657,11 +657,11 @@ bool LoRaPHY::verify(verification_params_t* verify, phy_attributes_t phy_attribu
if (phy_params.dl_dwell_time_setting == 0) { if (phy_params.dl_dwell_time_setting == 0) {
return val_in_range(verify->datarate, return val_in_range(verify->datarate,
phy_params.min_rx_datarate, phy_params.min_rx_datarate,
phy_params.min_rx_datarate); phy_params.max_rx_datarate);
} else { } else {
return val_in_range(verify->datarate, return val_in_range(verify->datarate,
phy_params.dwell_limit_datarate, phy_params.dwell_limit_datarate,
phy_params.min_rx_datarate ); phy_params.max_rx_datarate);
} }
} }
case PHY_DEF_TX_POWER: case PHY_DEF_TX_POWER:

View File

@ -280,7 +280,7 @@ LoRaPHYAS923::LoRaPHYAS923(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payload_table; phy_params.payloads.table = (void *) max_payload_table;
phy_params.payloads.size = 8; phy_params.payloads.size = 8;
phy_params.payloads_with_repeater.table = (void *) max_payload_table_with_repeater; phy_params.payloads_with_repeater.table = (void *) max_payload_table_with_repeater;
phy_params.payloads.size = 8; phy_params.payloads_with_repeater.size = 8;
// dwell time setting, 400 ms // dwell time setting, 400 ms
phy_params.ul_dwell_time_setting = 1; phy_params.ul_dwell_time_setting = 1;

View File

@ -279,7 +279,7 @@ LoRaPHYAU915::LoRaPHYAU915(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payload_AU915; phy_params.payloads.table = (void *) max_payload_AU915;
phy_params.payloads.size = 16; phy_params.payloads.size = 16;
phy_params.payloads_with_repeater.table = (void *) max_payload_with_repeater_AU915; phy_params.payloads_with_repeater.table = (void *) max_payload_with_repeater_AU915;
phy_params.payloads.size = 16; phy_params.payloads_with_repeater.size = 16;
// dwell time setting // dwell time setting
phy_params.ul_dwell_time_setting = 0; phy_params.ul_dwell_time_setting = 0;

View File

@ -252,7 +252,7 @@ LoRaPHYCN470::LoRaPHYCN470(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payloads_CN470; phy_params.payloads.table = (void *) max_payloads_CN470;
phy_params.payloads.size = 6; phy_params.payloads.size = 6;
phy_params.payloads_with_repeater.table = (void *)max_payloads_with_repeater_CN470; phy_params.payloads_with_repeater.table = (void *)max_payloads_with_repeater_CN470;
phy_params.payloads.size = 6; phy_params.payloads_with_repeater.size = 6;
// dwell time setting // dwell time setting
phy_params.ul_dwell_time_setting = 0; phy_params.ul_dwell_time_setting = 0;

View File

@ -268,7 +268,7 @@ LoRaPHYCN779::LoRaPHYCN779(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payloads_CN779; phy_params.payloads.table = (void *) max_payloads_CN779;
phy_params.payloads.size = 8; phy_params.payloads.size = 8;
phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_CN779; phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_CN779;
phy_params.payloads.size = 8; phy_params.payloads_with_repeater.size = 8;
// dwell time setting // dwell time setting
phy_params.ul_dwell_time_setting = 0; phy_params.ul_dwell_time_setting = 0;

View File

@ -269,7 +269,7 @@ LoRaPHYEU433::LoRaPHYEU433(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payloads_EU433; phy_params.payloads.table = (void *) max_payloads_EU433;
phy_params.payloads.size = 8; phy_params.payloads.size = 8;
phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_EU433; phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_EU433;
phy_params.payloads.size = 8; phy_params.payloads_with_repeater.size = 8;
// dwell time setting // dwell time setting
phy_params.ul_dwell_time_setting = 0; phy_params.ul_dwell_time_setting = 0;

View File

@ -299,7 +299,7 @@ LoRaPHYEU868::LoRaPHYEU868(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payloads_EU868; phy_params.payloads.table = (void *) max_payloads_EU868;
phy_params.payloads.size = 8; phy_params.payloads.size = 8;
phy_params.payloads_with_repeater.table = (void *) max_payloads_repeater_EU868; phy_params.payloads_with_repeater.table = (void *) max_payloads_repeater_EU868;
phy_params.payloads.size = 8; phy_params.payloads_with_repeater.size = 8;
// dwell time setting // dwell time setting
phy_params.ul_dwell_time_setting = 0; phy_params.ul_dwell_time_setting = 0;

View File

@ -270,7 +270,7 @@ LoRaPHYIN865::LoRaPHYIN865(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payloads_IN865; phy_params.payloads.table = (void *) max_payloads_IN865;
phy_params.payloads.size = 8; phy_params.payloads.size = 8;
phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater; phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater;
phy_params.payloads.size = 8; phy_params.payloads_with_repeater.size = 8;
// dwell time setting // dwell time setting
phy_params.ul_dwell_time_setting = 0; phy_params.ul_dwell_time_setting = 0;

View File

@ -279,7 +279,7 @@ LoRaPHYKR920::LoRaPHYKR920(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payloads_KR920; phy_params.payloads.table = (void *) max_payloads_KR920;
phy_params.payloads.size = 6; phy_params.payloads.size = 6;
phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_KR920; phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_KR920;
phy_params.payloads.size = 6; phy_params.payloads_with_repeater.size = 6;
// dwell time setting // dwell time setting
phy_params.ul_dwell_time_setting = 0; phy_params.ul_dwell_time_setting = 0;

View File

@ -271,7 +271,7 @@ LoRaPHYUS915::LoRaPHYUS915(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payloads_US915; phy_params.payloads.table = (void *) max_payloads_US915;
phy_params.payloads.size = 16; phy_params.payloads.size = 16;
phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_US915; phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_US915;
phy_params.payloads.size = 16; phy_params.payloads_with_repeater.size = 16;
// dwell time setting // dwell time setting
phy_params.ul_dwell_time_setting = 0; phy_params.ul_dwell_time_setting = 0;

View File

@ -269,7 +269,7 @@ LoRaPHYUS915Hybrid::LoRaPHYUS915Hybrid(LoRaWANTimeHandler &lora_time)
phy_params.payloads.table = (void *) max_payloads_US915_HYBRID; phy_params.payloads.table = (void *) max_payloads_US915_HYBRID;
phy_params.payloads.size = 16; phy_params.payloads.size = 16;
phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_US915_HYBRID; phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_US915_HYBRID;
phy_params.payloads.size = 16; phy_params.payloads_with_repeater.size = 16;
// dwell time setting // dwell time setting
phy_params.ul_dwell_time_setting = 0; phy_params.ul_dwell_time_setting = 0;

View File

@ -10,7 +10,7 @@ This edition of mbed TLS has been adapted for mbed OS and imported from its stan
Getting Help and Support Getting Help and Support
------------------------ ------------------------
The [mbed TLS website](https://tls.mbed.org/) contains fulll documentation for the library, including function by function descriptions, knowledgebase articles, blogs and a support forum for questions to the community. The [mbed TLS website](https://tls.mbed.org/) contains full documentation for the library, including function by function descriptions, knowledgebase articles, blogs and a support forum for questions to the community.
Contributing to the Project Contributing to the Project

View File

@ -1,30 +1,105 @@
{ {
"name": "mbed-mesh-api", "name": "mbed-mesh-api",
"config": { "config": {
"heap-size": 32500, "heap-size": {
"use-malloc-for-heap": false, "help": "Nanostack's heap size (bytes: 0-65534)",
"6lowpan-nd-channel-mask": "0x7fff800", "value": 32500
"6lowpan-nd-channel-page": 0, },
"6lowpan-nd-channel": 0, "use-malloc-for-heap": {
"6lowpan-nd-panid-filter": "0xffff", "help": "Use `malloc()` for reserving the internal heap.",
"6lowpan-nd-security-mode": "NONE", "value": false
"6lowpan-nd-psk-key-id": 1, },
"6lowpan-nd-psk-key": "{0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf}", "6lowpan-nd-channel-mask": {
"6lowpan-nd-sec-level": 5, "help": "Channel mask, bit mask of channels to use.",
"6lowpan-nd-device-type": "NET_6LOWPAN_ROUTER", "value": "0x7fff800"
"thread-pskd": "\"ABCDEFGH\"", },
"thread-use-static-link-config": true, "6lowpan-nd-channel-page": {
"thread-config-channel-mask": "0x7fff800", "help": "0 for 2.4 GHz and 2 for sub-GHz radios.",
"thread-config-channel-page": 0, "value": 0
"thread-config-channel": 22, },
"thread-config-panid": "0x0700", "6lowpan-nd-channel": {
"thread-config-network-name": "\"Thread Network\"", "help": "RF channel to use when `channel_mask` is not defined (0-26).",
"thread-config-commissioning-dataset-timestamp": "0x10000", "value": 0
"thread-config-extended-panid": "{0xf1, 0xb5, 0xa1, 0xb2,0xc4, 0xd5, 0xa1, 0xbd }", },
"thread-master-key": "{0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}", "6lowpan-nd-panid-filter": {
"thread-config-ml-prefix": "{0xfd, 0x0, 0x0d, 0xb8, 0x0, 0x0, 0x0, 0x0}", "help": "Beacon PAN ID filter, 0xffff means no filtering.",
"thread-config-pskc": "{0xc8, 0xa6, 0x2e, 0xae, 0xf3, 0x68, 0xf3, 0x46, 0xa9, 0x9e, 0x57, 0x85, 0x98, 0x9d, 0x1c, 0xd0}", "value": "0xffff"
"thread-device-type": "MESH_DEVICE_TYPE_THREAD_ROUTER", },
"thread-security-policy": 255 "6lowpan-nd-security-mode": {
"help": "NONE or PSK to use either no security, or pre-shared network key.",
"value": "NONE"
},
"6lowpan-nd-psk-key-id": {
"help": "PSK key ID when PSK is enabled.",
"value": 1
},
"6lowpan-nd-psk-key": {
"help": "Pre-shared network key.",
"value": "{0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf}"
},
"6lowpan-nd-sec-level": {
"help": "Network security level (1-7). Use default `5`.",
"value": 5
},
"6lowpan-nd-device-type": {
"help": "Device mode (NET_6LOWPAN_ROUTER or NET_6LOWPAN_HOST). Router is routing packets from other device, creating a mesh network.",
"value": "NET_6LOWPAN_ROUTER"
},
"thread-pskd": {
"help": "Human-scaled commissioning credentials. Uppercase alphanumeric string (0-9, A-Y excluding I, O, Q and Z), 6-32 characters.",
"value": "\"ABCDEFGH\""
},
"thread-use-static-link-config": {
"help": "True: Use the below link config, False: Use commissioning, ignore the below link config.",
"value": true
},
"thread-config-channel-mask": {
"help": "Channel mask, 0x7ffff800 scans all channels.",
"value": "0x7fff800"
},
"thread-config-channel-page": {
"help": "Channel page, 0 for 2.4 GHz radio.",
"value": 0
},
"thread-config-channel": {
"help": "RF channel to use. (11-26)",
"value": 22
},
"thread-config-panid": {
"help": "Network identifier (0-0xFFFF)",
"value": "0x0700"
},
"thread-config-network-name": {
"help": "Network name (max 16 characters)",
"value": "\"Thread Network\""
},
"thread-config-commissioning-dataset-timestamp": {
"help": "[48 bit timestamp seconds]-[15 bit timestamp ticks]-[U bit] (0-0xFFFFFFFFFFFFFFFF)",
"value": "0x10000"
},
"thread-config-extended-panid": {
"help": "Extended PAN ID.",
"value": "{0xf1, 0xb5, 0xa1, 0xb2,0xc4, 0xd5, 0xa1, 0xbd }"
},
"thread-master-key": {
"help": "Network master key.",
"value": "{0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}"
},
"thread-config-ml-prefix": {
"help": "Mesh Local prefix.",
"value": "{0xfd, 0x0, 0x0d, 0xb8, 0x0, 0x0, 0x0, 0x0}"
},
"thread-config-pskc": {
"help": "Pre-Shared Key for the Commissioner.",
"value": "{0xc8, 0xa6, 0x2e, 0xae, 0xf3, 0x68, 0xf3, 0x46, 0xa9, 0x9e, 0x57, 0x85, 0x98, 0x9d, 0x1c, 0xd0}"
},
"thread-device-type": {
"help": "Supported device operating modes: MESH_DEVICE_TYPE_THREAD_ROUTER, MESH_DEVICE_TYPE_THREAD_SLEEPY_END_DEVICE, MESH_DEVICE_TYPE_THREAD_MINIMAL_END_DEVICE",
"value": "MESH_DEVICE_TYPE_THREAD_ROUTER"
},
"thread-security-policy": {
"help": "Commissioning security policy bits (0-0xFF)",
"value": 255
}
} }
} }

View File

@ -19,7 +19,6 @@
#include "netsocket/NetworkInterface.h" #include "netsocket/NetworkInterface.h"
/** CellularInterface class /** CellularInterface class
* *
* Common interface that is shared between ethernet hardware * Common interface that is shared between ethernet hardware
@ -30,6 +29,7 @@ class CellularInterface : public NetworkInterface
public: public:
/** CellularInterface lifetime /** CellularInterface lifetime
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularNetwork.h instead.")
virtual ~CellularInterface() {}; virtual ~CellularInterface() {};
/** Set the cellular network APN and credentials /** Set the cellular network APN and credentials
@ -39,6 +39,7 @@ public:
* @param password Optional password fot the APN * @param password Optional password fot the APN
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularNetwork.h instead.")
virtual nsapi_error_t set_credentials(const char *apn, virtual nsapi_error_t set_credentials(const char *apn,
const char *username = 0, const char *password = 0) = 0; const char *username = 0, const char *password = 0) = 0;
@ -49,6 +50,7 @@ public:
* @param password Optional password for your APN * @param password Optional password for your APN
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularNetwork.h instead.")
virtual nsapi_error_t connect(const char *apn, virtual nsapi_error_t connect(const char *apn,
const char *username = 0, const char *password = 0) = 0; const char *username = 0, const char *password = 0) = 0;
@ -58,12 +60,14 @@ public:
* *
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularNetwork.h instead.")
virtual nsapi_error_t connect() = 0; virtual nsapi_error_t connect() = 0;
/** Stop the interface /** Stop the interface
* *
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularNetwork.h instead.")
virtual nsapi_error_t disconnect() = 0; virtual nsapi_error_t disconnect() = 0;
}; };

View File

@ -51,21 +51,21 @@ public:
/** Get the local IP address /** Get the local IP address
* *
* @return Null-terminated representation of the local IP address * @return Null-terminated representation of the local IP address
* or null if no IP address has been recieved * or null if no IP address has been received
*/ */
virtual const char *get_ip_address(); virtual const char *get_ip_address();
/** Get the local network mask /** Get the local network mask
* *
* @return Null-terminated representation of the local network mask * @return Null-terminated representation of the local network mask
* or null if no network mask has been recieved * or null if no network mask has been received
*/ */
virtual const char *get_netmask(); virtual const char *get_netmask();
/** Get the local gateway /** Get the local gateway
* *
* @return Null-terminated representation of the local gateway * @return Null-terminated representation of the local gateway
* or null if no network mask has been recieved * or null if no network mask has been received
*/ */
virtual const char *get_gateway(); virtual const char *get_gateway();

View File

@ -130,7 +130,7 @@ protected:
/** Bind a specific address to a socket /** Bind a specific address to a socket
* *
* Binding a socket specifies the address and port on which to recieve * Binding a socket specifies the address and port on which to receive
* data. If the IP address is zeroed, only the port is bound. * data. If the IP address is zeroed, only the port is bound.
* *
* @param handle Socket handle * @param handle Socket handle

View File

@ -78,7 +78,7 @@ public:
/** Bind a specific address to a socket /** Bind a specific address to a socket
* *
* Binding a socket specifies the address and port on which to recieve * Binding a socket specifies the address and port on which to receive
* data. * data.
* *
* @param port Local port to bind * @param port Local port to bind
@ -88,7 +88,7 @@ public:
/** Bind a specific address to a socket /** Bind a specific address to a socket
* *
* Binding a socket specifies the address and port on which to recieve * Binding a socket specifies the address and port on which to receive
* data. If the IP address is zeroed, only the port is bound. * data. If the IP address is zeroed, only the port is bound.
* *
* @param address Null-terminated local address to bind * @param address Null-terminated local address to bind
@ -99,7 +99,7 @@ public:
/** Bind a specific address to a socket /** Bind a specific address to a socket
* *
* Binding a socket specifies the address and port on which to recieve * Binding a socket specifies the address and port on which to receive
* data. If the IP address is zeroed, only the port is bound. * data. If the IP address is zeroed, only the port is bound.
* *
* @param address Local address to bind * @param address Local address to bind

View File

@ -23,7 +23,9 @@
/** /**
* OnboardCellularInterface is an on-board specific implementation. * OnboardCellularInterface is an on-board specific implementation.
*
*/ */
OnboardCellularInterface::OnboardCellularInterface(bool debug) : OnboardCellularInterface::OnboardCellularInterface(bool debug) :
UARTCellularInterface(MDMTXD, MDMRXD, MDMDCD, MDMRTS, UARTCellularInterface(MDMTXD, MDMRXD, MDMDCD, MDMRTS,
MDMCTS, MDMRI, MDMDTR, MDMDSR, MDMCTS, MDMRI, MDMDTR, MDMDSR,

View File

@ -32,12 +32,15 @@ typedef mbed::EasyCellularConnection OnboardCellularInterface;
* could be derived from different implementation classes. * could be derived from different implementation classes.
* Portable applications should only rely on it being a CellularBase. * Portable applications should only rely on it being a CellularBase.
*/ */
class OnboardCellularInterface : public UARTCellularInterface { class OnboardCellularInterface : public UARTCellularInterface {
public: public:
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularPower.h instead.")
OnboardCellularInterface(bool debug = false); OnboardCellularInterface(bool debug = false);
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularPower.h instead.")
virtual ~OnboardCellularInterface(); virtual ~OnboardCellularInterface();
protected: protected:
@ -46,6 +49,7 @@ protected:
* modem_init() is equivalent to plugging in the device, for example, attaching power and serial port. * modem_init() is equivalent to plugging in the device, for example, attaching power and serial port.
* Uses onboard_modem_api.h where the target provides the implementation of onboard_modem_api. * Uses onboard_modem_api.h where the target provides the implementation of onboard_modem_api.
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularPower.h instead.")
virtual void modem_init(); virtual void modem_init();
/** Sets the modem in unplugged state /** Sets the modem in unplugged state
@ -54,6 +58,7 @@ protected:
* and serial port. This puts the modem in lowest power state. * and serial port. This puts the modem in lowest power state.
* Uses onboard_modem_api.h where the target provides the implementation of onboard_modem_api. * Uses onboard_modem_api.h where the target provides the implementation of onboard_modem_api.
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularPower.h instead.")
virtual void modem_deinit(); virtual void modem_deinit();
/** Powers up the modem /** Powers up the modem
@ -62,6 +67,7 @@ protected:
* The driver may repeat this if the modem is not responsive to AT commands. * The driver may repeat this if the modem is not responsive to AT commands.
* Uses onboard_modem_api.h where the target provides the implementation of onboard_modem_api. * Uses onboard_modem_api.h where the target provides the implementation of onboard_modem_api.
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularPower.h instead.")
virtual void modem_power_up(); virtual void modem_power_up();
/** Powers down the modem /** Powers down the modem
@ -69,6 +75,7 @@ protected:
* modem_power_down() is equivalent to turning off the modem by button press. * modem_power_down() is equivalent to turning off the modem by button press.
* Uses onboard_modem_api.h where the target provides the implementation of onboard_modem_api. * Uses onboard_modem_api.h where the target provides the implementation of onboard_modem_api.
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/framework/API/CellularPower.h instead.")
virtual void modem_power_down(); virtual void modem_power_down();
}; };

View File

@ -19,7 +19,7 @@
#include <string.h> #include <string.h>
#include "nsapi_ppp.h" #include "nsapi_ppp.h"
#if MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #if MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
#include "utils/APN_db.h" #include "APN_db.h"
#endif //MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP #endif //MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
#if defined(FEATURE_COMMON_PAL) #if defined(FEATURE_COMMON_PAL)
#include "mbed_trace.h" #include "mbed_trace.h"
@ -570,12 +570,12 @@ nsapi_error_t PPPCellularInterface::connect()
user_specified_apn = true; user_specified_apn = true;
#endif #endif
} }
if (is_connected()) { if (is_connected()) {
return NSAPI_ERROR_IS_CONNECTED; return NSAPI_ERROR_IS_CONNECTED;
} else if (_connect_status == NSAPI_STATUS_CONNECTING) { } else if (_connect_status == NSAPI_STATUS_CONNECTING) {
return NSAPI_ERROR_ALREADY; return NSAPI_ERROR_ALREADY;
} }
_connect_status = NSAPI_STATUS_CONNECTING; _connect_status = NSAPI_STATUS_CONNECTING;
if (_connection_status_cb) { if (_connection_status_cb) {
@ -677,7 +677,7 @@ nsapi_error_t PPPCellularInterface::connect()
} }
tr_info("The APN being used is %s.\n", _apn); tr_info("The APN being used is %s.\n", _apn);
/* Attempt to enter data mode */ /* Attempt to enter data mode */
success = set_atd(_at); //enter into Data mode with the modem success = set_atd(_at); //enter into Data mode with the modem
if (!success) { if (!success) {

View File

@ -99,6 +99,7 @@ typedef struct {
* derived from in order to provide forms for specific interfaces, as well as * derived from in order to provide forms for specific interfaces, as well as
* adding extra power and reset controls alongside the FileHandle. * adding extra power and reset controls alongside the FileHandle.
*/ */
class PPPCellularInterface : public CellularBase { class PPPCellularInterface : public CellularBase {
public: public:
@ -108,8 +109,10 @@ public:
* The file handle pointer is not accessed within the constructor, only recorded for later * The file handle pointer is not accessed within the constructor, only recorded for later
* use - this permits a derived class to pass a pointer to a not-yet-constructed member object. * use - this permits a derived class to pass a pointer to a not-yet-constructed member object.
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
PPPCellularInterface(FileHandle *fh, bool debug = false); PPPCellularInterface(FileHandle *fh, bool debug = false);
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual ~PPPCellularInterface(); virtual ~PPPCellularInterface();
/** Set the Cellular network credentials /** Set the Cellular network credentials
@ -120,6 +123,7 @@ public:
* @param uname optionally, Username * @param uname optionally, Username
* @param pwd optionally, password * @param pwd optionally, password
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual void set_credentials(const char *apn, const char *uname = 0, virtual void set_credentials(const char *apn, const char *uname = 0,
const char *pwd = 0); const char *pwd = 0);
@ -127,6 +131,7 @@ public:
* *
* @param sim_pin PIN for the SIM card * @param sim_pin PIN for the SIM card
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual void set_sim_pin(const char *sim_pin); virtual void set_sim_pin(const char *sim_pin);
/** Start the interface /** Start the interface
@ -144,6 +149,7 @@ public:
* @param pwd optionally, password * @param pwd optionally, password
* @return NSAPI_ERROR_OK on success, or negative error code on failure * @return NSAPI_ERROR_OK on success, or negative error code on failure
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0, virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0,
const char *uname = 0, const char *pwd = 0); const char *uname = 0, const char *pwd = 0);
@ -167,6 +173,7 @@ public:
* Preferred method is to setup APN using 'set_credentials()' API. * Preferred method is to setup APN using 'set_credentials()' API.
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual nsapi_error_t connect(); virtual nsapi_error_t connect();
/** Attempt to disconnect from the network /** Attempt to disconnect from the network
@ -176,6 +183,7 @@ public:
* *
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual nsapi_error_t disconnect(); virtual nsapi_error_t disconnect();
/** Adds or removes a SIM facility lock /** Adds or removes a SIM facility lock
@ -188,6 +196,7 @@ public:
* @param set can be set to true if the SIM pin check is supposed to be enabled * @param set can be set to true if the SIM pin check is supposed to be enabled
* and vice versa. * and vice versa.
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
void set_sim_pin_check(bool set); void set_sim_pin_check(bool set);
/** Change the pin for the SIM card /** Change the pin for the SIM card
@ -198,6 +207,7 @@ public:
* *
* @param new_pin new pin to be used in string format * @param new_pin new pin to be used in string format
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
void set_new_sim_pin(const char *new_pin); void set_new_sim_pin(const char *new_pin);
/** Check if the connection is currently established or not /** Check if the connection is currently established or not
@ -206,27 +216,31 @@ public:
* connected to an external packet data network using PPP, isConnected() * connected to an external packet data network using PPP, isConnected()
* API returns true and false otherwise. * API returns true and false otherwise.
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual bool is_connected(); virtual bool is_connected();
/** Get the local IP address /** Get the local IP address
* *
* @return Null-terminated representation of the local IP address * @return Null-terminated representation of the local IP address
* or null if no IP address has been recieved * or null if no IP address has been received
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual const char *get_ip_address(); virtual const char *get_ip_address();
/** Get the local network mask /** Get the local network mask
* *
* @return Null-terminated representation of the local network mask * @return Null-terminated representation of the local network mask
* or null if no network mask has been recieved * or null if no network mask has been received
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual const char *get_netmask(); virtual const char *get_netmask();
/** Get the local gateways /** Get the local gateways
* *
* @return Null-terminated representation of the local gateway * @return Null-terminated representation of the local gateway
* or null if no network mask has been recieved * or null if no network mask has been received
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual const char *get_gateway(); virtual const char *get_gateway();
@ -234,18 +248,21 @@ public:
* *
* @param on set true to enable debug traces * @param on set true to enable debug traces
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
void modem_debug_on(bool on); void modem_debug_on(bool on);
/** Register callback for status reporting /** Register callback for status reporting
* *
* @param status_cb The callback for status changes * @param status_cb The callback for status changes
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual void attach(Callback<void(nsapi_event_t, intptr_t)> status_cb); virtual void attach(Callback<void(nsapi_event_t, intptr_t)> status_cb);
/** Get the connection status /** Get the connection status
* *
* @return The connection status according to nsapi_connection_status_t * @return The connection status according to nsapi_connection_status_t
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual nsapi_connection_status_t get_connection_status() const; virtual nsapi_connection_status_t get_connection_status() const;
/** Set blocking status of connect() which by default should be blocking /** Set blocking status of connect() which by default should be blocking
@ -253,6 +270,7 @@ public:
* @param blocking true if connect is blocking * @param blocking true if connect is blocking
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual nsapi_error_t set_blocking(bool blocking); virtual nsapi_error_t set_blocking(bool blocking);
private: private:
@ -274,7 +292,7 @@ private:
nsapi_error_t initialize_sim_card(); nsapi_error_t initialize_sim_card();
nsapi_error_t setup_context_and_credentials(); nsapi_error_t setup_context_and_credentials();
bool power_up(); bool power_up();
void power_down(); void power_down();
void ppp_status_cb(nsapi_event_t, intptr_t); void ppp_status_cb(nsapi_event_t, intptr_t);
protected: protected:

View File

@ -14,6 +14,7 @@
*/ */
#include "UARTCellularInterface.h" #include "UARTCellularInterface.h"
#if NSAPI_PPP_AVAILABLE #if NSAPI_PPP_AVAILABLE
UARTCellularInterface::UARTCellularInterface(PinName txd, PinName rxd, PinName dcd, PinName rts, PinName cts, PinName ri, UARTCellularInterface::UARTCellularInterface(PinName txd, PinName rxd, PinName dcd, PinName rts, PinName cts, PinName ri,

View File

@ -29,15 +29,18 @@
* It constructs a FileHandle and passes it back to its base class as well as overrides * It constructs a FileHandle and passes it back to its base class as well as overrides
* enable_hup() in the base class. * enable_hup() in the base class.
*/ */
class UARTCellularInterface : public PPPCellularInterface { class UARTCellularInterface : public PPPCellularInterface {
public: public:
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
UARTCellularInterface(PinName tx, PinName rx, PinName dcd = NC, PinName rts = NC, PinName cts = NC, PinName ri = NC, UARTCellularInterface(PinName tx, PinName rx, PinName dcd = NC, PinName rts = NC, PinName cts = NC, PinName ri = NC,
PinName dtr = NC, PinName dsr = NC, int baud = MBED_CONF_PPP_CELL_IFACE_BAUD_RATE, PinName dtr = NC, PinName dsr = NC, int baud = MBED_CONF_PPP_CELL_IFACE_BAUD_RATE,
bool active_high = false, bool active_high = false,
bool debug = false); bool debug = false);
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual ~UARTCellularInterface(); virtual ~UARTCellularInterface();
private: private:
@ -53,6 +56,7 @@ protected:
* signaling is not desired. enable_hup() controls whether this function should be * signaling is not desired. enable_hup() controls whether this function should be
* active. * active.
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use mbed-os/features/cellular/easy_cellular/EasyCellularConnection.h instead.")
virtual void enable_hup(bool enable); virtual void enable_hup(bool enable);
}; };

View File

@ -33,7 +33,7 @@
#include "netsocket/NetworkInterface.h" #include "netsocket/NetworkInterface.h"
#include "netsocket/EthInterface.h" #include "netsocket/EthInterface.h"
#include "netsocket/WiFiInterface.h" #include "netsocket/WiFiInterface.h"
#include "netsocket/CellularInterface.h" #include "netsocket/CellularBase.h"
#include "netsocket/MeshInterface.h" #include "netsocket/MeshInterface.h"
#include "netsocket/Socket.h" #include "netsocket/Socket.h"

View File

@ -403,7 +403,7 @@ typedef struct nsapi_stack_api
/** Bind a specific address to a socket /** Bind a specific address to a socket
* *
* Binding a socket specifies the address and port on which to recieve * Binding a socket specifies the address and port on which to receive
* data. If the IP address is zeroed, only the port is bound. * data. If the IP address is zeroed, only the port is bound.
* *
* @param stack Stack handle * @param stack Stack handle

View File

@ -33,7 +33,7 @@ Each item is kept in an entry containing a header and data, where the header hol
### Enabling NVStore and configuring it for your board ### Enabling NVStore and configuring it for your board
NVStore is enabled by default for all devices with the internal flash driver (have "FLASH" in the device_has attribute). NVStore is enabled by default for all devices with the internal flash driver (have "FLASH" in the device_has attribute).
One can disable it by setting its "enabled" attribute to false. One can disable it by setting its "enabled" attribute to false.
Unless specifically configured by the user, NVStore selects the last two flash sectors as its areas, with the mininum size of 4KBs, Unless specifically configured by the user, NVStore selects the last two flash sectors as its areas, with the minimum size of 4KBs,
meaning that if the sectors are smaller, few continuous ones will be used for each area. meaning that if the sectors are smaller, few continuous ones will be used for each area.
The user can override this by setting the addresses and sizes of both areas in` mbed_lib.json` on a per board basis. The user can override this by setting the addresses and sizes of both areas in` mbed_lib.json` on a per board basis.
In this case, all following four attributes need to be set: In this case, all following four attributes need to be set:

View File

@ -50,6 +50,11 @@ typedef enum {
// defines 2 areas - active and nonactive, not configurable // defines 2 areas - active and nonactive, not configurable
#define NVSTORE_NUM_AREAS 2 #define NVSTORE_NUM_AREAS 2
/** NVStore class
*
* Class for storing data by keys in the internal flash
*/
class NVStore : private mbed::NonCopyable<NVStore> { class NVStore : private mbed::NonCopyable<NVStore> {
public: public:
@ -399,6 +404,7 @@ private:
int do_set(uint16_t key, uint16_t buf_size, const void *buf, uint16_t flags); int do_set(uint16_t key, uint16_t buf_size, const void *buf, uint16_t flags);
}; };
/** @}*/
#endif // NVSTORE_ENABLED #endif // NVSTORE_ENABLED

View File

@ -936,7 +936,7 @@ The following provides general notes on the handling of errors:
- Supported backends may include non-volatile storage (flash) and SRAM. - Supported backends may include non-volatile storage (flash) and SRAM.
- For example. if a non-volatile storage (flash) backend is supported, then the flushing of data to the NV store must be atomic. - For example. if a non-volatile storage (flash) backend is supported, then the flushing of data to the NV store must be atomic.
This may require that flushing of data to flash is commited using an atomic write operation e.g. of a CRC32 value for the This may require that flushing of data to flash is commited using an atomic write operation e.g. of a CRC32 value for the
commit data. If power loss occured during the atomic write then the CRC32 would be invalid, the previously written data would commit data. If power loss occurred during the atomic write then the CRC32 would be invalid, the previously written data would
not be valid, and the system would have to revert to a previous version of the data that has successfully commited the correct CRC32 not be valid, and the system would have to revert to a previous version of the data that has successfully commited the correct CRC32
value. value.
@ -1080,7 +1080,7 @@ split the writing of the value into M writes, where N/M is smaller than availabl
In the case the the Write() call fails with return code `ARM_CFSTORE_DRIVER_ERROR_OUT_OF_MEMORY` In the case the the Write() call fails with return code `ARM_CFSTORE_DRIVER_ERROR_OUT_OF_MEMORY`
then the client may retry the write transaction with a smaller length (less bytes). then the client may retry the write transaction with a smaller length (less bytes).
Further, a client of the Write() function should alway check the returned value of the Further, a client of the Write() function should always check the returned value of the
len argment as this records the actual number of bytes written. CFSTORE may be able to len argment as this records the actual number of bytes written. CFSTORE may be able to
write a number of bytes less that the total number in the data buffer supplied by the write a number of bytes less that the total number in the data buffer supplied by the
client. The unwritten bytes should be supplied to a second call to Write(). client. The unwritten bytes should be supplied to a second call to Write().

View File

@ -1555,7 +1555,7 @@ static int32_t cfstore_flash_map_error(int32_t flash_journal_status_code)
* In flash journal async mode, when: * In flash journal async mode, when:
* - a FlashJournal_xxx() function has been invoked, and * - a FlashJournal_xxx() function has been invoked, and
* - before the async completion has been received and processed * - before the async completion has been received and processed
* the application context code should alway co-ordinate access to * the application context code should always coordinate access to
* context variables modified by interrupt and application context * context variables modified by interrupt and application context
* by use of the critical_section_xxx. * by use of the critical_section_xxx.
*/ */
@ -3497,7 +3497,7 @@ static int32_t cfstore_create(const char* key_name, ARM_CFSTORE_SIZE value_len,
ret = cfstore_recreate(key_name, value_len, hkey, &hkvt); ret = cfstore_recreate(key_name, value_len, hkey, &hkvt);
goto out1; goto out1;
} }
/* not a valid hkvt implying the key_name wasnt found */ /* not a valid hkvt implying the key_name wasn't found */
/* create new key */ /* create new key */
ret = cfstore_validate_key_desc(kdesc); ret = cfstore_validate_key_desc(kdesc);

View File

@ -202,6 +202,12 @@ USBHAL::USBHAL(void) {
__HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE(); __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();
__HAL_RCC_USB_OTG_HS_CLK_ENABLE(); __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
#elif defined(TARGET_STEVAL_3DP001V1)
__HAL_RCC_GPIOB_CLK_ENABLE();
pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS)); // DM
pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS)); // DP
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
#else #else
#error "USB pins are not configured !" #error "USB pins are not configured !"
#endif #endif

View File

@ -20,6 +20,7 @@
#if defined(TARGET_NUCLEO_F207ZG) || \ #if defined(TARGET_NUCLEO_F207ZG) || \
defined(TARGET_NUCLEO_F401RE) || \ defined(TARGET_NUCLEO_F401RE) || \
defined(TARGET_STEVAL_3DP001V1) || \
defined(TARGET_NUCLEO_F411RE) || \ defined(TARGET_NUCLEO_F411RE) || \
defined(TARGET_NUCLEO_F412ZG) || \ defined(TARGET_NUCLEO_F412ZG) || \
defined(TARGET_NUCLEO_F413ZH) || \ defined(TARGET_NUCLEO_F413ZH) || \

View File

@ -259,6 +259,11 @@ USBHALHost::USBHALHost()
pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)); // ID pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)); // ID
pin_function(PC_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS)); // VBUS pin_function(PC_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS)); // VBUS
#elif defined(TARGET_STEVAL_3DP001V1)
__HAL_RCC_GPIOA_CLK_ENABLE();
pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS)); // DM
pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS)); // DP
#else #else
#error "USB pins are not configured !" #error "USB pins are not configured !"
#endif #endif

View File

@ -40,7 +40,7 @@ int ethernet_write(const char *data, int size);
// send ethernet write buffer, returning the packet size sent // send ethernet write buffer, returning the packet size sent
int ethernet_send(void); int ethernet_send(void);
// recieve from ethernet buffer, returning packet size, or 0 if no packet // receive from ethernet buffer, returning packet size, or 0 if no packet
int ethernet_receive(void); int ethernet_receive(void);
// read size bytes in to data, return actual num bytes read (0..size) // read size bytes in to data, return actual num bytes read (0..size)

View File

@ -1,3 +1,5 @@
/** \addtogroup hal */
/** @{*/
/* mbed Microcontroller Library /* mbed Microcontroller Library
* Copyright (c) 2017 ARM Limited * Copyright (c) 2017 ARM Limited
* *
@ -26,8 +28,7 @@ extern "C" {
#endif #endif
/** /**
* @defgroup hal_itm_port ITM Stimulus Ports * \defgroup itm_hal Instrumented Trace Macrocell HAL API
*
* @{ * @{
*/ */
@ -35,13 +36,6 @@ enum {
ITM_PORT_SWO = 0 ITM_PORT_SWO = 0
}; };
/**@}*/
/**
* \defgroup itm_hal Instrumented Trace Macrocell HAL API
* @{
*/
/** /**
* @brief Target specific initialization function. * @brief Target specific initialization function.
* This function is responsible for initializing and configuring * This function is responsible for initializing and configuring
@ -89,3 +83,5 @@ uint32_t mbed_itm_send(uint32_t port, uint32_t data);
#endif #endif
#endif /* MBED_ITM_API_H */ #endif /* MBED_ITM_API_H */
/**@}*/

View File

@ -30,44 +30,20 @@ static uint16_t deep_sleep_lock = 0U;
#ifdef MBED_SLEEP_TRACING_ENABLED #ifdef MBED_SLEEP_TRACING_ENABLED
// Length of the identifier extracted from the driver name to store for logging.
#define IDENTIFIER_WIDTH 15
// Number of drivers that can be stored in the structure // Number of drivers that can be stored in the structure
#define STATISTIC_COUNT 10 #define STATISTIC_COUNT 10
typedef struct sleep_statistic { typedef struct sleep_statistic {
char identifier[IDENTIFIER_WIDTH]; const char* identifier;
uint8_t count; uint8_t count;
} sleep_statistic_t; } sleep_statistic_t;
static sleep_statistic_t sleep_stats[STATISTIC_COUNT]; static sleep_statistic_t sleep_stats[STATISTIC_COUNT];
static const char* strip_path(const char* const filename)
{
char *output = strrchr(filename, '/');
if (output != NULL) {
return output + 1;
}
output = strrchr(filename, '\\');
if (output != NULL) {
return output + 1;
}
return filename;
}
static sleep_statistic_t* sleep_tracker_find(const char *const filename) static sleep_statistic_t* sleep_tracker_find(const char *const filename)
{ {
char temp[IDENTIFIER_WIDTH];
strncpy(temp, filename, IDENTIFIER_WIDTH);
temp[IDENTIFIER_WIDTH - 1] = '\0';
// Search for the a driver matching the current name and return it's index
for (int i = 0; i < STATISTIC_COUNT; ++i) { for (int i = 0; i < STATISTIC_COUNT; ++i) {
if (strcmp(sleep_stats[i].identifier, temp) == 0) { if (sleep_stats[i].identifier == filename) {
return &sleep_stats[i]; return &sleep_stats[i];
} }
} }
@ -77,15 +53,9 @@ static sleep_statistic_t* sleep_tracker_find(const char *const filename)
static sleep_statistic_t* sleep_tracker_add(const char* const filename) static sleep_statistic_t* sleep_tracker_add(const char* const filename)
{ {
char temp[IDENTIFIER_WIDTH];
strncpy(temp, filename, IDENTIFIER_WIDTH);
temp[IDENTIFIER_WIDTH - 1] = '\0';
for (int i = 0; i < STATISTIC_COUNT; ++i) { for (int i = 0; i < STATISTIC_COUNT; ++i) {
if (sleep_stats[i].identifier[0] == '\0') { if (sleep_stats[i].identifier == NULL) {
core_util_critical_section_enter(); sleep_stats[i].identifier = filename;
strncpy(sleep_stats[i].identifier, temp, sizeof(temp));
core_util_critical_section_exit();
return &sleep_stats[i]; return &sleep_stats[i];
} }
@ -104,45 +74,42 @@ static void sleep_tracker_print_stats(void)
continue; continue;
} }
if (sleep_stats[i].identifier[0] == '\0') { if (sleep_stats[i].identifier == NULL) {
return; return;
} }
debug("[id: %s, count: %u]\r\n", sleep_stats[i].identifier, debug("[id: %s, count: %u]\r\n", sleep_stats[i].identifier,
sleep_stats[i].count); sleep_stats[i].count);
} }
} }
void sleep_tracker_lock(const char* const filename, int line) void sleep_tracker_lock(const char* const filename, int line)
{ {
const char* const stripped_path = strip_path(filename); sleep_statistic_t *stat = sleep_tracker_find(filename);
sleep_statistic_t* stat = sleep_tracker_find(stripped_path);
// Entry for this driver does not exist, create one. // Entry for this driver does not exist, create one.
if (stat == NULL) { if (stat == NULL) {
stat = sleep_tracker_add(stripped_path); stat = sleep_tracker_add(filename);
} }
core_util_atomic_incr_u8(&stat->count, 1); core_util_atomic_incr_u8(&stat->count, 1);
debug("LOCK: %s, ln: %i, lock count: %u\r\n", stripped_path, line, deep_sleep_lock); debug("LOCK: %s, ln: %i, lock count: %u\r\n", filename, line, deep_sleep_lock);
} }
void sleep_tracker_unlock(const char* const filename, int line) void sleep_tracker_unlock(const char* const filename, int line)
{ {
const char* const stripped_path = strip_path(filename); sleep_statistic_t *stat = sleep_tracker_find(filename);
sleep_statistic_t* stat = sleep_tracker_find(stripped_path);
// Entry for this driver does not exist, something went wrong. // Entry for this driver does not exist, something went wrong.
if (stat == NULL) { if (stat == NULL) {
debug("Unlocking sleep for driver that was not previously locked: %s, ln: %i\r\n", stripped_path, line); debug("Unlocking sleep for driver that was not previously locked: %s, ln: %i\r\n", filename, line);
return; return;
} }
core_util_atomic_decr_u8(&stat->count, 1); core_util_atomic_decr_u8(&stat->count, 1);
debug("UNLOCK: %s, ln: %i, lock count: %u\r\n", stripped_path, line, deep_sleep_lock); debug("UNLOCK: %s, ln: %i, lock count: %u\r\n", filename, line, deep_sleep_lock);
} }
#endif // MBED_SLEEP_TRACING_ENABLED #endif // MBED_SLEEP_TRACING_ENABLED

View File

@ -119,7 +119,7 @@ int spi_master_write(spi_t *obj, int value);
/** Write a block out in master mode and receive a value /** Write a block out in master mode and receive a value
* *
* The total number of bytes sent and recieved will be the maximum of * The total number of bytes sent and received will be the maximum of
* tx_length and rx_length. The bytes written will be padded with the * tx_length and rx_length. The bytes written will be padded with the
* value 0xff. * value 0xff.
* *

Some files were not shown because too many files have changed in this diff Show More