{"id":625,"date":"2020-11-01T16:34:39","date_gmt":"2020-11-01T07:34:39","guid":{"rendered":"https:\/\/chikuwa-ringyo.com\/?p=625"},"modified":"2023-05-05T16:57:26","modified_gmt":"2023-05-05T07:57:26","slug":"x-shifter%e3%81%ae%e3%82%b9%e3%82%a4%e3%83%83%e3%83%81%e3%83%a6%e3%83%8b%e3%83%83%e3%83%88%e3%82%92%e8%87%aa%e4%bd%9c%e3%81%97%e3%81%be%e3%81%97%e3%81%9f%e3%80%82ver2-0-ae-%e3%82%bd%e3%83%bc%e3%82%b9","status":"publish","type":"post","link":"https:\/\/chikuwa-ringyo.com\/?p=625","title":{"rendered":"X Shifter\u306e\u30b9\u30a4\u30c3\u30c1\u30e6\u30cb\u30c3\u30c8\u3092\u81ea\u4f5c\u3057\u307e\u3057\u305f\u3002Ver2.0-AE-\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\uff06\u56de\u8def-"},"content":{"rendered":"<h2>\u521d\u3081\u306b<\/h2>\n<p>https:\/\/chikuwa-ringyo.com\/?p=529<br \/>\nhttps:\/\/chikuwa-ringyo.com\/?p=536<br \/>\n\u306e\u7d9a\u304d\u3002\u5b9f\u969b\u306b\u30b9\u30a4\u30c3\u30c1\u30e6\u30cb\u30c3\u30c8\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u56de\u8def\u3067\u3059\u3002<br \/>\n\u2193\u307f\u305f\u3044\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/twitter.com\/i\/status\/1309463360400887813\">\u53c2\u8003\u52d5\u753b<\/a><\/p>\n<h2>\u4f7f\u3063\u305f\u3082\u306e<\/h2>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-629\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/uploads\/2020\/11\/-e1604216106796.jpg\" alt=\"\" width=\"480\" height=\"640\" \/><br \/>\n\u30fbAE-TYBLE16<br \/>\n<a href=\"https:\/\/akizukidenshi.com\/catalog\/g\/gK-12339\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u79cb\u6708\u96fb\u5b50\u3067\u8cfc\u5165<\/a><\/p>\n<p>\u30fb\u96fb\u6c60\u30b1\u30fc\u30b9<br \/>\n<a href=\"https:\/\/akizukidenshi.com\/catalog\/g\/gP-11255\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u79cb\u6708\u96fb\u5b50\u3067\u8cfc\u5165<\/a><\/p>\n<p>\u30fb\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1<br \/>\n<a href=\"http:\/\/akizukidenshi.com\/catalog\/g\/gP-09826\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u79cb\u6708\u96fb\u5b50\u3067\u8cfc\u5165<\/a><\/p>\n<p>\u30fb\u30b1\u30fc\u30d6\u30eb<br \/>\n<a href=\"https:\/\/www.monotaro.com\/p\/0523\/3305\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u30e2\u30ce\u30bf\u30ed\u30a6\u3067\u8cfc\u5165<\/a><\/p>\n<h2>\u56de\u8def\u56f3<\/h2>\n<p>\u30b9\u30a4\u30c3\u30c1\u3068\u96fb\u6c60\u3064\u306a\u3050\u3060\u3051\u3067\u3059\u3002<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-630\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/uploads\/2020\/11\/kairozu.png\" alt=\"\" width=\"566\" height=\"413\" \/><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-637\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/uploads\/2020\/11\/\u30b9\u30a4\u30c3\u30c1.jpg\" alt=\"\" width=\"640\" height=\"480\" \/><\/p>\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<p>nRF5_SDK_12.3\u306eble_app_hrs_c\u3092\u30d9\u30fc\u30b9\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u4fee\u6b63\u3057\u307e\u3057\u305f\u3002<br \/>\n\u4fee\u6b63\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306f\u4ee5\u4e0b\u306e3\u3064\u3002\uff08\u30af\u30ed\u30c3\u30af\u306e\u8a2d\u5b9a\u306a\u3069\u306f\u524d\u56de\u306e\u8a18\u4e8b\u3067\u5909\u66f4\u3057\u3066\u3044\u308b\u3053\u3068\u524d\u63d0)<br \/>\n\u30fbmain.c<br \/>\n\u30fbsdk_config.h(ble_app_hrs_c\\pca10028\\s130\\config\u5185)<br \/>\n\u30fbpca10028.h(components\\boards\u5185)<br \/>\n\u4fee\u6b63\u3057\u3066\u30d3\u30eb\u30c9\u3057\u3066\u3001\u4f5c\u6210\u3057\u305fhex\u30d5\u30a1\u30a4\u30eb\u3092SoftDeviceS130\u306eHex\u3068\u4e00\u7dd2\u306b\u66f8\u304d\u8fbc\u3093\u3067\u304a\u3057\u307e\u3044\u3067\u3059\u3002<\/p>\n<h3>sdk_config.h<\/h3>\n<p>\u4ee5\u4e0b\u306e\u7b87\u6240\u3092\u5909\u66f4<br \/>\n706\u884c\u76ee<br \/>\n#define GPIOTE_CONFIG_IRQ_PRIORITY 3<br \/>\n=&gt; #define GPIOTE_CONFIG_IRQ_PRIORITY 1<br \/>\n2708\u884c\u76ee<br \/>\n#define UART_ENABLED 1<br \/>\n=&gt; #define UART_ENABLED 0<br \/>\n2782\u884c\u76ee<br \/>\n#define UART0_ENABLED 1<br \/>\n=&gt; #define UART0_ENABLED 0<br \/>\n3670\u884c\u76ee<br \/>\n#define NRF_LOG_BACKEND_SERIAL_USES_UART 1<br \/>\n=&gt;#define NRF_LOG_BACKEND_SERIAL_USES_UART 0<br \/>\n3716\u884c\u76ee<br \/>\n#define NRF_LOG_BACKEND_SERIAL_USES_RTT 0<br \/>\n=&gt; #define NRF_LOG_BACKEND_SERIAL_USES_RTT 1<\/p>\n<h3>pca10028.h<\/h3>\n<p>73,74,75\u884c\u76ee<br \/>\n#define BUTTON_1 17<br \/>\n#define BUTTON_2 18<br \/>\n#define BUTTON_3 19<br \/>\n=&gt;<br \/>\n#define BUTTON_1 18<br \/>\n#define BUTTON_2 17<br \/>\n#define BUTTON_3 5<br \/>\n\u306b\u3059\u308b\u3002<\/p>\n<h3>main.c<\/h3>\n<p>\u5909\u66f4\u7b87\u6240\u304c\u591a\u3044\u306e\u3067\u30b3\u30fc\u30c9\u3092\u305d\u306e\u307e\u307e\u8f09\u305b\u307e\u3059\u3002<\/p>\n<pre class=\"language-c\"><code>\/**\r\n * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA\r\n * \r\n * All rights reserved.\r\n * \r\n * Redistribution and use in source and binary forms, with or without modification,\r\n * are permitted provided that the following conditions are met:\r\n * \r\n * 1. Redistributions of source code must retain the above copyright notice, this\r\n *    list of conditions and the following disclaimer.\r\n * \r\n * 2. Redistributions in binary form, except as embedded into a Nordic\r\n *    Semiconductor ASA integrated circuit in a product or a software update for\r\n *    such product, must reproduce the above copyright notice, this list of\r\n *    conditions and the following disclaimer in the documentation and\/or other\r\n *    materials provided with the distribution.\r\n * \r\n * 3. Neither the name of Nordic Semiconductor ASA nor the names of its\r\n *    contributors may be used to endorse or promote products derived from this\r\n *    software without specific prior written permission.\r\n * \r\n * 4. This software, with or without modification, must only be used with a\r\n *    Nordic Semiconductor ASA integrated circuit.\r\n * \r\n * 5. Any software provided in binary form under this license must not be reverse\r\n *    engineered, decompiled, modified and\/or disassembled.\r\n * \r\n * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA \"AS IS\" AND ANY EXPRESS\r\n * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r\n * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\n * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\r\n * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\r\n * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n * \r\n *\/\r\n\r\n\/**\r\n * @brief BLE Heart Rate Collector application main file.\r\n *\r\n * This file contains the source code for a sample heart rate collector.\r\n *\/\r\n\r\n#include &lt;stdint.h&gt;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n#include \"nordic_common.h\"\r\n#include \"nrf_sdm.h\"\r\n#include \"ble.h\"\r\n#include \"ble_hci.h\"\r\n#include \"ble_db_discovery.h\"\r\n#include \"softdevice_handler.h\"\r\n#include \"app_util.h\"\r\n#include \"app_error.h\"\r\n#include \"boards.h\"\r\n#include \"nrf_gpio.h\"\r\n#include \"peer_manager.h\"\r\n#include \"ble_hrs_c.h\"\r\n#include \"ble_bas_c.h\"\r\n#include \"app_util.h\"\r\n#include \"app_timer.h\"\r\n#include \"bsp.h\"\r\n#include \"bsp_btn_ble.h\"\r\n#include \"fds.h\"\r\n#include \"fstorage.h\"\r\n#include \"ble_conn_state.h\"\r\n#include \"nrf_ble_gatt.h\"\r\n#define NRF_LOG_MODULE_NAME \"APP\"\r\n#include \"nrf_log.h\"\r\n#include \"nrf_log_ctrl.h\"\r\n\r\n\r\n\r\n#define CENTRAL_LINK_COUNT          1                                   \/**&lt; Number of central links used by the application. When changing this number remember to adjust the RAM settings*\/\r\n#define PERIPHERAL_LINK_COUNT       0                                   \/**&lt; Number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*\/\r\n\r\n#define APP_TIMER_PRESCALER         2                                   \/**&lt; Value of the RTC1 PRESCALER register. *\/\r\n#define APP_TIMER_OP_QUEUE_SIZE     2                                   \/**&lt; Size of timer operation queues. *\/\r\n\r\n#define SEC_PARAM_BOND              1                                   \/**&lt; Perform bonding. *\/\r\n#define SEC_PARAM_MITM              0                                   \/**&lt; Man In The Middle protection not required. *\/\r\n#define SEC_PARAM_LESC              0                                   \/**&lt; LE Secure Connections not enabled. *\/\r\n#define SEC_PARAM_KEYPRESS          0                                   \/**&lt; Keypress notifications not enabled. *\/\r\n#define SEC_PARAM_IO_CAPABILITIES   BLE_GAP_IO_CAPS_NONE                \/**&lt; No I\/O capabilities. *\/\r\n#define SEC_PARAM_OOB               0                                   \/**&lt; Out Of Band data not available. *\/\r\n#define SEC_PARAM_MIN_KEY_SIZE      7                                   \/**&lt; Minimum encryption key size in octets. *\/\r\n#define SEC_PARAM_MAX_KEY_SIZE      16                                  \/**&lt; Maximum encryption key size in octets. *\/\r\n\r\n#define SCAN_INTERVAL               0x00A0                              \/**&lt; Determines scan interval in units of 0.625 millisecond. *\/\r\n#define SCAN_WINDOW                 0x0050                              \/**&lt; Determines scan window in units of 0.625 millisecond. *\/\r\n\r\n#define MIN_CONNECTION_INTERVAL     MSEC_TO_UNITS(7.5, UNIT_1_25_MS)    \/**&lt; Determines minimum connection interval in millisecond. *\/\r\n#define MAX_CONNECTION_INTERVAL     MSEC_TO_UNITS(30, UNIT_1_25_MS)     \/**&lt; Determines maximum connection interval in millisecond. *\/\r\n#define SLAVE_LATENCY               0                                   \/**&lt; Determines slave latency in counts of connection events. *\/\r\n#define SUPERVISION_TIMEOUT         MSEC_TO_UNITS(4000, UNIT_10_MS)     \/**&lt; Determines supervision time-out in units of 10 millisecond. *\/\r\n\r\n#define BLE_UUID_ELINK_SHIFT_CHARA  0x1524U         \/**&lt; Target device name that application is looking for. *\/\r\n#define BLE_UUID_ELINK_SERVICE \t\t0x1523U\r\n\r\n#define INIT_WRITE_MESSAGE_LENGTH\t\t18U\r\n#define SHIFT_WRITE_MESSAGE_LENGTH\t\t4U\r\n\r\n#define SYSTEM_OFF_TIME_SCAN\tAPP_TIMER_TICKS(60000, APP_TIMER_PRESCALER) \/*10s*\/\r\n#define SYSTEM_OFF_TIME_CONN\tAPP_TIMER_TICKS(600000, APP_TIMER_PRESCALER) \/*600s*\/\r\n\r\n#define BUTTON_PUSH_CHECK_TIME APP_TIMER_TICKS(300, APP_TIMER_PRESCALER) \/*ms*\/\r\n\r\n\/**\r\n * @defgroup hrs_c_enums Enumerations\r\n * @{\r\n *\/\r\n\r\n\r\n\r\n\r\n\/**@breif Macro to unpack 16bit unsigned UUID from octet stream. *\/\r\n#define UUID16_EXTRACT(DST, SRC) \\\r\n    do                           \\\r\n    {                            \\\r\n        (*(DST))   = (SRC)<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank01.png\" \/>;   \\\r\n        (*(DST)) &lt;&lt;= 8;          \\\r\n        (*(DST))  |= (SRC)[0];   \\\r\n    } while (0)\r\n\r\n\r\n\/**@brief Variable length data encapsulation in terms of length and pointer to data *\/\r\ntypedef struct\r\n{\r\n    uint8_t  * p_data;      \/**&lt; Pointer to data. *\/\r\n    uint16_t   data_len;    \/**&lt; Length of data. *\/\r\n} data_t;\r\n\r\ntypedef enum\r\n{\r\n    READ_REQ,  \/**&lt; Type identifying that this tx_message is a read request. *\/\r\n    WRITE_REQ  \/**&lt; Type identifying that this tx_message is a write request. *\/\r\n} tx_request_t;\r\ntypedef struct\r\n{\r\n    uint8_t                  gattc_value[INIT_WRITE_MESSAGE_LENGTH];  \/**&lt; The message to write. *\/\r\n    ble_gattc_write_params_t gattc_params;                       \/**&lt; GATTC parameters for this message. *\/\r\n} write_params_t;\r\n\r\n\/**@brief Structure for holding data to be transmitted to the connected central.\r\n *\/\r\ntypedef struct\r\n{\r\n    uint16_t     conn_handle;  \/**&lt; Connection handle to be used when transmitting this message. *\/\r\n    tx_request_t type;         \/**&lt; Type of this message, i.e. read or write message. *\/\r\n    union\r\n    {\r\n        uint16_t       read_handle;  \/**&lt; Read request message. *\/\r\n        write_params_t write_req;    \/**&lt; Write request message. *\/\r\n    } req;\r\n} tx_message_t;\r\n\r\nstatic ble_db_discovery_t    m_ble_db_discovery;           \/**&lt; Structure used to identify the DB Discovery module. *\/\r\n\r\nstatic ble_gap_scan_params_t m_scan_param;                 \/**&lt; Scan parameters requested for scanning and connection. *\/\r\nstatic uint16_t              m_conn_handle;                \/**&lt; Current connection handle. *\/\r\nstatic bool                  m_whitelist_disabled;         \/**&lt; True if whitelist has been temporarily disabled. *\/\r\nstatic bool                  m_memory_access_in_progress;  \/**&lt; Flag to keep track of ongoing operations on persistent memory. *\/\r\nstatic nrf_ble_gatt_t        m_gatt;                       \/**&lt; Structure for gatt module*\/\r\n\r\nstatic bool                  m_retry_db_disc;              \/**&lt; Flag to keep track of whether the DB discovery should be retried. *\/\r\nstatic uint16_t              m_pending_db_disc_conn = BLE_CONN_HANDLE_INVALID;  \/**&lt; Connection handle for which the DB discovery is retried. *\/\r\n\r\nstatic tx_message_t  m_tx_buffer;  \/**&lt; Transmit buffer for messages to be transmitted to the central. *\/\r\nAPP_TIMER_DEF(m_sec_req_timer_id);\r\nAPP_TIMER_DEF(m_button1_push_timer_id);\r\nAPP_TIMER_DEF(m_button2_push_timer_id);\r\nstatic bool m_push_switch= false;\r\nstatic bool m_button_timer = false;\r\n\t\r\n\/**\r\n * @brief Connection parameters requested for connection.\r\n *\/\r\nstatic const ble_gap_conn_params_t m_connection_param =\r\n{\r\n    (uint16_t)MIN_CONNECTION_INTERVAL,  \/\/ Minimum connection\r\n    (uint16_t)MAX_CONNECTION_INTERVAL,  \/\/ Maximum connection\r\n    (uint16_t)SLAVE_LATENCY,            \/\/ Slave latency.\r\n    (uint16_t)SUPERVISION_TIMEOUT       \/\/ Supervision time-out\r\n};\r\n\r\n\/**@brief Names which the central applications will scan for, and which will be advertised by the peripherals.\r\n *  if these are set to empty strings, the UUIDs defined below will be used\r\n *\/\r\nstatic const char m_target_periph_name[] = \"Elink\";          \/**&lt; If you want to connect to a peripheral using a given advertising name, type its name here. *\/\r\nstatic bool  is_connect_per_addr = true;               \/**&lt; If you want to connect to a peripheral with a given address, set this to true and put the correct address in the variable below. *\/\r\nstatic const ble_gap_addr_t m_target_periph_addr =\r\n{\r\n    \/* Possible values for addr_type:\r\n       BLE_GAP_ADDR_TYPE_PUBLIC,\r\n       BLE_GAP_ADDR_TYPE_RANDOM_STATIC,\r\n       BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE,\r\n       BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE. *\/\r\n    .addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC,\r\n    .addr      = {0xEF, 0xE3, 0xC8, 0x09, 0x96, 0xEB} \/*Elink MacAddr*\/\r\n};\r\n\r\n\r\nstatic void scan_start(void);\r\nstatic uint32_t Elin_Init(uint16_t conn_handle);\r\nstatic void Elin_ShiftUp(uint16_t conn_handle);\r\nstatic void Elin_ShiftDown(uint16_t conn_handle);\r\nstatic void ble_elink_on_db_disc_evt(const ble_db_discovery_evt_t * p_evt);\r\nstatic void elin_c_init(void);\r\nstatic uint32_t ble_elin_c_init(void);\r\nstatic void button1_event_handler(void);\r\nstatic void button2_event_handler(void); \t\r\nstatic void sec_req_timeout_handler(void * p_context);\r\nstatic void sleep_timer_reset(uint32_t timeout);\r\nstatic void button1_timer_start(void);\r\nstatic void button2_timer_start(void);\t\r\nstatic void button1_timer_event_handler(void * p_context);\r\nstatic void button2_timer_event_handler(void * p_context);\r\n \t\r\nstatic uint32_t Elin_Init(uint16_t conn_handle)\r\n{\r\n\tuint32_t err_code;\r\n\r\n\tm_tx_buffer.req.write_req.gattc_params.handle   = 0x0010U;\r\n    m_tx_buffer.req.write_req.gattc_params.len      = INIT_WRITE_MESSAGE_LENGTH;\r\n    m_tx_buffer.req.write_req.gattc_params.p_value  = m_tx_buffer.req.write_req.gattc_value;\r\n    m_tx_buffer.req.write_req.gattc_params.offset   = 0;\r\n    m_tx_buffer.req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ;\r\n    m_tx_buffer.req.write_req.gattc_value[0]        = 0xAA;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank01.png\" \/>        = 0xCF;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank02.png\" \/>        = 0x00;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank03.png\" \/>        = 0x00;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank04.png\" \/>        = 0x5D;\r\n    m_tx_buffer.req.write_req.gattc_value[5]        = 0x4A;\r\n    m_tx_buffer.req.write_req.gattc_value[6]        = 0x81;\r\n    m_tx_buffer.req.write_req.gattc_value[7]        = 0x89;\r\n    m_tx_buffer.req.write_req.gattc_value[8]        = 0x32;\r\n    m_tx_buffer.req.write_req.gattc_value[9]        = 0xF7;\r\n    m_tx_buffer.req.write_req.gattc_value[10]        = 0x52;\r\n    m_tx_buffer.req.write_req.gattc_value[11]        = 0x12;\r\n    m_tx_buffer.req.write_req.gattc_value[12]        = 0x36;\r\n    m_tx_buffer.req.write_req.gattc_value[13]        = 0x00;\t\r\n    m_tx_buffer.req.write_req.gattc_value[14]        = 0x00;\t\r\n    m_tx_buffer.req.write_req.gattc_value[15]        = 0x00;\t\r\n    m_tx_buffer.req.write_req.gattc_value[16]        = 0x00;\t\r\n    m_tx_buffer.req.write_req.gattc_value[17]        = 0x00;\t\r\n\tm_tx_buffer.conn_handle                         = conn_handle;\r\n    m_tx_buffer.type                                = WRITE_REQ;\r\n\t\r\n \terr_code = sd_ble_gattc_write(m_tx_buffer.conn_handle,\r\n                                          &amp;m_tx_buffer.req.write_req.gattc_params);\r\n \tif (err_code == NRF_SUCCESS)\r\n    {\r\n        NRF_LOG_INFO(\"WriteOK\\r\\n\");\r\n    }\r\n    else\r\n    {\r\n        NRF_LOG_INFO(\"WriteError\\r\\n\");\r\n    }\r\n\t\r\n\treturn err_code;\r\n}\r\n\r\n\r\nstatic void Elin_ShiftDown(uint16_t conn_handle)\r\n{\r\n\tuint32_t err_code;\r\n\r\n    m_tx_buffer.req.write_req.gattc_params.len      = SHIFT_WRITE_MESSAGE_LENGTH;\r\n    m_tx_buffer.req.write_req.gattc_value[0]        = 0x21U;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank01.png\" \/>        = 0x03U;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank02.png\" \/>        = 0x00U;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank03.png\" \/>        = 0x00U;\r\n\t\r\n \terr_code = sd_ble_gattc_write(m_tx_buffer.conn_handle,\r\n                                          &amp;m_tx_buffer.req.write_req.gattc_params);\r\n\tif (err_code == NRF_SUCCESS)\r\n    {\r\n        NRF_LOG_INFO(\"WriteOK\\r\\n\");\r\n    }\r\n    else\r\n    {\r\n        NRF_LOG_INFO(\"WriteError\\r\\n\");\r\n    }\r\n}\r\n\r\nstatic void Elin_ShiftUp(uint16_t conn_handle)\r\n{\r\n\tuint32_t err_code;\r\n\r\n\tm_tx_buffer.req.write_req.gattc_params.handle   = 0x0010U;\r\n    m_tx_buffer.req.write_req.gattc_params.len      = SHIFT_WRITE_MESSAGE_LENGTH;\r\n    m_tx_buffer.req.write_req.gattc_params.p_value  = m_tx_buffer.req.write_req.gattc_value;\r\n    m_tx_buffer.req.write_req.gattc_params.offset   = 0;\r\n    m_tx_buffer.req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ;\r\n\r\n    m_tx_buffer.req.write_req.gattc_value[0]        = 0x21U;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank01.png\" \/>        = 0x02U;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank02.png\" \/>        = 0x00U;\r\n    m_tx_buffer.req.write_req.gattc_value<img decoding=\"async\" class=\"ranking-number\" src=\"https:\/\/chikuwa-ringyo.com\/wp-content\/themes\/jin\/img\/rank03.png\" \/>        = 0x00U;\r\n\tm_tx_buffer.conn_handle                         = conn_handle;\r\n    m_tx_buffer.type                                = WRITE_REQ;\r\n\t\r\n\t\r\n \terr_code = sd_ble_gattc_write(m_tx_buffer.conn_handle,\r\n                                          &amp;m_tx_buffer.req.write_req.gattc_params);\r\n\tif (err_code == NRF_SUCCESS)\r\n    {\r\n        NRF_LOG_INFO(\"WriteOK\\r\\n\");\r\n    }\r\n    else\r\n    {\r\n        NRF_LOG_INFO(\"WriteError\\r\\n\");\r\n    }\r\n}\r\n\/**@brief Function for asserts in the SoftDevice.\r\n *\r\n * @details This function will be called in case of an assert in the SoftDevice.\r\n *\r\n * @warning This handler is an example only and does not fit a final product. You need to analyze\r\n *          how your product is supposed to react in case of Assert.\r\n * @warning On assert from the SoftDevice, the system can only recover on reset.\r\n *\r\n * @param[in] line_num     Line number of the failing ASSERT call.\r\n * @param[in] p_file_name  File name of the failing ASSERT call.\r\n *\/\r\nvoid assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)\r\n{\r\n    app_error_handler(0xDEADBEEF, line_num, p_file_name);\r\n}\r\n\r\n\r\n\/**@brief Function for handling database discovery events.\r\n *\r\n * @details This function is callback function to handle events from the database discovery module.\r\n *          Depending on the UUIDs that are discovered, this function should forward the events\r\n *          to their respective services.\r\n *\r\n * @param[in] p_event  Pointer to the database discovery event.\r\n *\/\r\nstatic void db_disc_handler(ble_db_discovery_evt_t * p_evt)\r\n{\r\n    ble_elink_on_db_disc_evt( p_evt);\r\n}\r\n\r\n\r\nstatic void ble_elink_on_db_disc_evt( const ble_db_discovery_evt_t * p_evt)\r\n{\r\n\r\n\tuint32_t err_code;\r\n    \/\/ Check if the Heart Rate Service was discovered.\r\n    if (p_evt-&gt;evt_type == BLE_DB_DISCOVERY_COMPLETE &amp;&amp;\r\n        p_evt-&gt;params.discovered_db.srv_uuid.uuid == BLE_UUID_ELINK_SERVICE &amp;&amp;\r\n        p_evt-&gt;params.discovered_db.srv_uuid.type == BLE_UUID_TYPE_BLE)\r\n    {\r\n\t\tNRF_LOG_INFO(\"Comp Discover.\\r\\n\");\r\n\r\n    \terr_code = Elin_Init(p_evt-&gt;conn_handle);\r\n    \tif (err_code == NRF_SUCCESS)\r\n    \t{ \r\n    \t\tm_conn_handle = p_evt-&gt;conn_handle;\r\n    \t\tsleep_timer_reset(SYSTEM_OFF_TIME_CONN);\r\n    \t}else{\r\n    \t\terr_code = sd_ble_gap_disconnect(p_evt-&gt;conn_handle,\r\n                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);\r\n            APP_ERROR_CHECK(err_code);\r\n    \t}\r\n    }\r\n}\r\n \t\r\n static void timers_init(void){\r\n  \tuint32_t err_code;\r\n \terr_code = app_timer_create(&amp;m_sec_req_timer_id,\r\n                               APP_TIMER_MODE_SINGLE_SHOT,\r\n   \t                            sec_req_timeout_handler);\r\n   \tAPP_ERROR_CHECK(err_code);\r\n }\r\n \t\r\n static void sleep_timer_reset(uint32_t timeout){\r\n   \tuint32_t err_code;\r\n \t\r\n \terr_code = app_timer_stop(m_sec_req_timer_id);\r\n   \tAPP_ERROR_CHECK(err_code);\r\n\r\n \terr_code = app_timer_create(&amp;m_sec_req_timer_id,\r\n                               APP_TIMER_MODE_SINGLE_SHOT,\r\n   \t                            sec_req_timeout_handler);\r\n   \tAPP_ERROR_CHECK(err_code);\r\n   \t\r\n \terr_code = app_timer_start(m_sec_req_timer_id,\r\n                               timeout,\r\n                               NULL);\r\n   \tAPP_ERROR_CHECK(err_code);\r\n }\r\n\r\n\/**@brief Function for handling Peer Manager events.\r\n *\r\n * @param[in] p_evt  Peer Manager event.\r\n *\/\r\nstatic void pm_evt_handler(pm_evt_t const * p_evt)\r\n{\r\n    ret_code_t err_code;\r\n\r\n    switch (p_evt-&gt;evt_id)\r\n    {\r\n        case PM_EVT_BONDED_PEER_CONNECTED:\r\n        {\r\n            NRF_LOG_INFO(\"Connected to a previously bonded device.\\r\\n\");\r\n        } break;\r\n\r\n        case PM_EVT_CONN_SEC_SUCCEEDED:\r\n        {\r\n            NRF_LOG_INFO(\"Connection secured. Role: %d. conn_handle: %d, Procedure: %d\\r\\n\",\r\n                         ble_conn_state_role(p_evt-&gt;conn_handle),\r\n                         p_evt-&gt;conn_handle,\r\n                         p_evt-&gt;params.conn_sec_succeeded.procedure);\r\n        } break;\r\n\r\n        case PM_EVT_CONN_SEC_FAILED:\r\n        {\r\n            \/* Often, when securing fails, it shouldn't be restarted, for security reasons.\r\n             * Other times, it can be restarted directly.\r\n             * Sometimes it can be restarted, but only after changing some Security Parameters.\r\n             * Sometimes, it cannot be restarted until the link is disconnected and reconnected.\r\n             * Sometimes it is impossible, to secure the link, or the peer device does not support it.\r\n             * How to handle this error is highly application dependent. *\/\r\n        } break;\r\n\r\n        case PM_EVT_CONN_SEC_CONFIG_REQ:\r\n        {\r\n            \/\/ Reject pairing request from an already bonded peer.\r\n            pm_conn_sec_config_t conn_sec_config = {.allow_repairing = false};\r\n            pm_conn_sec_config_reply(p_evt-&gt;conn_handle, &amp;conn_sec_config);\r\n        } break;\r\n\r\n        case PM_EVT_STORAGE_FULL:\r\n        {\r\n            \/\/ Run garbage collection on the flash.\r\n            err_code = fds_gc();\r\n            if (err_code == FDS_ERR_BUSY || err_code == FDS_ERR_NO_SPACE_IN_QUEUES)\r\n            {\r\n                \/\/ Retry.\r\n            }\r\n            else\r\n            {\r\n                APP_ERROR_CHECK(err_code);\r\n            }\r\n        } break;\r\n\r\n        case PM_EVT_PEERS_DELETE_SUCCEEDED:\r\n        {\r\n            scan_start();\r\n        } break;\r\n\r\n        case PM_EVT_LOCAL_DB_CACHE_APPLY_FAILED:\r\n        {\r\n            \/\/ The local database has likely changed, send service changed indications.\r\n            pm_local_database_has_changed();\r\n        } break;\r\n\r\n        case PM_EVT_PEER_DATA_UPDATE_FAILED:\r\n        {\r\n            \/\/ Assert.\r\n            APP_ERROR_CHECK(p_evt-&gt;params.peer_data_update_failed.error);\r\n        } break;\r\n\r\n        case PM_EVT_PEER_DELETE_FAILED:\r\n        {\r\n            \/\/ Assert.\r\n            APP_ERROR_CHECK(p_evt-&gt;params.peer_delete_failed.error);\r\n        } break;\r\n\r\n        case PM_EVT_PEERS_DELETE_FAILED:\r\n        {\r\n            \/\/ Assert.\r\n            APP_ERROR_CHECK(p_evt-&gt;params.peers_delete_failed_evt.error);\r\n        } break;\r\n\r\n        case PM_EVT_ERROR_UNEXPECTED:\r\n        {\r\n            \/\/ Assert.\r\n            APP_ERROR_CHECK(p_evt-&gt;params.error_unexpected.error);\r\n        } break;\r\n\r\n        case PM_EVT_CONN_SEC_START:\r\n        case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:\r\n        case PM_EVT_PEER_DELETE_SUCCEEDED:\r\n        case PM_EVT_LOCAL_DB_CACHE_APPLIED:\r\n        case PM_EVT_SERVICE_CHANGED_IND_SENT:\r\n        case PM_EVT_SERVICE_CHANGED_IND_CONFIRMED:\r\n        default:\r\n            break;\r\n    }\r\n}\r\n\r\n\r\n\/**\r\n * @brief Parses advertisement data, providing length and location of the field in case\r\n *        matching data is found.\r\n *\r\n * @param[in]  Type of data to be looked for in advertisement data.\r\n * @param[in]  Advertisement report length and pointer to report.\r\n * @param[out] If data type requested is found in the data report, type data length and\r\n *             pointer to data will be populated here.\r\n *\r\n * @retval NRF_SUCCESS if the data type is found in the report.\r\n * @retval NRF_ERROR_NOT_FOUND if the data type could not be found.\r\n *\/\r\nstatic uint32_t adv_report_parse(uint8_t type, data_t * p_advdata, data_t * p_typedata)\r\n{\r\n    uint32_t  index = 0;\r\n    uint8_t * p_data;\r\n\r\n    p_data = p_advdata-&gt;p_data;\r\n\r\n    while (index &lt; p_advdata-&gt;data_len)\r\n    {\r\n        uint8_t field_length = p_data[index];\r\n        uint8_t field_type   = p_data[index + 1];\r\n\r\n        if (field_type == type)\r\n        {\r\n            p_typedata-&gt;p_data   = &amp;p_data[index + 2];\r\n            p_typedata-&gt;data_len = field_length - 1;\r\n            return NRF_SUCCESS;\r\n        }\r\n        index += field_length + 1;\r\n    }\r\n    return NRF_ERROR_NOT_FOUND;\r\n}\r\n\r\n\r\n\/**@brief Function for putting the chip into sleep mode.\r\n *\r\n * @note This function will not return.\r\n *\/\r\nstatic void sleep_mode_enter(void)\r\n{   uint32_t err_code;\r\n    \/\/ Go to system-off mode (this function will not return; wakeup will cause a reset).\r\n    err_code = sd_power_system_off();\r\n    APP_ERROR_CHECK(err_code);\r\n}\r\n\r\n\r\n\/**@brief Function for searching a given name in the advertisement packets.\r\n *\r\n * @details Use this function to parse received advertising data and to find a given\r\n * name in them either as 'complete_local_name' or as 'short_local_name'.\r\n *\r\n * @param[in]   p_adv_report   advertising data to parse.\r\n * @param[in]   name_to_find   name to search.\r\n * @return   true if the given name was found, false otherwise.\r\n *\/\r\nstatic bool find_adv_name(const ble_gap_evt_adv_report_t *p_adv_report, const char * name_to_find)\r\n{\r\n    uint32_t err_code;\r\n    data_t   adv_data;\r\n    data_t   dev_name;\r\n\r\n    \/\/ Initialize advertisement report for parsing\r\n    adv_data.p_data     = (uint8_t *)p_adv_report-&gt;data;\r\n    adv_data.data_len   = p_adv_report-&gt;dlen;\r\n\r\n\r\n    \/\/search for advertising names\r\n    err_code = adv_report_parse(BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME,\r\n                                &amp;adv_data,\r\n                                &amp;dev_name);\r\n    if (err_code == NRF_SUCCESS)\r\n    {\r\n        if (memcmp(name_to_find, dev_name.p_data, dev_name.data_len )== 0)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        \/\/ Look for the short local name if it was not found as complete\r\n        err_code = adv_report_parse(BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME,\r\n                                    &amp;adv_data,\r\n                                    &amp;dev_name);\r\n        if (err_code != NRF_SUCCESS)\r\n        {\r\n            return false;\r\n        }\r\n        if (memcmp(m_target_periph_name, dev_name.p_data, dev_name.data_len )== 0)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n    return false;\r\n}\r\n\r\n\r\n\/**@brief Function for searching a given addr in the advertisement packets.\r\n *\r\n * @details Use this function to parse received advertising data and to find a given\r\n * addr in them.\r\n *\r\n * @param[in]   p_adv_report   advertising data to parse.\r\n * @param[in]   p_addr   name to search.\r\n * @return   true if the given name was found, false otherwise.\r\n *\/\r\nstatic bool find_peer_addr(const ble_gap_evt_adv_report_t *p_adv_report, const ble_gap_addr_t * p_addr)\r\n{\r\n    if (p_addr-&gt;addr_type == p_adv_report-&gt;peer_addr.addr_type)\r\n    {\r\n        if (memcmp(p_addr-&gt;addr, p_adv_report-&gt;peer_addr.addr, sizeof(p_adv_report-&gt;peer_addr.addr)) == 0)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n    return false;\r\n}\r\n\r\n\r\n\/**@brief Function for searching a UUID in the advertisement packets.\r\n *\r\n * @details Use this function to parse received advertising data and to find a given\r\n * UUID in them.\r\n *\r\n * @param[in]   p_adv_report   advertising data to parse.\r\n * @param[in]   uuid_to_find   UUIID to search.\r\n * @return   true if the given UUID was found, false otherwise.\r\n *\/\r\nstatic bool find_adv_uuid(const ble_gap_evt_adv_report_t *p_adv_report, const uint16_t uuid_to_find)\r\n{\r\n    uint32_t err_code;\r\n    data_t   adv_data;\r\n    data_t   type_data;\r\n\r\n    \/\/ Initialize advertisement report for parsing.\r\n    adv_data.p_data     = (uint8_t *)p_adv_report-&gt;data;\r\n    adv_data.data_len   = p_adv_report-&gt;dlen;\r\n\r\n    err_code = adv_report_parse(BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE,\r\n                                &amp;adv_data,\r\n                                &amp;type_data);\r\n\r\n    if (err_code != NRF_SUCCESS)\r\n    {\r\n        \/\/ Look for the services in 'complete' if it was not found in 'more available'.\r\n        err_code = adv_report_parse(BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE,\r\n                                    &amp;adv_data,\r\n                                    &amp;type_data);\r\n\r\n        if (err_code != NRF_SUCCESS)\r\n        {\r\n            \/\/ If we can't parse the data, then exit.\r\n            return false;\r\n        }\r\n    }\r\n\r\n    \/\/ Verify if any UUID match the given UUID.\r\n    for (uint32_t u_index = 0; u_index &lt; (type_data.data_len \/ sizeof(uint16_t)); u_index++)\r\n    {\r\n        uint16_t extracted_uuid;\r\n\r\n        UUID16_EXTRACT(&amp;extracted_uuid, &amp;type_data.p_data[u_index * sizeof(uint16_t)]);\r\n\r\n        if (extracted_uuid == uuid_to_find)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n    return false;\r\n}\r\n\r\n\r\n\/**@brief Function for handling the Application's BLE Stack events.\r\n *\r\n * @param[in]   p_ble_evt   Bluetooth stack event.\r\n *\/\r\nstatic void on_ble_evt(ble_evt_t * p_ble_evt)\r\n{\r\n    uint32_t                err_code;\r\n    const ble_gap_evt_t   * p_gap_evt = &amp;p_ble_evt-&gt;evt.gap_evt;\r\n\r\n    switch (p_ble_evt-&gt;header.evt_id)\r\n    {\r\n        case BLE_GAP_EVT_CONNECTED:\r\n        {\r\n            NRF_LOG_INFO(\"Connected.\\r\\n\");\r\n            m_pending_db_disc_conn = p_ble_evt-&gt;evt.gap_evt.conn_handle;\r\n            m_retry_db_disc = false;\r\n            \/\/ Discover peer's services.\r\n            err_code = ble_db_discovery_start(&amp;m_ble_db_discovery, m_pending_db_disc_conn);\r\n            if (err_code == NRF_ERROR_BUSY)\r\n            {\r\n                NRF_LOG_INFO(\"ble_db_discovery_start() returned busy, will retry later.\\r\\n\");\r\n                m_retry_db_disc = true;\r\n            }\r\n            else\r\n            {\r\n                APP_ERROR_CHECK(err_code);\r\n            }\r\n\t\t\t\r\n        \t\r\n            if (ble_conn_state_n_centrals() &lt; NRF_BLE_CENTRAL_LINK_COUNT)\r\n            {\r\n                scan_start();\r\n            }\r\n        } break;\r\n\r\n        case BLE_GAP_EVT_ADV_REPORT:\r\n        {\r\n            bool do_connect = false;\r\n            if (is_connect_per_addr)\r\n            {\r\n                if (find_peer_addr(&amp;p_gap_evt-&gt;params.adv_report, &amp;m_target_periph_addr))\r\n                {\r\n                    NRF_LOG_INFO(\"Address match send connect_request.\\r\\n\");\r\n                    do_connect = true;\r\n                }\r\n            }\r\n        \tif(!do_connect){\r\n\t        \tif (strlen(m_target_periph_name) != 0)\r\n\t            {\r\n\t                if (find_adv_name(&amp;p_gap_evt-&gt;params.adv_report, m_target_periph_name))\r\n\t                {\r\n\t                    do_connect = true;\r\n\t                    NRF_LOG_INFO(\"Name match send connect_request.\\r\\n\");\r\n\t                }\r\n\t            }\r\n\t            else\r\n\t            {\r\n\t                if (find_adv_uuid(&amp;p_gap_evt-&gt;params.adv_report, BLE_UUID_ELINK_SERVICE))\r\n\t                {\r\n\t                    do_connect = true;\r\n\t                    NRF_LOG_INFO(\"UUID match send connect_request.\\r\\n\");\r\n\t                }\r\n\t            }\r\n        \t}\r\n          \r\n            if (do_connect)\r\n            {\r\n                \/\/ Stop scanning.\r\n                (void) sd_ble_gap_scan_stop();\r\n\r\n                #if (NRF_SD_BLE_API_VERSION == 2)\r\n                    m_scan_param.selective = 0;\r\n                #endif\r\n                #if (NRF_SD_BLE_API_VERSION == 3)\r\n                    m_scan_param.use_whitelist = 0;\r\n                #endif\r\n\r\n                \/\/ Initiate connection.\r\n                err_code = sd_ble_gap_connect(&amp;p_gap_evt-&gt;params.adv_report.peer_addr,\r\n                                              &amp;m_scan_param,\r\n                                              &amp;m_connection_param);\r\n\r\n                m_whitelist_disabled = false;\r\n\r\n                if (err_code != NRF_SUCCESS)\r\n                {\r\n                    NRF_LOG_ERROR(\"Connection Request Failed, reason %d.\\r\\n\", err_code);\r\n                }\r\n            }\r\n        } break; \/\/ BLE_GAP_EVT_ADV_REPORT\r\n\r\n        case BLE_GAP_EVT_DISCONNECTED:\r\n        {\r\n            NRF_LOG_INFO(\"Disconnected, reason 0x%x.\\r\\n\",\r\n                         p_ble_evt-&gt;evt.gap_evt.params.disconnected.reason);\r\n\r\n        \tm_conn_handle = BLE_CONN_HANDLE_INVALID;\r\n\r\n            \/\/ Reset DB discovery structure.\r\n            memset(&amp;m_ble_db_discovery, 0 , sizeof (m_ble_db_discovery));\r\n\r\n            if (ble_conn_state_n_centrals() &lt; NRF_BLE_CENTRAL_LINK_COUNT)\r\n            {\r\n                scan_start();\r\n            }\r\n        } break;\r\n\r\n        case BLE_GAP_EVT_TIMEOUT:\r\n        {\r\n            if (p_gap_evt-&gt;params.timeout.src == BLE_GAP_TIMEOUT_SRC_SCAN)\r\n            {\r\n                NRF_LOG_DEBUG(\"Scan timed out.\\r\\n\");\r\n                scan_start();\r\n            }\r\n            else if (p_gap_evt-&gt;params.timeout.src == BLE_GAP_TIMEOUT_SRC_CONN)\r\n            {\r\n                NRF_LOG_INFO(\"Connection Request timed out.\\r\\n\");\r\n            }\r\n        } break;\r\n\r\n        case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST:\r\n            \/\/ Accepting parameters requested by peer.\r\n            err_code = sd_ble_gap_conn_param_update(p_gap_evt-&gt;conn_handle,\r\n                                                    &amp;p_gap_evt-&gt;params.conn_param_update_request.conn_params);\r\n            APP_ERROR_CHECK(err_code);\r\n            break;\r\n\r\n        case BLE_GATTC_EVT_TIMEOUT:\r\n            \/\/ Disconnect on GATT Client timeout event.\r\n            NRF_LOG_DEBUG(\"GATT Client Timeout.\\r\\n\");\r\n            err_code = sd_ble_gap_disconnect(p_ble_evt-&gt;evt.gattc_evt.conn_handle,\r\n                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);\r\n            APP_ERROR_CHECK(err_code);\r\n            break;\r\n\r\n        case BLE_GATTS_EVT_TIMEOUT:\r\n            \/\/ Disconnect on GATT Server timeout event.\r\n            NRF_LOG_DEBUG(\"GATT Server Timeout.\\r\\n\");\r\n            err_code = sd_ble_gap_disconnect(p_ble_evt-&gt;evt.gatts_evt.conn_handle,\r\n                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);\r\n            APP_ERROR_CHECK(err_code);\r\n            break;\r\n\r\n        default:\r\n            break;\r\n    }\r\n}\r\n\r\n\r\n\/**@brief Function for handling the Application's system events.\r\n *\r\n * @param[in]   sys_evt   system event.\r\n *\/\r\nstatic void on_sys_evt(uint32_t sys_evt)\r\n{\r\n    switch (sys_evt)\r\n    {\r\n        case NRF_EVT_FLASH_OPERATION_SUCCESS:\r\n            \/* fall through *\/\r\n        case NRF_EVT_FLASH_OPERATION_ERROR:\r\n\r\n            if (m_memory_access_in_progress)\r\n            {\r\n                m_memory_access_in_progress = false;\r\n                scan_start();\r\n            }\r\n            break;\r\n\r\n        default:\r\n            \/\/ No implementation needed.\r\n            break;\r\n    }\r\n}\r\n\r\n\r\n\/**@brief Function for dispatching a BLE stack event to all modules with a BLE stack event handler.\r\n *\r\n * @details This function is called from the scheduler in the main loop after a BLE stack event has\r\n *  been received.\r\n *\r\n * @param[in]   p_ble_evt   Bluetooth stack event.\r\n *\/\r\nstatic void ble_evt_dispatch(ble_evt_t * p_ble_evt)\r\n{\r\n    \/\/ Modules which depend on ble_conn_state, like Peer Manager,\r\n    \/\/ should have their callbacks invoked after ble_conn_state's.\r\n    ble_conn_state_on_ble_evt(p_ble_evt);\r\n    pm_on_ble_evt(p_ble_evt);\r\n    ble_db_discovery_on_ble_evt(&amp;m_ble_db_discovery, p_ble_evt);\r\n    bsp_btn_ble_on_ble_evt(p_ble_evt);\r\n    nrf_ble_gatt_on_ble_evt(&amp;m_gatt, p_ble_evt);\r\n    on_ble_evt(p_ble_evt);\r\n}\r\n\r\n\r\n\r\n\/**@brief Function for dispatching a system event to interested modules.\r\n *\r\n * @details This function is called from the System event interrupt handler after a system\r\n *          event has been received.\r\n *\r\n * @param[in]   sys_evt   System stack event.\r\n *\/\r\nstatic void sys_evt_dispatch(uint32_t sys_evt)\r\n{\r\n    fs_sys_event_handler(sys_evt);\r\n    on_sys_evt(sys_evt);\r\n}\r\n\r\n\r\n\/**@brief Function for initializing the BLE stack.\r\n *\r\n * @details Initializes the SoftDevice and the BLE event interrupt.\r\n *\/\r\nstatic void ble_stack_init(void)\r\n{\r\n    uint32_t err_code;\r\n\r\n    nrf_clock_lf_cfg_t clock_lf_cfg;\r\n    clock_lf_cfg.rc_ctiv = 16;\r\n    clock_lf_cfg.rc_temp_ctiv = 2;\r\n    clock_lf_cfg.source = NRF_CLOCK_LF_SRC_RC;\r\n    clock_lf_cfg.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM;\r\n\t\r\n\r\n    \/\/ Initialize the SoftDevice handler module.\r\n    SOFTDEVICE_HANDLER_INIT(&amp;clock_lf_cfg, NULL);\r\n\r\n    ble_enable_params_t ble_enable_params;\r\n    err_code = softdevice_enable_get_default_config(NRF_BLE_CENTRAL_LINK_COUNT,\r\n                                                    NRF_BLE_PERIPHERAL_LINK_COUNT,\r\n                                                    &amp;ble_enable_params);\r\n    APP_ERROR_CHECK(err_code);\r\n\r\n    \/\/Check the ram settings against the used number of links\r\n    CHECK_RAM_START_ADDR(NRF_BLE_CENTRAL_LINK_COUNT, NRF_BLE_PERIPHERAL_LINK_COUNT);\r\n\r\n    \/\/ Enable BLE stack.\r\n#if (NRF_SD_BLE_API_VERSION == 3)\r\n    ble_enable_params.gatt_enable_params.att_mtu = NRF_BLE_GATT_MAX_MTU_SIZE;\r\n#endif\r\n\r\n    err_code = softdevice_enable(&amp;ble_enable_params);\r\n    APP_ERROR_CHECK(err_code);\r\n\r\n    \/\/ Register with the SoftDevice handler module for BLE events.\r\n    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);\r\n    APP_ERROR_CHECK(err_code);\r\n\r\n    \/\/ Register with the SoftDevice handler module for System events.\r\n    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);\r\n    APP_ERROR_CHECK(err_code);\r\n}\r\n\r\n\r\n\r\n\/**@brief Function for the Peer Manager initialization.\r\n *\r\n * @param[in] erase_bonds  Indicates whether bonding information should be cleared from\r\n *                         persistent storage during initialization of the Peer Manager.\r\n *\/\r\nstatic void peer_manager_init(bool erase_bonds)\r\n{\r\n    ble_gap_sec_params_t sec_param;\r\n    ret_code_t err_code;\r\n\r\n    err_code = pm_init();\r\n    APP_ERROR_CHECK(err_code);\r\n\r\n    if (erase_bonds)\r\n    {\r\n        err_code = pm_peers_delete();\r\n        APP_ERROR_CHECK(err_code);\r\n    }\r\n\r\n    memset(&amp;sec_param, 0, sizeof(ble_gap_sec_params_t));\r\n\r\n    \/\/ Security parameters to be used for all security procedures.\r\n    sec_param.bond              = SEC_PARAM_BOND;\r\n    sec_param.mitm              = SEC_PARAM_MITM;\r\n    sec_param.lesc              = SEC_PARAM_LESC;\r\n    sec_param.keypress          = SEC_PARAM_KEYPRESS;\r\n    sec_param.io_caps           = SEC_PARAM_IO_CAPABILITIES;\r\n    sec_param.oob               = SEC_PARAM_OOB;\r\n    sec_param.min_key_size      = SEC_PARAM_MIN_KEY_SIZE;\r\n    sec_param.max_key_size      = SEC_PARAM_MAX_KEY_SIZE;\r\n    sec_param.kdist_own.enc     = 1;\r\n    sec_param.kdist_own.id      = 1;\r\n    sec_param.kdist_peer.enc    = 1;\r\n    sec_param.kdist_peer.id     = 1;\r\n\r\n    err_code = pm_sec_params_set(&amp;sec_param);\r\n    APP_ERROR_CHECK(err_code);\r\n\r\n    err_code = pm_register(pm_evt_handler);\r\n    APP_ERROR_CHECK(err_code);\r\n}\r\n\r\n\r\n\r\n\/**@brief Function for handling events from the BSP module.\r\n *\r\n * @param[in]   event   Event generated by button press.\r\n *\/\r\nvoid bsp_event_handler(bsp_event_t event)\r\n{\r\n    switch (event)\r\n    {\r\n    \tcase BSP_EVENT_KEY_1:\t\/*P017 Push*\/\r\n    \t\tbutton1_event_handler();\r\n\t    \tbutton1_timer_start();\r\n    \t\t\/*timer start*\/\r\n        \tbreak;\r\n\t\tcase BSP_EVENT_KEY_2:\t\/*P005 Push*\/\r\n    \t\tbutton2_event_handler();\r\n\t    \tbutton2_timer_start();\r\n        \tbreak;\r\n        default:\r\n            break;\r\n    }\r\n\r\n}\r\n \t\r\nstatic  void button1_timer_start(void){\r\n \tuint32_t err_code;\r\n\tif(!m_button_timer){\r\n\t\tm_button_timer = true;\r\n\t \terr_code = app_timer_create(&amp;m_button1_push_timer_id,\r\n\t                               APP_TIMER_MODE_SINGLE_SHOT,\r\n\t   \t                            button1_timer_event_handler);\r\n\t   \tAPP_ERROR_CHECK(err_code);\r\n\t   \t\r\n\t \terr_code = app_timer_start(m_button1_push_timer_id,\r\n\t                               BUTTON_PUSH_CHECK_TIME,\r\n\t                               NULL);\r\n\t   \tAPP_ERROR_CHECK(err_code);\r\n\t}\r\n}\r\n\r\n static  void button1_timer_event_handler(void * context){\r\n \tuint32_t err_code;\r\n\t\r\n \tif(bsp_button_is_pressed(1)){\/*push *\/\r\n \t\tbutton1_event_handler();\r\n\t \terr_code = app_timer_start(m_button1_push_timer_id,\r\n\t                               BUTTON_PUSH_CHECK_TIME,\r\n\t                               NULL);\r\n\t   \tAPP_ERROR_CHECK(err_code);\t\r\n \t}else{\r\n \t\tm_button_timer = false;\r\n \t}\r\n}\r\n \t\r\n\r\nstatic  void button2_timer_start(void){\r\n\tuint32_t err_code;\r\n\tif(!m_button_timer){\r\n\t\tm_button_timer = true;\r\n\t\terr_code = app_timer_create(&amp;m_button2_push_timer_id,\r\n\t                               APP_TIMER_MODE_SINGLE_SHOT,\r\n\t   \t                            button2_timer_event_handler);\r\n\t   \tAPP_ERROR_CHECK(err_code);\r\n\t   \t\r\n\t \terr_code = app_timer_start(m_button2_push_timer_id,\r\n\t                               BUTTON_PUSH_CHECK_TIME,\r\n\t                               NULL);\r\n\t   \tAPP_ERROR_CHECK(err_code);\t\r\n\t}\r\n\t\r\n}\r\n static  void button2_timer_event_handler(void * context){\r\n \tuint32_t err_code;\r\n\t\r\n \tif(bsp_button_is_pressed(2)){\/*push *\/\r\n \t\tbutton2_event_handler();\r\n\t \terr_code = app_timer_start(m_button2_push_timer_id,\r\n\t                               BUTTON_PUSH_CHECK_TIME,\r\n\t                               NULL);\r\n\t   \tAPP_ERROR_CHECK(err_code);\t\r\n \t}else{\r\n \t\tm_button_timer = false;\r\n \t}\r\n}\r\n \t\r\n\/**@brief Function for handling the security request timer time-out.\r\n *\r\n * @details This function is called each time the security request timer expires.\r\n *\r\n * @param[in] p_context  Pointer used for passing context information from the\r\n *                       app_start_timer() call to the time-out handler.\r\n *\/\r\nstatic void sec_req_timeout_handler(void * p_context)\r\n{\r\n\tsleep_mode_enter();\r\n}\r\n\r\n\/**\r\n * @brief Heart rate collector initialization.\r\n *\/\r\nstatic void elin_c_init(void)\r\n{\r\n\r\n    uint32_t err_code = ble_elin_c_init();\r\n    APP_ERROR_CHECK(err_code);\r\n}\r\n\r\nstatic uint32_t ble_elin_c_init(void)\r\n{\r\n\r\n    ble_uuid_t elin_uuid;\r\n\r\n    elin_uuid.type = BLE_UUID_TYPE_BLE;\r\n    elin_uuid.uuid = BLE_UUID_ELINK_SERVICE;\r\n\tm_conn_handle = BLE_CONN_HANDLE_INVALID;\r\n\r\n    return ble_db_discovery_evt_register(&amp;elin_uuid);\r\n}\r\n\r\n\/**\r\n * @brief Database discovery collector initialization.\r\n *\/\r\nstatic void db_discovery_init(void)\r\n{\r\n    uint32_t err_code = ble_db_discovery_init(db_disc_handler);\r\n    APP_ERROR_CHECK(err_code);\r\n}\r\n\r\n\r\n\/**@brief Retrieve a list of peer manager peer IDs.\r\n *\r\n * @param[inout] p_peers   The buffer where to store the list of peer IDs.\r\n * @param[inout] p_size    In: The size of the @p p_peers buffer.\r\n *                         Out: The number of peers copied in the buffer.\r\n *\/\r\nstatic void peer_list_get(pm_peer_id_t * p_peers, uint32_t * p_size)\r\n{\r\n    pm_peer_id_t peer_id;\r\n    uint32_t     peers_to_copy;\r\n\r\n    peers_to_copy = (*p_size &lt; BLE_GAP_WHITELIST_ADDR_MAX_COUNT) ?\r\n                     *p_size : BLE_GAP_WHITELIST_ADDR_MAX_COUNT;\r\n\r\n    peer_id = pm_next_peer_id_get(PM_PEER_ID_INVALID);\r\n    *p_size = 0;\r\n\r\n    while ((peer_id != PM_PEER_ID_INVALID) &amp;&amp; (peers_to_copy--))\r\n    {\r\n        p_peers[(*p_size)++] = peer_id;\r\n        peer_id = pm_next_peer_id_get(peer_id);\r\n    }\r\n}\r\n\r\n\r\nstatic void whitelist_load()\r\n{\r\n    ret_code_t   ret;\r\n    pm_peer_id_t peers[8];\r\n    uint32_t     peer_cnt;\r\n\r\n    memset(peers, PM_PEER_ID_INVALID, sizeof(peers));\r\n    peer_cnt = (sizeof(peers) \/ sizeof(pm_peer_id_t));\r\n\r\n    \/\/ Load all peers from flash and whitelist them.\r\n    peer_list_get(peers, &amp;peer_cnt);\r\n\r\n    ret = pm_whitelist_set(peers, peer_cnt);\r\n    APP_ERROR_CHECK(ret);\r\n\r\n    \/\/ Setup the device identies list.\r\n    \/\/ Some SoftDevices do not support this feature.\r\n    ret = pm_device_identities_list_set(peers, peer_cnt);\r\n    if (ret != NRF_ERROR_NOT_SUPPORTED)\r\n    {\r\n        APP_ERROR_CHECK(ret);\r\n    }\r\n}\r\n\r\n\r\n\/**@brief Function to start scanning.\r\n *\/\r\nstatic void scan_start(void)\r\n{\r\n    uint32_t flash_busy;\r\n\r\n    \/\/ If there is any pending write to flash, defer scanning until it completes.\r\n    (void) fs_queued_op_count_get(&amp;flash_busy);\r\n\r\n    if (flash_busy != 0)\r\n    {\r\n        m_memory_access_in_progress = true;\r\n        return;\r\n    }\r\n\r\n    \/\/ Whitelist buffers.\r\n    ble_gap_addr_t whitelist_addrs[8];\r\n    ble_gap_irk_t  whitelist_irks[8];\r\n\r\n    memset(whitelist_addrs, 0x00, sizeof(whitelist_addrs));\r\n    memset(whitelist_irks,  0x00, sizeof(whitelist_irks));\r\n\r\n    uint32_t addr_cnt = (sizeof(whitelist_addrs) \/ sizeof(ble_gap_addr_t));\r\n    uint32_t irk_cnt  = (sizeof(whitelist_irks)  \/ sizeof(ble_gap_irk_t));\r\n\r\n    #if (NRF_SD_BLE_API_VERSION == 2)\r\n\r\n        ble_gap_addr_t * p_whitelist_addrs[8];\r\n        ble_gap_irk_t  * p_whitelist_irks[8];\r\n\r\n        for (uint32_t i = 0; i &lt; 8; i++)\r\n        {\r\n            p_whitelist_addrs[i] = &amp;whitelist_addrs[i];\r\n            p_whitelist_irks[i]  = &amp;whitelist_irks[i];\r\n        }\r\n\r\n        ble_gap_whitelist_t whitelist =\r\n        {\r\n            .pp_addrs = p_whitelist_addrs,\r\n            .pp_irks  = p_whitelist_irks,\r\n        };\r\n\r\n    #endif\r\n\r\n    \/\/ Reload the whitelist and whitelist all peers.\r\n    whitelist_load();\r\n\r\n    ret_code_t ret;\r\n\r\n    \/\/ Get the whitelist previously set using pm_whitelist_set().\r\n    ret = pm_whitelist_get(whitelist_addrs, &amp;addr_cnt,\r\n                           whitelist_irks,  &amp;irk_cnt);\r\n\r\n    m_scan_param.active   = 0;\r\n    m_scan_param.interval = SCAN_INTERVAL;\r\n    m_scan_param.window   = SCAN_WINDOW;\r\n\r\n    if (((addr_cnt == 0) &amp;&amp; (irk_cnt == 0)) ||\r\n        (m_whitelist_disabled))\r\n    {\r\n        \/\/ Don't use whitelist.\r\n        #if (NRF_SD_BLE_API_VERSION == 2)\r\n            m_scan_param.selective   = 0;\r\n            m_scan_param.p_whitelist = NULL;\r\n        #endif\r\n        #if (NRF_SD_BLE_API_VERSION == 3)\r\n            m_scan_param.use_whitelist  = 0;\r\n            m_scan_param.adv_dir_report = 0;\r\n        #endif\r\n        m_scan_param.timeout  = 0x0000; \/\/ No timeout.\r\n    }\r\n    else\r\n    {\r\n        \/\/ Use whitelist.\r\n        #if (NRF_SD_BLE_API_VERSION == 2)\r\n            whitelist.addr_count     = addr_cnt;\r\n            whitelist.irk_count      = irk_cnt;\r\n            m_scan_param.selective   = 1;\r\n            m_scan_param.p_whitelist = &amp;whitelist;\r\n        #endif\r\n        #if (NRF_SD_BLE_API_VERSION == 3)\r\n            m_scan_param.use_whitelist  = 1;\r\n            m_scan_param.adv_dir_report = 0;\r\n        #endif\r\n        m_scan_param.timeout  = 0x001E; \/\/ 30 seconds.\r\n    }\r\n\r\n    NRF_LOG_INFO(\"Starting scan.\\r\\n\");\r\n    ret = sd_ble_gap_scan_start(&amp;m_scan_param);\r\n    APP_ERROR_CHECK(ret);\r\n   \tsleep_timer_reset(SYSTEM_OFF_TIME_SCAN);\r\n}\r\n\r\n\r\n\/**@brief Function for initializing buttons and leds.\r\n *\r\n * @param[out] p_erase_bonds  Will be true if the clear bonding button was pressed to wake the application up.\r\n *\/\r\nstatic void buttons_leds_init(bool * p_erase_bonds)\r\n{\r\n    bsp_event_t startup_event;\r\n\r\n    uint32_t err_code = bsp_init(BSP_INIT_BUTTONS,\r\n                                 APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),\r\n                                 bsp_event_handler);\r\n    APP_ERROR_CHECK(err_code);\r\n\r\n    err_code = bsp_btn_ble_init(NULL, &amp;startup_event);\r\n    APP_ERROR_CHECK(err_code);\r\n\r\n    *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA);\r\n\r\n}\r\n\r\n\r\n\/**@brief Function for initializing the nrf log module.\r\n *\/\r\nstatic void log_init(void)\r\n{\r\n    ret_code_t err_code = NRF_LOG_INIT(NULL);\r\n    APP_ERROR_CHECK(err_code);\r\n}\r\n\r\n\r\n\/** @brief Function for the Power manager.\r\n *\/\r\nstatic void power_manage(void)\r\n{\r\n    uint32_t err_code = sd_app_evt_wait();\r\n    APP_ERROR_CHECK(err_code);\r\n}\r\n\r\n\r\n\/* GATT generic Event handler. *\/\r\nvoid gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t * p_evt)\r\n{\r\n    NRF_LOG_INFO(\"GATT MTU on link %d changed to %d\\r\\n\",\r\n                 p_evt-&gt;conn_handle,\r\n                 p_evt-&gt;att_mtu_effective);\r\n    if (m_retry_db_disc)\r\n    {\r\n        ret_code_t err_code;\r\n        NRF_LOG_DEBUG(\"Retrying DB discovery.\\r\\n\");\r\n        m_retry_db_disc = false;\r\n        \/\/ Discover peer's services.\r\n        err_code = ble_db_discovery_start(&amp;m_ble_db_discovery, m_pending_db_disc_conn);\r\n        if (err_code == NRF_ERROR_BUSY)\r\n        {\r\n            NRF_LOG_DEBUG(\"ble_db_discovery_start() returned busy, will retry later.\\r\\n\");\r\n            m_retry_db_disc = true;\r\n        }\r\n        else\r\n        {\r\n            APP_ERROR_CHECK(err_code);\r\n        }\r\n    }\r\n}\r\n\r\n\r\n\/* GATT Module init. *\/\r\nvoid gatt_init(void)\r\n{\r\n    ret_code_t err_code = nrf_ble_gatt_init(&amp;m_gatt, gatt_evt_handler);\r\n    APP_ERROR_CHECK(err_code);\r\n}\r\n\r\n\r\nint main(void)\r\n{\r\n\tbool erase_bonds;\r\n\t\r\n\t\/\/ Initialize.\r\n    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);\r\n\r\n\ttimers_init();\r\n\tbuttons_leds_init(&amp;erase_bonds);\r\n    log_init();\r\n    ble_stack_init();\r\n    peer_manager_init(false);\r\n    gatt_init();\r\n    db_discovery_init();\r\n\telin_c_init();\r\n\r\n    scan_start();\r\n\r\n    for (;;)\r\n    {\r\n        if (NRF_LOG_PROCESS() == false)\r\n        {\r\n           power_manage();\r\n        \tif(m_push_switch){\r\n        \t\tsleep_timer_reset(SYSTEM_OFF_TIME_CONN);\r\n\t\t\t\t\r\n        \t\tm_push_switch = false;\r\n        \t}\r\n        }\r\n    }\r\n}\r\n\r\n\r\n \r\nstatic void button1_event_handler(void){\r\n\t\r\n\tif(m_conn_handle != BLE_CONN_HANDLE_INVALID){\r\n   \t\tm_push_switch = true;\r\n\t\tElin_ShiftUp(m_conn_handle);\r\n    }\r\n\r\n\t\r\n}\r\nstatic void button2_event_handler(void){\r\n\t\r\n\tif(m_conn_handle != BLE_CONN_HANDLE_INVALID){\r\n\t\tm_push_switch = true;\r\n\t\tElin_ShiftDown(m_conn_handle);\r\n    }\r\n}\r\n\r\n \t<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u521d\u3081\u306b https:\/\/chikuwa-ringyo.com\/?p=529 https:\/\/chikuwa-ringyo.com\/?p=536 \u306e\u7d9a\u304d\u3002\u5b9f\u969b\u306b\u30b9\u30a4\u30c3\u30c1\u30e6\u30cb\u30c3\u30c8\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u56de\u8def\u3067\u3059\u3002 \u2193\u307f\u305f\u3044\u306a\u611f\u3058\u306b\u306a<\/p>\n","protected":false},"author":1,"featured_media":635,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[27],"tags":[],"_links":{"self":[{"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=\/wp\/v2\/posts\/625"}],"collection":[{"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=625"}],"version-history":[{"count":10,"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=\/wp\/v2\/posts\/625\/revisions"}],"predecessor-version":[{"id":1028,"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=\/wp\/v2\/posts\/625\/revisions\/1028"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=\/wp\/v2\/media\/635"}],"wp:attachment":[{"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chikuwa-ringyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}