<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to use socket?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62910/how-to-use-socket</link><description>&amp;lt;Environment&amp;gt; - Windows10 - nrf v1.3.0 - modem fw 1.2.0 
 I&amp;#39;m attempting to make a socket and communicate with the modem using it. 
 However, sending data doesn&amp;#39;t work out. It was working in v1.2.0. Any tip? 
 I don&amp;#39;t want to use at_cmd.c becuase I need</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Jul 2020 10:38:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62910/how-to-use-socket" /><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/258057?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2020 10:38:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6289943d-5f09-4f57-b6e1-6258b5b79b3f</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Good to hear that you could use nrf_socket to receive SMS.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;To use the SMS library (&lt;span style="text-decoration:underline;"&gt;&amp;quot;&lt;em&gt;A library for managing SMS subscriptions&lt;/em&gt;&amp;quot;)&lt;/span&gt; you would need to add the configuration, in prj.conf:&lt;/p&gt;
&lt;p&gt;CONFIG_SMS=y&lt;/p&gt;
&lt;p&gt;and&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;#include&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;lt;modem/sms.h&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;in your main file.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;br /&gt;Unfortunately, we do not have a sample that uses this library.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/257220?ContentTypeID=1</link><pubDate>Sat, 27 Jun 2020 06:19:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3186ead9-7666-462e-9cda-5521b455b7a9</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;OK. I cloud receive SMS using nrf_socket. Instead, sms.c doesn&amp;#39;t work. I may use it in a wrong way. I hope sample program will be provided.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/257042?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 06:11:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:396a428a-e3e7-48cf-b6e3-bc21a1ba2865</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;I read the link, but the code doesn&amp;#39;t work. Instead this works out&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int fd = nrf_socket(NRF_AF_LTE, NRF_SOCK_DGRAM, NRF_PROTO_AT);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;On the other hand, this doesn&amp;#39;t work. confusing. I referred to at_cmd.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int fd = socket(AF_LTE, SOCK_DGRAM, NPROTO_AT);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/257032?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 01:04:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54a5864c-5010-4438-99c6-d9faeb499fe0</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;in sms.h&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**
 * @brief Register a new listener.
 *
 * A listener is identified by a unique handle value. This handle should be used
 * to unregister the listener. A listener can be registered multiple times with
 * the same or a different context.
 *
 * @param listener Callback function. Cannot be null.
 * @param context User context. Can be null if not used.
 *
 * @retval -EINVAL Invalid parameter.
 * @retval -ENOMEM No memory to register new observers.
 * @return Handle identifying the listener,
 *         or a negative value if an error occurred.
 */
int sms_register_listener(sms_callback_t listener, void *context);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;*The handle should be used to unregister the listener&lt;/p&gt;
&lt;p&gt;=&amp;gt; what does this mean?&lt;/p&gt;
&lt;p&gt;I would like to keep registering SMS notification. In this case, do you have&amp;nbsp;to unregister it every time the handler is called?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/257031?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 00:48:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd9adaa1-e0a9-405d-8222-9d2e324d0a6f</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;I read the link but it doesn&amp;#39;t explain how to use sms.h library.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/256915?ContentTypeID=1</link><pubDate>Thu, 25 Jun 2020 12:33:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c05e56c-3d7f-429c-b961-39ea605e6718</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;in v1.2.0, I could receive SMS.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll check the link later&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/256910?ContentTypeID=1</link><pubDate>Thu, 25 Jun 2020 12:26:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c157fd23-eb8c-4d76-b8e4-67322d76fa1e</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Yusuke,&lt;br /&gt;Please start out just by running AT Client sample and verify that you actually can send SMS with AT commands and that you have a SIM card that supports this.&lt;br /&gt;&lt;br /&gt;You can see an example in this thread on how to do it:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/41755/sending-sms-using-at_client-example/164297#164297"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/41755/sending-sms-using-at_client-example/164297#164297&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/256358?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 09:31:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4897228-12eb-4c43-854f-f892b82e60c1</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;Can&amp;#39;t receive SMS by this program. Any tip?&lt;/p&gt;
&lt;p&gt;&amp;lt;prj.conf&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
# General config
CONFIG_ASSERT=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

# SMS
CONFIG_SMS=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_LOCK_BANDS=y
CONFIG_LTE_LOCK_BAND_MASK=&amp;quot;10000000&amp;quot;
CONFIG_LTE_NETWORK_MODE_LTE_M=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

# BSD library
CONFIG_BSD_LIBRARY=y

# AT host library
CONFIG_AT_HOST_LIBRARY=n
CONFIG_UART_INTERRUPT_DRIVEN=y

# Stacks and heaps
CONFIG_MAIN_STACK_SIZE=3072
CONFIG_HEAP_MEM_POOL_SIZE=16384

# SEGGER RTT for Dev
CONFIG_PRINTK=y
CONFIG_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;main.c&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;modem/sms.h&amp;gt;
#include &amp;lt;modem/lte_lc.h&amp;gt;

void sms_handler(struct sms_data *const data, void *context)
{
    printk(&amp;quot;here\n&amp;quot;);
}

void main(){
    int ret;
    
	/* Configure LTE-M */
    printk(&amp;quot;LTE Link Connecting ...\n&amp;quot;);
    ret = lte_lc_init_and_connect();
    printk(&amp;quot;LTE Link Connected!\n&amp;quot;);
	if (ret) {
		printk(&amp;quot;Error: modem_configure\n&amp;quot;);
		return;
	}

	/* SMS socket set up */
	if (sms_init() != 0) {
        printk(&amp;quot;ERROR: sms_init\n&amp;quot;);
		return;
	}

    /* Set up listener */
	if (sms_register_listener(sms_handler, NULL) != 0) {
        printk(&amp;quot;ERROR: sms_register_listener\n&amp;quot;);
		return;
	}

    printk(&amp;quot;SMS waiting...&amp;quot;);
    
    while(1){}
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/256347?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 08:57:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9585c034-c578-42fd-8f0e-756987373f3b</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;Do you know any sample program using sms.c?&lt;/p&gt;
&lt;p&gt;I really don&amp;#39;t know what arguments should be included in sms listener...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/256343?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 08:47:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f71d325-c747-40c5-a411-e152ca4cf0bc</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;Thank you for your reply! I read this document&lt;/p&gt;
&lt;p&gt;What is User context in sms_register_listener arguments?&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use socket?</title><link>https://devzone.nordicsemi.com/thread/256339?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 08:33:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76d9809e-47c6-4d25-9ff4-c40a8eeaa97e</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Yusuke,&lt;/p&gt;
&lt;p&gt;In NCS v1.3.0 we actually have an &amp;quot;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/modem/sms.html" rel="noopener noreferrer" target="_blank"&gt;SMS subscriber&amp;quot; library&lt;/a&gt;&amp;nbsp;which you could use to accomplish this.&lt;br /&gt;if you instead want to use regular AT commands, you make sockets &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfxlib/bsdlib/doc/at_commands.html" rel="noopener noreferrer" target="_blank"&gt;the following way.&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>