docker常用操作命令

docker常用操作命令

创建

可以在hub.docker.com上创建一个新的repo,或者自己复制一个现有的repo.
绑定github后,也可以直接通过Dockerfile来发生成最新的镜像

查看镜像列表

docker images

查看容器列表

docker ps

查看所有的容器

docker ps -a

查看最近创建的容器

docker ps -l

查找在指定 image 之后创建的 image 中的父 image

docker image inspect --format='{{.RepoTags}} {{.Id}} {{.Parent}}' $(docker image ls -q --filter since=xxxxxx)

获取镜像

docker pull name/reponame

删除

docker rm          Remove one or more containers
docker rmi         Remove one or more images

删除已经退出运行的容器

docker ps -a | grep "Exited" | awk '{print $1 }'|xargs docker rm

删除none镜像

docker images |grep none |awk '{print $3}'|xargs docker rmi

要删除全部image的话

docker rmi $(docker images -q)

停止所有容器

停止容器,才能删除所包含的image

docker stop $(docker ps -a -q)

ssh登录docker

在开发阶段免不了需要ssh上去进行现场配置。

从ssh启动docker:

docker run -it  username/imagename /bin/bash

ssh登陆,并挂载本地目录,默认读写权限:

docker run -it -v 宿主绝对路径:docker绝对路径 username/imagename /bin/bash

这样启动的入口进程是bash,整整需要启动的服务进程,再此模式下要自己手动启动

attach

docker attach --sig-proxy=false $CONTAINER_ID

如果当前的不是bash,attach上去也无法进行ssh,只有是上面这种直接启动ssh并后台运行的情况,attach上去,才进入ssh

exec

在Docker1.3版本开始,提供了一个更方便的命令exec。可以直接在容器内运行命令。所以我们ssh登录docker最方便的是exec:

docker exec -ti 7f16264f7ab4 /bin/bash

detach

docker没有专用的命令,目前不能使用eixit,因为会导致主进程退出。使用ctl+p+ctl+q来detach当前的进程

查看底层信息,比如IP等

docker inspect --format='{{.NetworkSettings.IPAddress}}' $CONTAINER_ID

commit

docker commit CONTAINER_ID docker_hub用户名/镜像名:tagname

push

docker push docker_hub用户名/镜像名:tagname

docker hub的使用

如果你使用hub.docker.com来管理你的镜像,那么就涉及到账户登录,如果你docker pull时遇到如下的提示:

unauthorized: incorrect username or password

那么说明你登录信息过期了,需要重新登录:

docker login

查看日志

查看最新30分钟的日志:

docker logs --since 30m CONTAINER_ID

其他需求,请详细查看logs 的参数

其他参考

资深专家都知道的 Docker 常用命令---源英文:Top Docker Commands Any Expert Should Know
Docker之容器的创建、启动、终止、删除、迁移等
docker入门——构建镜像

echo命令行和网页方式下base64编码不一致问题

echo命令行和网页方式下base64编码不一致问题

发现的问题

同样的测试内容:chabctimes
在centos7下面:

# echo "chabctimes"|base64
Y2hhYmN0aW1lcwo=

在线测试平台 https://tool.oschina.net/encrypt?type=3 测试如下:

Y2hhYmN0aW1lcw==

根据第三方的验证,下面的内容是通过验证可以正常用的,上面的不行。从对比看,下面跟上面的结果比较,末尾倒数第2个字符一个是=一个是o

分析

一阵g搜索,再结合只有尾部一个字符差异,而且所有内容都是倒数第二个差异,所以初步猜测可能是尾部回车换行的差异导致。
经过不同内容的验证,基本确认以上的猜测:在linux环境下echo命令行的模式,比在线的方式多一个尾部的回车换行。
再就回车换行问题进一步进行确认,因为是1个字符也会多回车换行,还不是经典的76字符回车换行问题,所以怀疑是echo的问题,经搜索,确认是echo的问题。

解决

在echo中增加参数-n 去掉结尾回车换行,验证OK:

echo -n "chabctimes"|base64
centos下privoxy安装及使用

centos下privoxy安装及使用

下载

###下载安装文件
wget http://www.privoxy.org/sf-download-mirror/Sources/3.0.26%20%28stable%29/privoxy-3.0.26-stable-src.tar.gz
tar -zxvf privoxy-3.0.26-stable-src.tar.gz
cd privoxy-3.0.26-stable

privoxy-3.0.26-stable 是目前最新的稳定版,建议在下载前去 Privoxy 官网下载页 检查一下版本。

新建用户

Privoxy 强烈不建议使用 root 用户运行,所以我们使用 useradd privoxy 新建一个用户.

安装

autoheader && autoconf
./configure
make && make install

配置

```vi /usr/local/etc/privoxy/config```

找到以下两句,确保没有注释掉

listen-address 127.0.0.1:8118   # 8118 是默认端口,不用改,下面会用到
forward-socks5t / 127.0.0.1:0 . # 这里的端口写 shadowsocks 的本地端口(注意最后那个 . 不要漏了)

启动

privoxy --user privoxy /usr/local/etc/privoxy/config

开启系统代理

配置 /etc/profile

vi /etc/profile

添加下面两句:

export http_proxy=http://127.0.0.1:8118       #这里的端口和上面 privoxy 中的保持一致
export https_proxy=http://127.0.0.1:8118

运行以下:

source /etc/profile

测试生效

curl www.google.com

返回一大堆 HTML 则说明 shadowsocks 正常工作了。

wordpress更新时弹出ftp登录

wordpress更新时弹出ftp登录

原因

因为更新本身就是对本地文件的更新覆盖,而wordpress的更新程序无法完成本地文件更新所以就会出现ftp的方式提示,所以就是文件的更新权限问题。

权限检查

因为是wordpress的php部分的逻辑负责更新,所以就是查看这部分php的运行用户权限。如果我们的php是运行在fpm模式,这个我们可以用:

ps aux |grep  php-fpm

这条指令来查看,输出第一列就是当前归属的用户组信息。然后我们对当前的wordpress根目录或者主题插件的目录进行用户权限修改:

 chown -R xxx:xxx /DDD

xxx为用户和组,DDD为需要更新权限的目录,-R表示递归所有子目录。

mysql错误日志

mysql错误日志

mysql的默认错误日志为:hostname.err
完整路径:/usr/local/mysql/var/xxxxxx.err

如果我们要重新设置日志的路径,在[mysqld] 中輸入

#log  
log-error=/usr/local/mysql/log/error.log  
log=/usr/local/mysql/log/mysql.log  
long_query_time=2  
log-slow-queries= /usr/local/mysql/log/slowquery.log 

需要注意的是这里文件和路径需要mysql用户可访问,所以需要通过chown将log设置为mysql用户:

chown -R mysql:mysql log
apt-get update -qqy

apt-get update -qqy

第一次看到-qq参数,觉得比较新奇,特意确认了下:

-q, --quiet

Quiet. Produces output suitable for logging, omitting progress indicators. More q's will produce more quiet up to a maximum of two. You can also use -q=# to set the quiet level, overriding the configuration file. Note that quiet level 2 implies -y, you should never use -qq without a no-action modifier such as -d, --print-uris or -s as APT may decided to do something you did not expect.

所以按照说明,-qq一般是搭配y选项的。
这个参数经常在docker的静默安装指令中使用。

参考:
https://linux.die.net/man/8/apt-get

nrf52832 memory layout

nrf52832 memory layout

协议栈

版本:nRF5_SDK_15.3.0_59ac345

#define SD_FLASH_SIZE 0x26000

app:
0x26000-0x77000

bootloader
0x77000-0x7e000

MBR params
0x7e000-7f000

bootloader setting:
7f000-80000

ref:
https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sr3nrf52.firmware/memory_configuration.html

centos7 vsftp 虚拟用户配置

centos7 vsftp 虚拟用户配置

搞过好多遍了,每次都要花不少时间确认一些小问题,所以做个笔记,供以后参考
1. 安装 vsftpd

yum install vsftpd
chkconfig vsftpd on
  1. 测试端口外网可访问性,用telnet就可以测试,如果不可访问,请确认vsftp端口已经监听,并且iptable 或者firewall配置正确,同时如果用的是阿里云之类的云主机,确认云平台的安全策略是否已经开放21端口
  2. 创建用户
    useradd virtual -s /sbin/nologin
    默认的vsftpd的服务宿主用户是root,但是这不符合安全性的需要。这里建立名字为virtual的用户,用他来作为支持Vsftpd的服务宿主用户。由于该用户仅用来支持vsftpd服务用,因此没有许可他登陆系统的必要,并设定他为不能登陆系统的用户。
    这个用户跟配置文件中的guest_username字段是对应的。
  3. 修改/etc/vsftpd.conf
    新增:
anonymous_enable=NO
chroot_local_user=YES
guest_enable=YES
guest_username=ftp
virtual_use_local_privs=YES
user_config_dir=/etc/vsftpd/users
reverse_lookup_enable=NO
  1. 修改 /etc/pam.d/vsftpd,删除原有内容,新增:
auth    required    pam_userdb.so   db=/etc/vsftpd/virtual_users
account required    pam_userdb.so   db=/etc/vsftpd/virtual_users
session required    pam_loginuid.so
  1. 创建账号
    1)创建账号文件 login.txt:aaaa是密码,1111是密码,多个用户依次换行
aaa
111111
bbb
222

2)生成虚拟用户数据文件
db_load -T -t hash -f /etc/vsftpd/virtual_users.txt /etc/vsftpd/virtual_users.db
7. 创建虚拟账号
mkdir /etc/vsftpd/users
vi aaaa
这里面的权限要根据需要的权限来配置,下面是一个可读写的全权限用户配置

local_root=/var/ftp/aaa
write_enable=YES
anon_umask=022
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
  1. 对相关的路径给与权限,这样才能正常上传,否则会提示553错误
mkdir -p /var/ftp/aaa

chown virtual:virtual /var/ftp/aaa

chmod 755 /var/ftp/aaa
  1. 配置完成重启服务
    systemctl restart vsftpd
Dockerfile中RUN CMD ENTRYPOINT命令区别

Dockerfile中RUN CMD ENTRYPOINT命令区别

简单总结如下:
1. run用于docker的构建,可以理解为构建docker本身的单次的程序安装,只是为了生成docker image的,在docker build阶段执行。
2. entrypoint 理解为docker run时的shell指令,一般实现需要每次开机动态更新的设置或者文件操作等
3. cmd只能支持一条,代表entrypoint额外的默认运行参数,当在外层通过 docker run传递参数时,cmd的参数可以被覆盖。

参考:
1. https://www.cnblogs.com/klvchen/p/9238410.html
2. https://www.jianshu.com/p/f0a0f6a43907

基于ubuntu的LAMP dockerfile示例

基于ubuntu的LAMP dockerfile示例

简单的dockerfile例子

这里先给一个简单的例子,用来说明基本的dockerfile的组成:

# Barebones Apache installation on Ubuntu

FROM ubuntu

MAINTAINER DockerFan version 1.0

ENV DEBIAN_FRONTEND noninteractive

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

RUN apt-get update && apt-get install -y apache2

EXPOSE 8080

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

解释

Here’s what the instructions do:

  • FROM is always your first instruction, because it names the base image you’re building your new image from.

  • MAINTAINER is the creator of the Dockerfile.

  • ENV sets environment variables, in the form ENV [key] [value]. This assigns a single value to the key, as in our example Dockerfile. The value can be any string, including spaces and punctuation, so you can configure values like IP addresses, URLs, and passphrases. Note that when you set DEBIAN_FRONTEND noninteractive (for an unattended installation) in your Dockerfile there is no equals sign, as there is when you script a standard Debian or Ubuntu installation with export DEBIAN_FRONTEND=noninteractive.

  • There are multiple instructions for setting environment variables: ADD, COPY, ENV, EXPOSE, LABEL, USER, WORKDIR, VOLUME, STOPSIGNAL, and ONBUILD.

  • RUN executes commands. The example above, RUN apt-get update && apt-get install -y apache2, demonstrates two important steps. It is a good practice to use apt-get update && apt-get install foo together to ensure that an updated packaged will be installed. Docker makes generous use of caching, so this prevents a cached packaged from being installed. If you’re sure your cached packages are fresh enough then it’s not necessary, and will save you some download time. apt-get install -y must be used together with ENV DEBIAN_FRONTEND noninteractive; it means answer Yes to all prompts and run non-interactively.

  • EXPOSE defines which ports you want open at runtime, in a space-delimited list.

  • CMD can be used only once in your Dockerfile. If you have more than one, only the last one will run. The preferred syntax is CMD [“executable”,”param1″,”param2″]. The parameters are optional and comma-separated if you have more than one.

完整的LAMP dockerfile

# Ubuntu LAMP stack with Apache, MariaDB, PHP, and SSL

FROM ubuntu

MAINTAINER DockerFan version 1.0

ENV DEBIAN_FRONTEND noninteractive

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

# Install Apache, SSL, PHP, and some PHP modules

RUN apt-get update && apt-get install -y apache2 
 openssl 
 php5 
 php5-cli 
 php5-apcu

# Install MariaDB and set default root password

RUN echo 'mariadb-server mariadb-server/root_password  password mypassword' | debconf-set-selections
RUN echo 'mariadb-server mariadb-server/root_password_again password mypassword' | debconf-set-selections
RUN apt-get install mariadb-server -y

# Disable the default Apache site config
# Install your site's Apache configuration and activate SSL

ADD my_apache.conf /etc/apache2/sites-available/
RUN a2dissite 000-default
RUN a2ensite my_apache
RUN a2enmod ssl

# Remove APT files
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

EXPOSE 443 8080

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

The section that installs Apache, SSL, and PHP shows the proper Docker way to install multiple packages at once, with each package on its own line ending in a backslash. The MariaDB installation sections shows how to use debconf to automatically set the root DB password.

You will need your own Apache virtual host configuration file, and it should be in the same directory as your Dockerfile. Use the ADD instruction to build it into your image. I like to do a little housecleaning to keep my image as small as possible by running apt-get clean, and removing temp files.

Since we are using SSL, we’ll need port 443 available. On a production system, you would probably want only port 443 enabled, and use mod_rewrite to automatically redirect HTTP requests to HTTPS.

DEBIAN_FRONTEND选项

DEBIAN_FRONTEND选项

ENV DEBIAN_FRONTEND noninteractive
在基于ubuntu的dockerfile中我们经常看到如上的配置,那么,DEBIAN_FRONTEND到底是什么东西呢?

因为ubuntu是基于apt工具包进行软件安装的,而apt工具包是基于DebianPackageManagement的。而DEBIAN_FRONTEND就是DebianPackageManagement的基本选项。

dpkg-reconfigure 可以让我们简单的配置/重新配置包选项,而不需要重新安装。在配置的过程中我们就要面临frontend的选择。

正常情况下我们会选择交互式的配置过程,但是在很多脚本过程中,我们也需要自动化整个过程,而frontend就是用来指定我们的包配置模式的。DEBIAN_FRONTEND=noninteractive 实际上就是通过环境变量模式来指定的方式。

DEBIAN_FRONTEND支持的配置方式如下:

noninteractive
Do not ask any questions and assume the defaults.

dialog
Presents the user with the familiar text gray window on blue background. This is the default.

text
This removes the dialog interface and asks the configuration questions in a pure text-based format. This is well suited for slow connections or terminal emulators that don’t cooperate well with the dialog-based input and windowing system.

gtk
Prompts the user graphically using the GTK libraries. This may not work correctly on KDE. Also requires the package cdebconf-gtk and gkdebconf to be installed before use.

所以在dockerfile的自动化配置脚本中,我们一般选择noninteractive

蓝牙uart透传技术摘要

蓝牙uart透传技术摘要

蓝牙uart透传技术摘要

基于 nRF5_SDK_15.3.0_59ac345

app->mcu->uart

  1. BLE_NUS_DEF(m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT); 执行时将ble_nus_on_ble_evt,进行了注册了绑定。
  2. nrf_sdh_ble_evts_poll 执行时,通过回调,调用ble_nus_on_ble_evt。
  3. 当有蓝牙数据发送时,会触发BLE_GATTS_EVT_WRITE,调用on_write
  4. 在on_write中会调用我们在业务中注册的nus service 回调nus_data_handler,这个回调作为参数在ble_nus_init中注册。
  5. 在nus_data_handler中我们就可以将数据通过串口发送函数app_uart_put发出了

uart->mcu->app

  1. uart_event_handle回调函数到nus发送函数ble_nus_data_send
  2. sd_ble_gatts_hvx协议栈函数会将内容通过蓝牙发送给app
nordic下的gcc编译

nordic下的gcc编译

默认大家使用keil等ui的IDE多些,但有时候需要gcc来实现,默认nordic 也做好了gcc工程模板,直接使用就可以。
1. 需要配置gcc,直接make,然后根据提示配置gcc的路径,这里可以使用:gcc-arm-none-eabi
2. 配置gcc路径时,内容为去掉-gcc的gcc文件全路径

Nordic SoftDevice 处理

Nordic SoftDevice 处理

来源:https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.2.0%2Fgroup__nrf__sdh.html&anchor=ga574d17fdf1c59dec6355e3f525c484ec

SoftDevice Handler

API for initializing and disabling the SoftDevice. More...

Modules

ANT support in SoftDevice Handler
This file contains the declarations of types and functions required for ANT stack support.
BLE support in SoftDevice Handler
This file contains the declarations of types and functions required for BLE stack support.
SoftDevice handler configuration
SoC support in SoftDevice Handler
This file contains the declarations of types and functions required for SoftDevice Handler SoC support.

Data Structures

struct nrf_sdh_req_observer_t
SoftDevice Handler state request observer. More...
struct nrf_sdh_state_observer_t
SoftDevice Handler state observer. More...
struct nrf_sdh_stack_observer_t
SoftDevice stack event observer. More...

Functions

ret_code_t nrf_sdh_enable_request (void)
Function for requesting to enable the SoftDevice. More...
ret_code_t nrf_sdh_disable_request (void)
Function for requesting to disable the SoftDevice. More...
ret_code_t nrf_sdh_request_continue (void)
Function for restarting the SoftDevice Enable/Disable process. More...
bool nrf_sdh_is_enabled (void)
Function for retrieving the SoftDevice state. More...
void nrf_sdh_suspend (void)
Function for stopping the incoming stack events. More...
void nrf_sdh_resume (void)
Function for resuming polling incoming events from the SoftDevice.
bool nrf_sdh_is_suspended (void)
Function for retrieving the information about the module state. More...
void nrf_sdh_evts_poll (void)
Function for polling stack events from the SoftDevice. More...

Softdevice Handler dispatch models

#define NRF_SDH_DISPATCH_MODEL_INTERRUPT   0
SoftDevice events are passed to the application from the interrupt context.
#define NRF_SDH_DISPATCH_MODEL_APPSH   1
SoftDevice events are passed to the application using SchedulerMore...
#define NRF_SDH_DISPATCH_MODEL_POLLING   2
SoftDevice events are polled manually using nrf_sdh_evts_poll()More...

SoftDevice Handler state change requests

enum nrf_sdh_req_evt_t { 
  NRF_SDH_EVT_ENABLE_REQUEST
  NRF_SDH_EVT_DISABLE_REQUEST 
}
SoftDevice Handler state requests. More...
typedef bool(* nrf_sdh_req_evt_handler_t )(nrf_sdh_req_evt_t request, void *p_context)
SoftDevice Handler state request handler. More...
#define NRF_SDH_REQUEST_OBSERVER(_observer, _prio)
Macro for registering a SoftDevice state change request observer. More...

SoftDevice Handler state events

enum nrf_sdh_state_evt_t { 
  NRF_SDH_EVT_STATE_ENABLE_PREPARE
  NRF_SDH_EVT_STATE_ENABLED
  NRF_SDH_EVT_STATE_DISABLE_PREPARE
  NRF_SDH_EVT_STATE_DISABLED 
}
SoftDevice Handler state events. More...
typedef void(* nrf_sdh_state_evt_handler_t )(nrf_sdh_state_evt_t state, void *p_context)
SoftDevice Handler state event handler.
#define NRF_SDH_STATE_OBSERVER(_observer, _prio)
Macro for registering a SoftDevice state observer. More...

SoftDevice stack events

typedef void(* nrf_sdh_stack_evt_handler_t )(void *p_evt)
SoftDevice stack event handler.
#define NRF_SDH_STACK_OBSERVER(_observer, _prio)
Macro for registering a SoftDevice stack events observer. More...

Detailed Description

API for initializing and disabling the SoftDevice.

Macro Definition Documentation

#define NRF_SDH_DISPATCH_MODEL_APPSH   1

SoftDevice events are passed to the application using Scheduler.

Note
Scheduler must be initialized before enabling the SoftDevice handler.

#define NRF_SDH_DISPATCH_MODEL_POLLING   2

SoftDevice events are polled manually using nrf_sdh_evts_poll().

Note
In this mode, a user application can also implement SD_EVT_IRQHandler() to receive a notification about incoming events.

#define NRF_SDH_REQUEST_OBSERVER ( _observer,
_prio
)

Macro for registering a SoftDevice state change request observer.

An observer of SoftDevice state change requests receives requests to change the state of the SoftDevice from enabled to disabled and vice versa. These requests may or may not be acknowledged by the observer, depending on the value returned by its request handler function. Thus, a request observer has the capability to defer the change of state of the SoftDevice. If it does so, it has the responsibility to call nrf_sdh_request_continue when it is ready to let the SoftDevice change its state. If such capability is not necessary and you only need to be informed about changes of the SoftDevice state, use the NRF_SDH_STATE_OBSERVER macro instead.

Note
This macro places the observer in a section named "sdh_req_observers".
Parameters
[in] _observer Name of the observer.
[in] _prio Priority of the observer's event handler. The smaller the number, the higher the priority.

#define NRF_SDH_STACK_OBSERVER ( _observer,
_prio
)

Macro for registering a SoftDevice stack events observer.

A SoftDevice stack event observer receives all events from the SoftDevice. These events can be either BLE, ANT, or SoC events. If you need to receive BLE, ANT, or SoC events separately, use the NRF_SDH_BLE_OBSERVERNRF_SDH_ANT_OBSERVER, or NRF_SDH_SOC_OBSERVER macros respectively.

Note
This macro places the observer in a section named "sdh_stack_observers".
Parameters
[in] _observer Name of the observer.
[in] _prio Priority of the observer's event handler. The smaller the number, the higher the priority.

#define NRF_SDH_STATE_OBSERVER ( _observer,
_prio
)

Macro for registering a SoftDevice state observer.

A SoftDevice state observer receives events when the SoftDevice state has changed or is about to change. These events are only meant to inform the state observer, which, contrary to a state change request observer, does not have the capability to defer the change of state. If such capability is required, use the NRF_SDH_REQUEST_OBSERVER macro instead.

This macro places the observer in a section named "sdh_state_observers".

Parameters
[in] _observer Name of the observer.
[in] _prio Priority of the observer's event handler. The smaller the number, the higher the priority.

Typedef Documentation

typedef bool(* nrf_sdh_req_evt_handler_t)(nrf_sdh_req_evt_t request, void *p_context)

SoftDevice Handler state request handler.

Return values
true If ready for the SoftDevice to change state.
false If not ready for the SoftDevice to change state. If false is returned, the state change is aborted.

Enumeration Type Documentation

SoftDevice Handler state requests.

Enumerator
NRF_SDH_EVT_ENABLE_REQUEST Request to enable the SoftDevice.
NRF_SDH_EVT_DISABLE_REQUEST Request to disable the SoftDevice.

SoftDevice Handler state events.

Enumerator
NRF_SDH_EVT_STATE_ENABLE_PREPARE SoftDevice is going to be enabled.
NRF_SDH_EVT_STATE_ENABLED SoftDevice is enabled.
NRF_SDH_EVT_STATE_DISABLE_PREPARE SoftDevice is going to be disabled.
NRF_SDH_EVT_STATE_DISABLED SoftDevice is disabled.

Function Documentation

ret_code_t nrf_sdh_disable_request ( void )

Function for requesting to disable the SoftDevice.

This function issues a NRF_SDH_EVT_DISABLE_REQUEST request to all observers that were registered using the NRF_SDH_REQUEST_OBSERVER macro. The observers may or may not acknowledge the request. If all observers acknowledge the request, the SoftDevice will be disabled. Otherwise, the process will be stopped and the observers that did not acknowledge have the responsibility to restart it by calling nrf_sdh_request_continue when they are ready for the SoftDevice to change state.

Return values
NRF_SUCCESS The process is started.
NRF_ERROR_INVALID_STATE The SoftDevice is already disabled.

ret_code_t nrf_sdh_enable_request ( void )

Function for requesting to enable the SoftDevice.

This function issues a NRF_SDH_EVT_ENABLE_REQUEST request to all observers that were registered using the NRF_SDH_REQUEST_OBSERVER macro. The observers may or may not acknowledge the request. If all observers acknowledge the request, the SoftDevice will be enabled. Otherwise, the process will be stopped and the observers that did not acknowledge have the responsibility to restart it by calling nrf_sdh_request_continue when they are ready for the SoftDevice to change state.

Return values
NRF_SUCCESS The process is started.
NRF_ERROR_INVALID_STATE The SoftDevice is already enabled.

void nrf_sdh_evts_poll ( void )

Function for polling stack events from the SoftDevice.

The events are passed to the application using the registered event handlers.

Note
NRF_SDH_DISPATCH_MODEL_POLLING must be selected to use this function.

bool nrf_sdh_is_enabled ( void )

Function for retrieving the SoftDevice state.

Return values
true If the SoftDevice is enabled.
false If the SoftDevice is disabled.

bool nrf_sdh_is_suspended ( void )

Function for retrieving the information about the module state.

Return values
true The SoftDevice handler is paused, and it will not fetch events from the stack.
false The SoftDevice handler is running, and it will fetch and dispatch events from the stack to the registered stack observers.

ret_code_t nrf_sdh_request_continue ( void )

Function for restarting the SoftDevice Enable/Disable process.

Modules which did not acknowledge a NRF_SDH_EVT_ENABLE_REQUEST or NRF_SDH_EVT_DISABLE_REQUEST request must call this function to restart the SoftDevice state change process.

Return values
NRF_SUCCESS The process is restarted.
NRF_ERROR_INVALID_STATE No state change request was pending.

void nrf_sdh_suspend ( void )

Function for stopping the incoming stack events.

This function disables the SoftDevice interrupt. To resume polling for events, call nrf_sdh_resume.


Documentation feedback | Developer Zone | Subscribe | Updated 2017-11-24