Skip to content

Commit

Permalink
Merge pull request #5 from IRNAS/release/v1.0.1
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
vid553 committed Jun 16, 2023
2 parents 571a0f3 + 8999b3e commit 39a58e6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 22 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]

## [1.0.1] - 2023-06-16

### Fixed

- Log level for printing trace array (set to debug).
- Battery level to use correct scaling.

### Changed

- Refactor HAL time management to use compensation (Note that the compensation value is still 0 by default).


## [1.0.0] - 2022-12-12

### Added
Expand All @@ -29,6 +41,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- stream
- tx_rx_continous

[Unreleased]: https://github.com/IRNAS/SWL2001-Zephyr/compare/v1.0.0...HEAD
[Unreleased]: https://github.com/IRNAS/SWL2001-Zephyr/compare/v1.0.1...HEAD

[1.0.1]: https://github.com/IRNAS/SWL2001-Zephyr/compare/v1.0.0...v1.0.1

[1.0.0]: https://github.com/IRNAS/SWL2001-Zephyr/compare/52a1e1e0301ef9fc9b7c1418cee0aed9ef185e0d...v1.0.0
2 changes: 1 addition & 1 deletion drivers/apps_common/smtc_app/smtc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static uint32_t prv_convert_gps_to_utc_time(uint32_t gps_time_s)
/**
* @brief Callback for modem hal
*/
static int prv_get_battery_level_cb(uint8_t *value)
static int prv_get_battery_level_cb(uint32_t *value)
{
if (!prv_env_callbacks || !prv_env_callbacks->get_battery_level) {
return -1;
Expand Down
7 changes: 4 additions & 3 deletions drivers/apps_common/smtc_app/smtc_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,14 @@ struct smtc_app_env_callbacks {
/**
* @brief Get battery level callback
*
* @param [out] battery_level The battery level (in %, where 100% means full battery). The
* application should set this to the most recent battery level it has avaliable
* @param [out] battery_level The battery level in permilles (‰) (where 1000‰ means full
* battery). The application should set this to the most recent battery level it has
* avaliable
*
* @return int 0 if the battery level was set, or a negative error code if no valid battery
* level is available
*/
int (*get_battery_level)(uint8_t *battery_level);
int (*get_battery_level)(uint32_t *battery_level);

/**
* @brief Get temperature callback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ void smtc_modem_hal_print_trace_array_dbg(char *msg, uint8_t *array, uint32_t le
{
#ifdef CONFIG_LOG
prv_string_trim(msg);
LOG_HEXDUMP_INF(array, len, msg);
LOG_HEXDUMP_DBG(array, len, msg);
#endif /* CONFIG_LOG */
}
23 changes: 14 additions & 9 deletions drivers/smtc_modem_hal_impl/smtc_modem_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ uint32_t smtc_modem_hal_get_time_in_s(void)
return (uint32_t)(time_ms / 1000);
}

int32_t smtc_modem_hal_get_time_compensation_in_s(void)
{
/* There is no compensation going on */
return 0;
}

/* There is no difference in zephyr between "uncompensated" and "compensated" time,
* so we just use the same implementation.
* Semtech does something similar in their HAl for stm
*/
uint32_t smtc_modem_hal_get_compensated_time_in_s(void)
{
return smtc_modem_hal_get_time_in_s();
}

int32_t smtc_modem_hal_get_time_compensation_in_s(void)
{
/* There is no compensation going on */
return 0;
return smtc_modem_hal_get_time_in_s() + smtc_modem_hal_get_time_compensation_in_s();
}

uint32_t smtc_modem_hal_get_time_in_ms(void)
Expand Down Expand Up @@ -426,14 +426,19 @@ uint32_t smtc_modem_hal_get_radio_tcxo_startup_delay_ms(void)
/* This is called when LoRa Cloud sends a device status request */
uint8_t smtc_modem_hal_get_battery_level(void)
{
uint8_t battery;
uint32_t battery;
int ret = prv_get_battery_level_cb(&battery);

if (ret) {
return 0;
}

return battery;
if (battery > 1000) {
return 255;
}

/* scale 0-1000 to 0-255 */
return (uint8_t)((float)battery * 0.255);
}

/* This is called when DM info required is */
Expand Down
6 changes: 3 additions & 3 deletions drivers/smtc_modem_hal_impl/smtc_modem_hal_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ extern "C" {
/**
* @brief Get battery level callback
*
* @param [out] value The battery level (in %, where 100% means full battery). The application
* should set this to the most recent battery level it has avaliable
* @param [out] value The battery level (in permille (‰) , where 1000 ‰ means full battery). The
* application should set this to the most recent battery level it has avaliable
*
* @return int 0 if the battery level was set, or a negative error code if no valid battery
* level is available
*/
typedef int (*get_battery_level_cb_t)(uint8_t *value);
typedef int (*get_battery_level_cb_t)(uint32_t *value);

/**
* @brief Get temperature callback
Expand Down
9 changes: 5 additions & 4 deletions samples/dm_info/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(main);
static void on_modem_reset(uint16_t reset_count);
static void on_modem_network_joined(void);

static int get_battery_level(uint8_t *battery_level);
static int get_battery_level(uint32_t *battery_level);
static int get_temperature(int32_t *battery_level);
static int get_voltage_level(uint32_t *battery_level);

Expand Down Expand Up @@ -181,11 +181,12 @@ static void on_modem_network_joined(void)
* if the callbacks are not set, default (minumum) values will be used.
*
*/
static int get_battery_level(uint8_t *battery_level)
static int get_battery_level(uint32_t *battery_level)
{
/* we simulate battery draining here */
static uint8_t battery_percent = 100;
*battery_level = battery_percent--;
static uint32_t battery_promiles = 1000;
*battery_level = battery_promiles;
battery_promiles -= 10;

return 0;
}
Expand Down

0 comments on commit 39a58e6

Please sign in to comment.