问:
Sonarqube failed to create user cache
I'm creating a Sonarqube environment with Docker, but when I run the scanner, an error occurred.

I run the scanner directly into the container :

```<code>PS C:\docker\sonarqube\projects\test> docker exec -it sonarqube /bin/bash
</code>```

```<code>sonarqube@05399e4fa8a6:/home/projects/test$ sonar-scanner
</code>```

INFO: Scanner configuration file: /usr/lib/sonar-scanner/conf/sonar-scanner.properties

  INFO: Project root configuration file: /home/projects/test/sonar-project.properties

  INFO: SonarQube Scanner 4.2.0.1873

  INFO: Java 11.0.3 AdoptOpenJDK (64-bit)

  INFO: Linux 4.9.184-linuxkit amd64

  INFO: ------------------------------------------------------------------------

  INFO: EXECUTION FAILURE

  INFO: ------------------------------------------------------------------------

  INFO: Total time: 0.364s

  INFO: Final Memory: 2M/10M

  INFO: ------------------------------------------------------------------------

  ERROR: Error during SonarQube Scanner execution

  java.lang.IllegalStateException: Unable to create user cache: /home/.sonar/cache

                at org.sonarsource.scanner.api.internal.cache.FileCache.createDir(FileCache.java:147)

                at org.sonarsource.scanner.api.internal.cache.FileCache.(FileCache.java:46)

                at org.sonarsource.scanner.api.internal.cache.FileCache.create(FileCache.java:52)

                at org.sonarsource.scanner.api.internal.cache.FileCacheBuilder.build(FileCacheBuilder.java:48)

                at org.sonarsource.scanner.api.internal.JarDownloaderFactory.create(JarDownloaderFactory.java:42)

                at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:68)

                at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)

                at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)

                at org.sonarsource.scanner.cli.Main.execute(Main.java:73)

                at org.sonarsource.scanner.cli.Main.main(Main.java:61)

  Caused by: java.nio.file.AccessDeniedException: /home/.sonar/cache

                at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)

                at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)

                at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)

                at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(Unknown Source)

                at java.base/java.nio.file.Files.createDirectory(Unknown Source)

                at java.base/java.nio.file.Files.createAndCheckIsDirectory(Unknown Source)

                at java.base/java.nio.file.Files.createDirectories(Unknown Source)

                at org.sonarsource.scanner.api.internal.cache.FileCache.createDir(FileCache.java:145)

          ... 9 more

Here is the dockerfile I use in a docker-compose :

```<code>FROM sonarqube:latest

# Switch to root user to be able to install packages.
USER root

# Install packages.
RUN apt-get update
RUN apt-get install -y vim wget

# Install sonarqube scanner.
WORKDIR /usr/src

RUN wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip

RUN unzip sonar-scanner-cli-4.2.0.1873-linux.zip
RUN rm sonar-scanner-cli-4.2.0.1873-linux.zip
RUN mv sonar-scanner-4.2.0.1873-linux /usr/lib/sonar-scanner

# Create symbolic link.
RUN ln -s /usr/lib/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner
ENV SONAR_RUNNER_HOME=/usr/lib/sonar-scanner

ENV SONAR_USER_HOME=/home/.sonar

# Switch back to the sonarqube environment.
WORKDIR $SONARQUBE_HOME
USER sonarqube
</code>```

The docker-compose :

```<code>version: '3.7'

services:
    sonarqube:
        build: .
        container_name: sonarqube
        ports:
            - 9000:9000
        networks:
            - sonarnet
        environment:
            - sonar.jdbc.url=jdbc:postgresql://db:5432/sonar
        volumes:
            - ./projects:/home/projects
            - sonarqube_conf:/opt/sonarqube/conf
            - sonarqube_data:/opt/sonarqube/data
            - sonarqube_logs:/opt/sonarqube/logs
            - sonarqube_extensions:/opt/sonarqube/extensions

    db:
        image: postgres:latest
        container_name: sonarqube_database
        networks:
            - sonarnet
        environment:
            - POSTGRES_USER=sonar
            - POSTGRES_PASSWORD=sonar
        volumes:
            - postgresql:/var/lib/postgresql
            - postgresql_data:/var/lib/postgresql/data

networks:
    sonarnet:
        driver: bridge

volumes:
    projects:
    sonarqube_conf:
    sonarqube_data:
    sonarqube_logs:
    sonarqube_extensions:
    postgresql:
    postgresql_data:

</code>```

I understand that's an access problem, but I don't understand why.

Any ideas why is that happen ?

答:
Solved my problem. In dockerfile :  </p>

```<code>RUN mkdir /home/.sonar
RUN chmod 777 /home/.sonar
ENV SONAR_USER_HOME=/home/.sonar
</code>```

Title: Sonarqube failed to create user cache

Body:
I'm creating a Sonarqube environment with Docker, but when I run the scanner, an error occurred.

I run the scanner directly into the container :

PS C:\docker\sonarqube\projects\test> docker exec -it sonarqube /bin/bash

sonarqube@05399e4fa8a6:/home/projects/test$ sonar-scanner

INFO: Scanner configuration file: /usr/lib/sonar-scanner/conf/sonar-scanner.properties

  INFO: Project root configuration file: /home/projects/test/sonar-project.properties

  INFO: SonarQube Scanner 4.2.0.1873

  INFO: Java 11.0.3 AdoptOpenJDK (64-bit)

  INFO: Linux 4.9.184-linuxkit amd64

  INFO: ------------------------------------------------------------------------

  INFO: EXECUTION FAILURE

  INFO: ------------------------------------------------------------------------

  INFO: Total time: 0.364s

  INFO: Final Memory: 2M/10M

  INFO: ------------------------------------------------------------------------

  ERROR: Error during SonarQube Scanner execution

  java.lang.IllegalStateException: Unable to create user cache: /home/.sonar/cache

                at org.sonarsource.scanner.api.internal.cache.FileCache.createDir(FileCache.java:147)

                at org.sonarsource.scanner.api.internal.cache.FileCache.(FileCache.java:46)

                at org.sonarsource.scanner.api.internal.cache.FileCache.create(FileCache.java:52)

                at org.sonarsource.scanner.api.internal.cache.FileCacheBuilder.build(FileCacheBuilder.java:48)

                at org.sonarsource.scanner.api.internal.JarDownloaderFactory.create(JarDownloaderFactory.java:42)

                at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:68)

                at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)

                at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)

                at org.sonarsource.scanner.cli.Main.execute(Main.java:73)

                at org.sonarsource.scanner.cli.Main.main(Main.java:61)

  Caused by: java.nio.file.AccessDeniedException: /home/.sonar/cache

                at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)

                at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)

                at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)

                at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(Unknown Source)

                at java.base/java.nio.file.Files.createDirectory(Unknown Source)

                at java.base/java.nio.file.Files.createAndCheckIsDirectory(Unknown Source)

                at java.base/java.nio.file.Files.createDirectories(Unknown Source)

                at org.sonarsource.scanner.api.internal.cache.FileCache.createDir(FileCache.java:145)

          ... 9 more

Here is the dockerfile I use in a docker-compose :

FROM sonarqube:latest

# Switch to root user to be able to install packages.
USER root

# Install packages.
RUN apt-get update
RUN apt-get install -y vim wget

# Install sonarqube scanner.
WORKDIR /usr/src

RUN wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip

RUN unzip sonar-scanner-cli-4.2.0.1873-linux.zip
RUN rm sonar-scanner-cli-4.2.0.1873-linux.zip
RUN mv sonar-scanner-4.2.0.1873-linux /usr/lib/sonar-scanner

# Create symbolic link.
RUN ln -s /usr/lib/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner
ENV SONAR_RUNNER_HOME=/usr/lib/sonar-scanner

ENV SONAR_USER_HOME=/home/.sonar

# Switch back to the sonarqube environment.
WORKDIR $SONARQUBE_HOME
USER sonarqube

The docker-compose :

version: '3.7'

services:
    sonarqube:
        build: .
        container_name: sonarqube
        ports:
            - 9000:9000
        networks:
            - sonarnet
        environment:
            - sonar.jdbc.url=jdbc:postgresql://db:5432/sonar
        volumes:
            - ./projects:/home/projects
            - sonarqube_conf:/opt/sonarqube/conf
            - sonarqube_data:/opt/sonarqube/data
            - sonarqube_logs:/opt/sonarqube/logs
            - sonarqube_extensions:/opt/sonarqube/extensions

    db:
        image: postgres:latest
        container_name: sonarqube_database
        networks:
            - sonarnet
        environment:
            - POSTGRES_USER=sonar
            - POSTGRES_PASSWORD=sonar
        volumes:
            - postgresql:/var/lib/postgresql
            - postgresql_data:/var/lib/postgresql/data

networks:
    sonarnet:
        driver: bridge

volumes:
    projects:
    sonarqube_conf:
    sonarqube_data:
    sonarqube_logs:
    sonarqube_extensions:
    postgresql:
    postgresql_data:

I understand that's an access problem, but I don't understand why.

Any ideas why is that happen ?

Body:
Solved my problem. In dockerfile :

RUN mkdir /home/.sonar
RUN chmod 777 /home/.sonar
ENV SONAR_USER_HOME=/home/.sonar


来源: stackexchange

问:
SQL adding new column
I would be happy to ask my first question on StackOverflow.

I have two tables (employees and salaries) within my database (employees).

Employees table looks like this:

```<code>+------------+---------------+------+-----+---------+-------+
| Field      | Type          | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| emp_no     | int           | NO   | PRI | NULL    |       |
| first_name | varchar(14)   | NO   |     | NULL    |       |
| last_name  | varchar(16)   | NO   |     | NULL    |       |
+------------+---------------+------+-----+---------+-------+
</code>```

Salaries table looks like this:

```<code>+-----------+------+------+-----+---------+-------+
| Field     | Type | Null | Key | Default | Extra |
+-----------+------+------+-----+---------+-------+
| emp_no    | int  | NO   | PRI | NULL    |       |
| salary    | int  | NO   |     | NULL    |       |
| from_date | date | NO   | PRI | NULL    |       |
| to_date   | date | NO   |     | NULL    |       |
+-----------+------+------+-----+---------+-------+
</code>```

I want to return values for a specific date interval. For instance, I want to know what salary an employee had for an interval in a dynamic view, for the 1990-1991 years for 1991-1992 years, etc.

I wrote the following query:

```<code>SELECT
    e.emp_no,
    e.first_name,
    e.last_name,
    s.salary AS Salary_for_1990
FROM
    employees e
        JOIN
    salaries s ON e.emp_no = s.emp_no
WHERE
    from_date BETWEEN '1990-01-01' AND '1990-12-31'
GROUP BY e.emp_no
ORDER BY e.emp_no ASC
LIMIT 10;
</code>```

I got the following result:

```<code>+--------+------------+-----------+-----------------+
| emp_no | first_name | last_name | Salary_for_1990 |
+--------+------------+-----------+-----------------+
|  10001 | Georgi     | Facello   |           66961 |
|  10004 | Christian  | Koblick   |           48271 |
|  10005 | Kyoichi    | Maliniak  |           82621 |
|  10006 | Anneke     | Preusig   |           40000 |
|  10007 | Tzvetan    | Zielinski |           60740 |
|  10009 | Sumant     | Peace     |           70889 |
|  10011 | Mary       | Sluis     |           42365 |
|  10013 | Eberhardt  | Terkki    |           46305 |
|  10018 | Kazuhide   | Peha      |           61648 |
|  10021 | Ramzi      | Erde      |           59700 |
+--------+------------+-----------+-----------------+
</code>```

So it works for a single value '1990-1991' years, however, I seek for a possibility to add in the query additional column for '1991-1992', '1992-1993' years, etc to be able to see the dynamic growth of employee's salaries.

I thought about variables, however, I don't have an idea how to query it within the context.

Look forward to your answers.
 Thank you in advance.

答:
One simple possibility are subqueries, although it's not very elegant and does not scale well with many years:</p>

```<code>SELECT
e.emp_no,
e.first_name,
e.last_name,
(SELECT s.salary FROM salaries s WHERE s.emp_no = e.emp_no AND from_date BETWEEN '1990-01-01' AND '1990-12-31') Salary_for_1990,
(SELECT s.salary FROM salaries s WHERE s.emp_no = e.emp_no AND from_date BETWEEN '1991-01-01' AND '1991-12-31') Salary_for_1991
...
</code>```

ContentLicense: CC BY-SA 4.0

Title: SQL adding new column

Body:
I would be happy to ask my first question on StackOverflow.

I have two tables (employees and salaries) within my database (employees).

Employees table looks like this:

+------------+---------------+------+-----+---------+-------+
| Field      | Type          | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| emp_no     | int           | NO   | PRI | NULL    |       |
| first_name | varchar(14)   | NO   |     | NULL    |       |
| last_name  | varchar(16)   | NO   |     | NULL    |       |
+------------+---------------+------+-----+---------+-------+

Salaries table looks like this:

+-----------+------+------+-----+---------+-------+
| Field     | Type | Null | Key | Default | Extra |
+-----------+------+------+-----+---------+-------+
| emp_no    | int  | NO   | PRI | NULL    |       |
| salary    | int  | NO   |     | NULL    |       |
| from_date | date | NO   | PRI | NULL    |       |
| to_date   | date | NO   |     | NULL    |       |
+-----------+------+------+-----+---------+-------+

I want to return values for a specific date interval. For instance, I want to know what salary an employee had for an interval in a dynamic view, for the 1990-1991 years for 1991-1992 years, etc.

I wrote the following query:

SELECT
    e.emp_no,
    e.first_name,
    e.last_name,
    s.salary AS Salary_for_1990
FROM
    employees e
        JOIN
    salaries s ON e.emp_no = s.emp_no
WHERE
    from_date BETWEEN '1990-01-01' AND '1990-12-31'
GROUP BY e.emp_no
ORDER BY e.emp_no ASC
LIMIT 10;

I got the following result:

+--------+------------+-----------+-----------------+
| emp_no | first_name | last_name | Salary_for_1990 |
+--------+------------+-----------+-----------------+
|  10001 | Georgi     | Facello   |           66961 |
|  10004 | Christian  | Koblick   |           48271 |
|  10005 | Kyoichi    | Maliniak  |           82621 |
|  10006 | Anneke     | Preusig   |           40000 |
|  10007 | Tzvetan    | Zielinski |           60740 |
|  10009 | Sumant     | Peace     |           70889 |
|  10011 | Mary       | Sluis     |           42365 |
|  10013 | Eberhardt  | Terkki    |           46305 |
|  10018 | Kazuhide   | Peha      |           61648 |
|  10021 | Ramzi      | Erde      |           59700 |
+--------+------------+-----------+-----------------+

So it works for a single value '1990-1991' years, however, I seek for a possibility to add in the query additional column for '1991-1992', '1992-1993' years, etc to be able to see the dynamic growth of employee's salaries.

I thought about variables, however, I don't have an idea how to query it within the context.

Look forward to your answers.
 Thank you in advance.

Body:
One simple possibility are subqueries, although it's not very elegant and does not scale well with many years:

SELECT
e.emp_no,
e.first_name,
e.last_name,
(SELECT s.salary FROM salaries s WHERE s.emp_no = e.emp_no AND from_date BETWEEN '1990-01-01' AND '1990-12-31') Salary_for_1990,
(SELECT s.salary FROM salaries s WHERE s.emp_no = e.emp_no AND from_date BETWEEN '1991-01-01' AND '1991-12-31') Salary_for_1991
...


问:
AWS EMR JupyterHub access issue on MacOS Catalina due to Temporary SSL Certificate recognized as "Invalid"
After upgrading to MacOS Catalina, I am no longer able to access AWS EMR JupyterHub as the new OS blocks temporary SSL certificates. Found a relevant post on Github but no resolution. Any suggestions?

https://github.com/jetstack/cert-manager/issues/2168

Describe the bug:
Temporary Certificates issued when a valid certificate issuance all seem to have the same serial numbers, which in MacOS Catalina causes both Firefox and Chrome to block even allowing access to the sites.

Chrome gives a standard ERR_CERT_INVALID error, and firefox gives a SEC_ERROR_REUSED_ISSUER_AND_SERIAL error

答:
For everyone having this issue on Mac OS Catalina, you should add the Self-Signed certificate or the revoked certificate to the keychain and then trust it from there. This affects only Chrome. On FireFox and Safari you should not have this issue. </p>

<p>Following tutorial make it easier to understand. https://css-tricks.com/getting-around-revoked-certificate-osx/ </p>

Body:
For everyone having this issue on Mac OS Catalina, you should add the Self-Signed certificate or the revoked certificate to the keychain and then trust it from there. This affects only Chrome. On FireFox and Safari you should not have this issue.

Following tutorial make it easier to understand. https://css-tricks.com/getting-around-revoked-certificate-osx/


问:
What determines if a scrollbar has color in Firefox?
TLDR; I've encountered interesting behaviour in Firefox. For example, it automatically styles the scrollbar limegreen, but not lightgreen. Why does it render one, but not the other?

While answering another question I found that this renders a limegreen colored scroll bar in Firefox 72 latest on Windows 10:

div {
  background-color: limegreen;
  max-height: 5em;
  overflow-y: scroll;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br></div></code>```

Like this:

But that Firefox refuses to render a lightgreen colored scroll bar:

div {
  background-color: lightgreen;
  max-height: 5em;
  overflow-y: scroll;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br>Hi!<br></div></code>```

See this:

What causes this behavior, and how can I predict it?

PS. Chrome 80 shows both scrollbars in the default style.

PS. There are questions on how to actively change scrollbar color in Firefox, but I'm not (right now) interested in pragmatic advice on "how to change scrollbar color", but instead I'm asking and trying to understand when and why it happens automatically, and only for some background colors.

答:
div {
  background-color: lightgreen;
  max-height: 5em;
  overflow-y: scroll;
  scrollbar-color: lightgreen lightgreen;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div></code>```

Using scrollbar-color works (more info here). I think color detection is just really buggy - sometimes one color works with scrollbar-color and applies to both parts of the scrollbar and sometimes you need to repeat it twice. I just think it's a poorly implemented part of the HTML spec. Doesn't have great browser support though so make sure it's not required as part of your interface.

Body:
TLDR; I've encountered interesting behaviour in Firefox. For example, it automatically styles the scrollbar limegreen, but not lightgreen. Why does it render one, but not the other?

While answering another question I found that this renders a limegreen colored scroll bar in Firefox 72 latest on Windows 10:

div {
  background-color: limegreen;
  max-height: 5em;
  overflow-y: scroll;
}

Hi!
Hi!
Hi!
Hi!
Hi!
Hi!
Hi!
Hi!
Hi!
Hi!

Like this:

But that Firefox refuses to render a lightgreen colored scroll bar:

div {
  background-color: lightgreen;
  max-height: 5em;
  overflow-y: scroll;
}

Hi!
Hi!
Hi!
Hi!
Hi!
Hi!
Hi!
Hi!
Hi!
Hi!

See this:

What causes this behavior, and how can I predict it?

PS. Chrome 80 shows both scrollbars in the default style.

PS. There are questions on how to actively change scrollbar color in Firefox, but I'm not (right now) interested in pragmatic advice on "how to change scrollbar color", but instead I'm asking and trying to understand when and why it happens automatically, and only for some background colors.

Body:
div {
  background-color: lightgreen;
  max-height: 5em;
  overflow-y: scroll;
  scrollbar-color: lightgreen lightgreen;
}

<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>

Using scrollbar-color works (more info here). I think color detection is just really buggy - sometimes one color works with scrollbar-color and applies to both parts of the scrollbar and sometimes you need to repeat it twice. I just think it's a poorly implemented part of the HTML spec. Doesn't have great browser support though so make sure it's not required as part of your interface.


问:
React Router : Dynamically url id

How can I implement dynamic paths when I click on a link like in a picture?

The user clicks on the link and goes to the message section, then clicks on the link (Link) and goes to the desired component.

DATA:

```<code>const data = [
    {
        link: 'Link Name 1',
        text: 'Text 1',
        id: '1'
    },
    {
        link: 'Link Name 2',
        text: 'Text 2',
        id: '2'
    },
    {
        link: 'Link Name 3',
        text: 'Text 3',
        id: '3'
    }
    ];
</code>```

App.js

```<code><Switch>
 <Route exact path="/" component={AppHome}/>
 <Route exact path="/messages" component={AppMessages}/>
 <Route exact path="/messages/chat" component={AppMessageItems}/>
 <Route exact path="/messages/chat/:id" component={AppMessageItems}/>
</Switch>
</code>```

Messages.js

```<code>const AppMessages = () => {
             <ul>
                {data.map(function(item, index) {
                    return (
                        <li key={index}>
                            <Link to='/messages/chat'><AppMessageUserList {...item} /></Link>
                        </li>);
                })}
            </ul>
}
</code>```

AppMessageUserList

```<code>const AppMessageUserList = ( props ) => {
const {link} = props;
   return ( <div> {link} </div> );

}
</code>```

AppMessageItems.js

```<code>const AppMessageItems = () => {
   return ( <h1> Hello World </h1> );

}
</code>```

But when i try this code i get error when click to link.

答:
Replace your code with

// App.js
<Switch>
 <Route exact path="/" component={AppHome}/>
 <Route exact path="/messages" component={AppMessages}/>
 <Route path={["/messages/chat", "/messages/chat/:id"]} component={AppMessageItems}/>
</Switch>

// Messages.js
// Assuming item has id and upon clicking the item should change the url

const AppMessages = () => (

    {data.map((item, index) =>
      (

          <Link to={`/messages/chat/${item.id}`}>
             <AppMessageUserList {...item} />
           </Link>

       )
     }

)

// AppMessageItems

const AppMessageItems = (props) => {
if (props.match.params && props.match.params.id) {
   // return the selected items
 }
// return whatever you wanted to return if nothing is selected
}

```

NOTE: Don't use index as key

Title: React Router : Dynamically url id

Body:
How can I implement dynamic paths when I click on a link like in a picture?

The user clicks on the link and goes to the message section, then clicks on the link (Link) and goes to the desired component.

DATA:

const data = [
    {
        link: 'Link Name 1',
        text: 'Text 1',
        id: '1'
    },
    {
        link: 'Link Name 2',
        text: 'Text 2',
        id: '2'
    },
    {
        link: 'Link Name 3',
        text: 'Text 3',
        id: '3'
    }
    ];

App.js

<Switch>
 <Route exact path="/" component={AppHome}/>
 <Route exact path="/messages" component={AppMessages}/>
 <Route exact path="/messages/chat" component={AppMessageItems}/>
 <Route exact path="/messages/chat/:id" component={AppMessageItems}/>
</Switch>

Messages.js

const AppMessages = () => {

                {data.map(function(item, index) {
                    return (

                            <Link to='/messages/chat'><AppMessageUserList {...item} /></Link>

);
                })}

}

AppMessageUserList

const AppMessageUserList = ( props ) => {
const {link} = props;
   return (
 {link}
 );

}

AppMessageItems.js

const AppMessageItems = () => {
   return (
 Hello World
 );

}

But when i try this code i get error when click to link.

Body:
Replace your code with

// App.js
<Switch>
 <Route exact path="/" component={AppHome}/>
 <Route exact path="/messages" component={AppMessages}/>
 <Route path={["/messages/chat", "/messages/chat/:id"]} component={AppMessageItems}/>
</Switch>

// Messages.js
// Assuming item has id and upon clicking the item should change the url

const AppMessages = () => (
  <ul>
    {data.map((item, index) =>
      (
        <li key={item.id}>
          <Link to={`/messages/chat/${item.id}`}>
             <AppMessageUserList {...item} />
           </Link>
         </li>
       )
     }
    </ul>
)

// AppMessageItems

const AppMessageItems = (props) => {
if (props.match.params && props.match.params.id) {
   // return the selected items
 }
// return whatever you wanted to return if nothing is selected
}

NOTE: Don't use index as key


问:
Continuous Speechrecognition in Android
I googled around and found the regular speech-api from google. But I think this isn't what I need. I need continious voice recognition and the ability to launch other actions when a specific word is spoken. Is there anything in the android sdk that I can use?

If not: Is it possible to implement third-party libraries? (If yes: which - and what do I have to think about when implement a third-party-library?)

Edit: I thought about this again. I have to recognize just one 'word' (that probably won't be in googles-speech-databases). I have the chance to record it. That means, I'm able to continiously match the incoming audio-stream against my recording. That should work without a database. But I'm new to android-development. Do you have suggestions for APIs to use for recording and matching the recorded? Or is there any better way to continiously wait for a specifig 'word' to occur and then process any further actions?

btw: if that wasn't clear described: the app should continue to record and watch for the word to occure again when the reaction is done.

答:
Is there anything in the android sdk that I can use?

No, sorry.

ContentLicense: CC BY-SA 3.0

Title: Continuous Speechrecognition in Android


问:
Select parent selector in SASS/SCSS
I have a small missunderstanding in SCSS syntax. Creating small component using BEM methodology and got a problem in SCSS.
HTML:

```<code><div class="message message--success">
        <div class="message__title">
          BEM Example
        </div>
        <div class="message__content">
          <p>BEM Example text</p>
        </div>
      </div>
</code>```

SCSS:

```<code>.message {
  display: block;
  width: 300px;
  border-radius: 5px;
  border: 2px solid #000;
  padding: 10px;

  &__title {
    font-size: 18px;
    line-height: 1;
    color: #000;
    margin-bottom: 10px;
  }

  &__content {
    font-size: 15px;
    color: #000;
  }

  &--success {
    border-color: #3f9442;

    &__title {
      color: #3f9442;
    }

    &__content {
      color: #3f9442;
    }
  }
}
</code>```

As you can see, I have .message--success class and inside &--success the direct styles(border-color) works, but stylyng for title and content not. How to select .message* as parent for **&__title and &__content inside &--success

答:
Either you write both the selectors with the full classname (without using &) or you could save a reference to the .message class and use it in the nested selector

```<code>.message {

  display: block;
  width: 300px;
  border-radius: 5px;
  border: 2px solid #000;
  padding: 10px;

  $this: &; /* reference to the .message class */

  &__title {
    font-size: 18px;
    line-height: 1;
    color: #000;
    margin-bottom: 10px;
  }

  &__content {
    font-size: 15px;
    color: #000;
  }

  &--success {
    border-color: #3f9442;

    /* use the reference stored */

    #{$this}__title {
      color: #3f9442;
    }

    #{$this}__content {
      color: #3f9442;
    }
  }
}
</code>```

Title: Select parent selector in SASS/SCSS

Body:
I have a small missunderstanding in SCSS syntax. Creating small component using BEM methodology and got a problem in SCSS.
HTML:

          BEM Example

BEM Example text

SCSS:

.message {
  display: block;
  width: 300px;
  border-radius: 5px;
  border: 2px solid #000;
  padding: 10px;

  &__title {
    font-size: 18px;
    line-height: 1;
    color: #000;
    margin-bottom: 10px;
  }

  &__content {
    font-size: 15px;
    color: #000;
  }

  &--success {
    border-color: #3f9442;

    &__title {
      color: #3f9442;
    }

    &__content {
      color: #3f9442;
    }
  }
}

As you can see, I have .message--success class and inside &--success the direct styles(border-color) works, but stylyng for title and content not. How to select .message* as parent for **&__title and &__content inside &--success

Body:
Either you write both the selectors with the full classname (without using &) or you could save a reference to the .message class and use it in the nested selector

.message {

  display: block;
  width: 300px;
  border-radius: 5px;
  border: 2px solid #000;
  padding: 10px;

  $this: &; /* reference to the .message class */

  &__title {
    font-size: 18px;
    line-height: 1;
    color: #000;
    margin-bottom: 10px;
  }

  &__content {
    font-size: 15px;
    color: #000;
  }

  &--success {
    border-color: #3f9442;

    /* use the reference stored */

    #{$this}__title {
      color: #3f9442;
    }

    #{$this}__content {
      color: #3f9442;
    }
  }
}


问:
CKEditor 4 and ASP.NET core MVC : How to change image url in ckeditor
I'm using CKEditor 4 for blog post. I'm uploading image and returning the image url. Whenever i click SOURCE on my ckeditor, i see "https://localhost:5001/88e4174d-8d8f-b041-8af0-9503a0ec7dfd" width="1776" />" how do i change the source to the image url returned ?

答:
Whenever i click SOURCE on my ckeditor, i see "https://localhost:5001/88e4174d-8d8f-b041-8af0-9503a0ec7dfd" width="1776" />" how do i change the source to the image url returned ?

I did a test with following code sample, which work well on my side, you can refer to it.

In view page

```<code><textarea name="blog_input"></textarea>

@section scripts{

    <script src="https://cdn.ckeditor.com/4.10.1/standard/ckeditor.js"></script>
    <script>
        CKEDITOR.replace('blog_input', {
            filebrowserImageUploadUrl: '/Home/UploadImage'
        });
    </script>
}
</code>```

Note: set filebrowserImageUploadUrl property with custom ImageUpload Url for CKEditor

UploadImage action

```<code>[HttpPost]
public async Task<ActionResult> UploadImage(IFormFile upload)
{
    if (upload.Length <= 0) return null;

    //your custom code logic here

    //1)check if the file is image

    //2)check if the file is too large

    //etc

    var fileName = Guid.NewGuid() + Path.GetExtension(upload.FileName).ToLower();

    //save file under wwwroot/CKEditorImages folder

    var filePath = Path.Combine(
        Directory.GetCurrentDirectory(), "wwwroot/CKEditorImages",
        fileName);

    using (var stream = System.IO.File.Create(filePath))
    {
        await upload.CopyToAsync(stream);
    }

    var url = $"{"/CKEditorImages/"}{fileName}";

    var successMessage = "image is uploaded";

    dynamic success = Newtonsoft.Json.JsonConvert.DeserializeObject("{ 'uploaded': 1,'fileName': \"" + fileName + "\",'url': \"" + url + "\", 'error': { 'message': \"" + successMessage + "\"}}");
    return Json(success);
}
</code>```

Test Result

1) select and upload local file

2) source of image in CKEditor

Body:
Whenever i click SOURCE on my ckeditor, i see "https://localhost:5001/88e4174d-8d8f-b041-8af0-9503a0ec7dfd" width="1776" />" how do i change the source to the image url returned ?

I did a test with following code sample, which work well on my side, you can refer to it.

In view page

<textarea name="blog_input"></textarea>

@section scripts{

    <script src="https://cdn.ckeditor.com/4.10.1/standard/ckeditor.js"></script>
    <script>
        CKEDITOR.replace('blog_input', {
            filebrowserImageUploadUrl: '/Home/UploadImage'
        });
    </script>
}

Note: set filebrowserImageUploadUrl property with custom ImageUpload Url for CKEditor

UploadImage action

[HttpPost]
public async Task<ActionResult> UploadImage(IFormFile upload)
{
    if (upload.Length <= 0) return null;

    //your custom code logic here

    //1)check if the file is image

    //2)check if the file is too large

    //etc

    var fileName = Guid.NewGuid() + Path.GetExtension(upload.FileName).ToLower();

    //save file under wwwroot/CKEditorImages folder

    var filePath = Path.Combine(
        Directory.GetCurrentDirectory(), "wwwroot/CKEditorImages",
        fileName);

    using (var stream = System.IO.File.Create(filePath))
    {
        await upload.CopyToAsync(stream);
    }

    var url = $"{"/CKEditorImages/"}{fileName}";

    var successMessage = "image is uploaded";

    dynamic success = Newtonsoft.Json.JsonConvert.DeserializeObject("{ 'uploaded': 1,'fileName': \"" + fileName + "\",'url': \"" + url + "\", 'error': { 'message': \"" + successMessage + "\"}}");
    return Json(success);
}

Test Result

1) select and upload local file

2) source of image in CKEditor


问:
Python JSON file to sorted pandas dataframe
I have a JSON file in the following format:

```<code>[
  {
    "positionmessage": {
      "name": "ship-1",
      "sog": 0,
      "latitude": 51.82284,
      "eni": "02010000",
      "mmsi": "100000"
    }
  },
  {
    "positionmessage": {
      "name": "ship-2",
      "sog": 0,
      "latitude": 51.81966,
      "eni": "02020000",
      "mmsi": "200000"
    }
  },
  {
    "positionmessage": {
      "name": "ship-2",
      "sog": 0,
      "latitude": 51.8196,
      "eni": "02020000",
      "mmsi": "200000"
    }
  },
  {
    "positionmessage": {
      "name": "ship-3",
      "sog": 0,
      "latitude": 51.8225,
      "eni": "02030000",
      "mmsi": "300000"
    }
  },
  {
    "positionmessage": {
      "name": "ship-4",
      "sog": 0,
      "latitude": 51.8291,
      "eni": "02040000",
      "mmsi": "400000"
    }
  }
]
</code>```

I would like to get a pandas dataframe with the variables on the columns:

column 1: name

column 2: SOG

column 3: latitude, etc.

On the rows should be the content of  all columns. How do I do this?

Body:
I have a JSON file in the following format:

[
  {
    "positionmessage": {
      "name": "ship-1",
      "sog": 0,
      "latitude": 51.82284,
      "eni": "02010000",
      "mmsi": "100000"
    }
  },
  {
    "positionmessage": {
      "name": "ship-2",
      "sog": 0,
      "latitude": 51.81966,
      "eni": "02020000",
      "mmsi": "200000"
    }
  },
  {
    "positionmessage": {
      "name": "ship-2",
      "sog": 0,
      "latitude": 51.8196,
      "eni": "02020000",
      "mmsi": "200000"
    }
  },
  {
    "positionmessage": {
      "name": "ship-3",
      "sog": 0,
      "latitude": 51.8225,
      "eni": "02030000",
      "mmsi": "300000"
    }
  },
  {
    "positionmessage": {
      "name": "ship-4",
      "sog": 0,
      "latitude": 51.8291,
      "eni": "02040000",
      "mmsi": "400000"
    }
  }
]

I would like to get a pandas dataframe with the variables on the columns:

column 1: name

column 2: SOG

column 3: latitude, etc.

On the rows should be the content of  all columns. How do I do this?

Body:
Use read_json with lines parameter, convert to list and then to DataFrame:

L = pd.read_json('file.json', lines=True)['positionmessage'].tolist()
df = pd.DataFrame(L)
print (df)
       name   sog  latitude       eni    mmsi
0    ship-1   0.0  51.82284  02010000  100000
1    ship-2   0.0  51.81966  02020000  200000
2    ship-2   0.0  51.81960  02020000  200000
3    ship-3   0.0  51.82250  02030000  300000
4    ship-4   0.0  51.82910  02040000  400000
5    ship-5   8.0  51.82384  02050000  500000
6    ship-6   0.0  51.82470  02060000  600000
7    ship-7   0.0  51.81920  02070000  700000
8    ship-6   0.0  51.82470  02060000  600000
9    ship-8   9.0  51.82870  02080000  800000
10   ship-9   0.0  51.82710  02090000  900000
11  ship-10   9.0  51.82620  02010000  100000
12  ship-11   0.0  51.81930  02011000  110000
13  ship-12  10.0  51.82390  02012000  120000


问:
iOS web apps and in-app php linking
I'm trying to build a web app to handle guest lists for an event. It's basicly a long list of names, but then I want to be able to click a name and get some info in a sidebar.

My normal aproach is to do some ?id=25 for example, and just load the appropriate info based on that.

But when making such links for the guests, I get kicked out of the app and Safari opens up the link. Do I have to use Ajax, or is there some way to make links work within the app, since it's just an index.php file.

答:
I'm not an ios app coder, but if you're writing an app, why use urls?
Why no listen to the events and pull the ID from the clicked user and send the request with the app and then display the content in the sidebar. Sorta like ajax in webapps. </p>

Title: iOS web apps and in-app php linking


问:
Leaflet timer. Highlighting a different town (polygon) every secs
I have a map with 4 towns using Leaflet. Mouseover and Mouseout work fine but I would like to have a timer that automatically focus on each town in rotation every 5 or 10 secs. I was trying to find in the documentation a way to find all polygons on the map and then loop indefinitely into these but I can't access them individually to apply functions to highlight and reset styles.</p>

```<code>$.getJSON('./data/mymap.json', function (geojson) {
var geojsonLayer = new L.GeoJSON(geojson, {
    style: function () {
        return {
            color: 'blue'
        }
    },
    onEachFeature: function (feature, layer) {
        layer.on('mouseover', function () {
            this.setStyle({
                color: 'green'
            });
            document.getElementById("mapdetails").innerText = layer.feature.properties.name;
        });
        layer.on('mouseout', function () {
            geojsonLayer.resetStyle(this);
            document.getElementById("mapdetails").innerText = '';
        });
        layer.on('click', function () {
            mymap.fitBounds(arrayBounds);
        });
    }
}).addTo(mymap);

});

function highlightLayer(layerID) {
    mymap._layers['name'+layerID].setStyle(highlight); }

var highlight = {
    'color': '#333333',
    'weight': 2,
    'opacity': 1 };

$(document).ready(function() {

    var layerGroup = L.LayerGroup([polygon]);

    for (var i in this._layers) {
        if (this._layers[i].options.name == 'Mytown') {
            console.log('found');
        }
    }
</code>```

答:
You have to call eachLayer() or getLayers() from the geojsonLayer.</p>

```<code>
var i = 0;
function highlightLayer(){
   setTimeout(function(){
      geojsonLayer.resetStyle(); //To clear style of all layers
      var layers =  geojsonLayer.getLayers();
      if(layers.length >= i){
         i = 0;
      }
      layers[i].setStyle(highlight);
      i++;
      highlightLayer(); //Restart Timer
   },1000);
}
</code>```

Body:
I have a map with 4 towns using Leaflet. Mouseover and Mouseout work fine but I would like to have a timer that automatically focus on each town in rotation every 5 or 10 secs. I was trying to find in the documentation a way to find all polygons on the map and then loop indefinitely into these but I can't access them individually to apply functions to highlight and reset styles.

$.getJSON('./data/mymap.json', function (geojson) {
var geojsonLayer = new L.GeoJSON(geojson, {
    style: function () {
        return {
            color: 'blue'
        }
    },
    onEachFeature: function (feature, layer) {
        layer.on('mouseover', function () {
            this.setStyle({
                color: 'green'
            });
            document.getElementById("mapdetails").innerText = layer.feature.properties.name;
        });
        layer.on('mouseout', function () {
            geojsonLayer.resetStyle(this);
            document.getElementById("mapdetails").innerText = '';
        });
        layer.on('click', function () {
            mymap.fitBounds(arrayBounds);
        });
    }
}).addTo(mymap);

});

function highlightLayer(layerID) {
    mymap._layers['name'+layerID].setStyle(highlight); }

var highlight = {
    'color': '#333333',
    'weight': 2,
    'opacity': 1 };

$(document).ready(function() {

    var layerGroup = L.LayerGroup([polygon]);

    for (var i in this._layers) {
        if (this._layers[i].options.name == 'Mytown') {
            console.log('found');
        }
    }

Body:
You have to call eachLayer() or getLayers() from the geojsonLayer.

var i = 0;
function highlightLayer(){
   setTimeout(function(){
      geojsonLayer.resetStyle(); //To clear style of all layers
      var layers =  geojsonLayer.getLayers();
      if(layers.length >= i){
         i = 0;
      }
      layers[i].setStyle(highlight);
      i++;
      highlightLayer(); //Restart Timer
   },1000);
}


问:
How to get the max number and key
I have has like this

var hash = {};
hash['a'] = ["a", "b", "c", "d", "e"];
hash['b'] = ["a", "b", "c"];
hash['k'] = ["q", "b"];

Math.max(Object.keys(hash)
    .map(function(key) {
      return hash[key].length;
    })
  )```

It returns 5 but, I want to get the hash key 'a' at the same time.

Is it possible??

答:
Does this fulfil your requirement?

I have used sort instead of Math.max here to find the maxima

var hash = {};
hash['a'] = ["a", "b", "c", "d", "e"];
hash['b'] = ["a", "b", "c"];
hash['k'] = ["q", "b"];

var result = Object.keys(hash)
    .map(function(key) {
      return {[key]: hash[key].length};
    }).sort(function(a, b){
      return a.key > b.key
    })[0]

console.log(result);```

Title: How to get the max number and key

Body:
I have has like this

var hash = {};
hash['a'] = ["a", "b", "c", "d", "e"];
hash['b'] = ["a", "b", "c"];
hash['k'] = ["q", "b"];

Math.max(Object.keys(hash)
    .map(function(key) {
      return hash[key].length;
    })
  )

It returns 5 but, I want to get the hash key 'a' at the same time.

Is it possible??


问:
Can't open a new popup window react bootstrap
I am trying to open a new popup window in react.
I copied the code to open a new popup window from here:
https://react-bootstrap.netlify.com/components/modal/

And when I press the button, it is not opening a new window

this is my code:

```<code>import React from 'react';
import './App.css';
import {Modal, Button} from 'react-bootstrap'

function MyVerticallyCenteredModal(props) {
  return (
    <Modal
      {...props}
      size="lg"
      aria-labelledby="contained-modal-title-vcenter"
      centered
    >
      <Modal.Header closeButton>
        <Modal.Title id="contained-modal-title-vcenter">
          Modal heading
        </Modal.Title>
      </Modal.Header>
      <Modal.Body>
        <h4>Centered Modal</h4>
        <p>
          Cras mattis consectetur purus sit amet fermentum. Cras justo odio,
          dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac
          consectetur ac, vestibulum at eros.
        </p>
      </Modal.Body>
      <Modal.Footer>
        <Button onClick={props.onHide}>Close</Button>
      </Modal.Footer>
    </Modal>
  );
}

function App() {
  const [modalShow, setModalShow] = React.useState(false);

  return (
    <>
      <Button variant="primary" onClick={() => setModalShow(true)}>
        Launch vertically centered modal
      </Button>

      <MyVerticallyCenteredModal
        show={modalShow}
        onHide={() => setModalShow(false)}
      />
    </>
  );
}

export default App;
</code>```

I expect the result to be a new window open.
but instead I get this result.

What am I doing wrong?
I am working with the new chrome,
and this is my bootrap version: 1.0.0-beta.16

答:
According to react-bootstrap documentation You need to install bootstrap & import bootstrap.css

```<code>import 'bootstrap/dist/css/bootstrap.min.css';
</code>```

Body:
I am trying to open a new popup window in react.
I copied the code to open a new popup window from here:
https://react-bootstrap.netlify.com/components/modal/

And when I press the button, it is not opening a new window

this is my code:

import React from 'react';
import './App.css';
import {Modal, Button} from 'react-bootstrap'

function MyVerticallyCenteredModal(props) {
  return (
    <Modal
      {...props}
      size="lg"
      aria-labelledby="contained-modal-title-vcenter"
      centered
    >
      <Modal.Header closeButton>
        <Modal.Title id="contained-modal-title-vcenter">
          Modal heading
        </Modal.Title>
      </Modal.Header>
      <Modal.Body>

Centered Modal

          Cras mattis consectetur purus sit amet fermentum. Cras justo odio,
          dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac
          consectetur ac, vestibulum at eros.

      </Modal.Body>
      <Modal.Footer>
        <Button onClick={props.onHide}>Close</Button>
      </Modal.Footer>
    </Modal>
  );
}

function App() {
  const [modalShow, setModalShow] = React.useState(false);

  return (
    <>
      <Button variant="primary" onClick={() => setModalShow(true)}>
        Launch vertically centered modal
      </Button>

      <MyVerticallyCenteredModal
        show={modalShow}
        onHide={() => setModalShow(false)}
      />
    </>
  );
}

export default App;

I expect the result to be a new window open.
but instead I get this result.

What am I doing wrong?
I am working with the new chrome,
and this is my bootrap version: 1.0.0-beta.16

Body:
According to react-bootstrap documentation You need to install bootstrap & import bootstrap.css

import 'bootstrap/dist/css/bootstrap.min.css';


问:
SQL TRUNCATE DATABASE ? How to TRUNCATE ALL TABLES
I use  SQL server 2008 R2.

Is there a SQL command to empty the database, instead of having to truncate all 20 my tables?

I just want to delete the data not the structure.

答:
You can use the sp_MSforeachtable stored procedure like so:

```<code>USE MyDatabase
EXEC sp_MSforeachtable 'TRUNCATE TABLE ?'
</code>```

Be warned that this will delete (by truncation) ALL data from all user tables. And in case you can't TRUNCATE due to foreign keys etc. you can run the same as a delete:

```<code>USE MyDatabase
EXEC sp_MSforeachtable 'DELETE FROM ?'
</code>```

Body:
You can use the sp_MSforeachtable stored procedure like so:

USE MyDatabase
EXEC sp_MSforeachtable 'TRUNCATE TABLE ?'

Be warned that this will delete (by truncation) ALL data from all user tables. And in case you can't TRUNCATE due to foreign keys etc. you can run the same as a delete:

USE MyDatabase
EXEC sp_MSforeachtable 'DELETE FROM ?'


问:
SQL Server substring throws error "multiple results"
I use Microsoft SQL Server 2016.

I have a column that is called Failover and looks like his:

```<code>  $D$Failov:12345:54362:28564
  $D$Failov:12345:
  $D$Failov:86905:45634
</code>```

I want that number so I use :

```<code>select substring(failover, 10, 5)
from dbo.f009
where failover like '$D$Failov:%'
</code>```

It works fine, but if I want a second column called Account, it crashed with multiple results…

```<code>Select
    account,
    (Select substring(failover, 10, 5) AS "1.Result"
     from dbo.f009
     where Failover like '$D$Failov:%')
from
    f009
where
    Failover like '$D$Failov:%'
</code>```

How to fix this ?

Is there a simple way to take the second number and third? I can do it with:

```<code>substring(failover, 16, 5), substring(failover, 22, 5)
</code>```

etc etc but it don't want to repeat myself.

答:
It seems that what you want can be achieved with a simple query:</p>

```<code>Select account, substring(failover,10,5) AS "1.Result"
from dbo.f009
where Failover like '$D$Failov:%'
</code>```

Body:
I use Microsoft SQL Server 2016.

I have a column that is called Failover and looks like his:

  $D$Failov:12345:54362:28564
  $D$Failov:12345:
  $D$Failov:86905:45634

I want that number so I use :

select substring(failover, 10, 5)
from dbo.f009
where failover like '$D$Failov:%'

It works fine, but if I want a second column called Account, it crashed with multiple results…

Select
    account,
    (Select substring(failover, 10, 5) AS "1.Result"
     from dbo.f009
     where Failover like '$D$Failov:%')
from
    f009
where
    Failover like '$D$Failov:%'

How to fix this ?

Is there a simple way to take the second number and third? I can do it with:

substring(failover, 16, 5), substring(failover, 22, 5)

etc etc but it don't want to repeat myself.

Body:
It seems that what you want can be achieved with a simple query:

Select account, substring(failover,10,5) AS "1.Result"
from dbo.f009
where Failover like '$D$Failov:%'


问:
Android / MySQL: Populate Spinner from database with Initial Set Text "Please Select"
I want to ask regarding my codes. I successfully create a spinner that lists data from the database.

In my case, this spinner will populate data from column "fac_name" at table "factory". Now, at initial list of the spinner, I want to display a text "Please Select" and below the text will display the populate data from database. Below is my code.

Java

```<code>public static final String TAG_FAC_NAME = "fac_name";

public static final String JSON_ARRAY = "result";
private JSONArray result;
private ArrayList<String> factoryList;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_task);

    factoryList = new ArrayList<>();
    spFactory = findViewById(R.id.spFactory);
    spFactory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    getData();

}

private void getData(){
    StringRequest stringRequest = new StringRequest(URLs.URL_SPINNER_FACTORY,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {

                    JSONObject j = null;

                    try {
                        j = new JSONObject(response);

                        result = j.getJSONArray(JSON_ARRAY);

                        getFactory(result);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {

                }
            });

    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringRequest);
}

private void getFactory(JSONArray j){
    for(int i=0;i<j.length();i++){
        try {
            JSONObject json = j.getJSONObject(i);

            factoryList.add(json.getString(TAG_FAC_NAME));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    spFactory.setAdapter(new ArrayAdapter<String>(AddTask.this, android.R.layout.simple_spinner_dropdown_item, factoryList));
}
</code>```

URL_SPINNER_FACTORY (spinner_factory.php)

```<code><?php

    require_once "../config/configPDO.php";

    $query = $conn->prepare("SELECT * FROM ot_factory ORDER BY fac_id ASC");
    $query->execute();

    $factoryList = array();

    while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
        array_push($factoryList,array(

            'fac_name'=>$row['fac_name'],

            )
        );
    }

    echo json_encode(array('result'=>$factoryList));

?>
</code>```

Can Nyone help me on this? Thank you..

答:
you can do it by using the XML code. like</p>

```<code>`<Spinner
  android:id="@+id/R.id.spFactory"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_marginStart="20dp"
  android:layout_marginLeft="20dp"
  android:layout_marginTop="15dp"
  android:layout_marginBottom="15dp"
  android:prompt="Please Select" />`
</code>```

Body:
I want to ask regarding my codes. I successfully create a spinner that lists data from the database.

In my case, this spinner will populate data from column "fac_name" at table "factory". Now, at initial list of the spinner, I want to display a text "Please Select" and below the text will display the populate data from database. Below is my code.

Java

public static final String TAG_FAC_NAME = "fac_name";

public static final String JSON_ARRAY = "result";
private JSONArray result;
private ArrayList<String> factoryList;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_task);

    factoryList = new ArrayList<>();
    spFactory = findViewById(R.id.spFactory);
    spFactory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    getData();

}

private void getData(){
    StringRequest stringRequest = new StringRequest(URLs.URL_SPINNER_FACTORY,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {

                    JSONObject j = null;

                    try {
                        j = new JSONObject(response);

                        result = j.getJSONArray(JSON_ARRAY);

                        getFactory(result);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {

                }
            });

    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringRequest);
}

private void getFactory(JSONArray j){
    for(int i=0;i<j.length();i++){
        try {
            JSONObject json = j.getJSONObject(i);

            factoryList.add(json.getString(TAG_FAC_NAME));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    spFactory.setAdapter(new ArrayAdapter<String>(AddTask.this, android.R.layout.simple_spinner_dropdown_item, factoryList));
}

URL_SPINNER_FACTORY (spinner_factory.php)

<?php

    require_once "../config/configPDO.php";

    $query = $conn->prepare("SELECT * FROM ot_factory ORDER BY fac_id ASC");
    $query->execute();

    $factoryList = array();

    while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
        array_push($factoryList,array(

            'fac_name'=>$row['fac_name'],

            )
        );
    }

    echo json_encode(array('result'=>$factoryList));

?>

Can Nyone help me on this? Thank you..

Body:
you can do it by using the XML code. like

`<Spinner
  android:id="@+id/R.id.spFactory"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_marginStart="20dp"
  android:layout_marginLeft="20dp"
  android:layout_marginTop="15dp"
  android:layout_marginBottom="15dp"
  android:prompt="Please Select" />`


问:
How to show the input field value in another input field using reactjs?
I'm new to reactjs. I'm bit confused how to do it, i want to write something in first input field and at the same time it should reflect on the second input field. If i delete the value in the first input field then it should delete the second input field also. Can anybody help me in this?

Here is the Code:

```<code>import React, { Component } from "react";
import "./styles.css";
import { Form, Input, Button } from "semantic-ui-react";

class App extends Component {
  constructor() {
    super();
    this.state = {
      name: "",
      email: ""
    };
  }

  handleName = event => {
    this.setState({ [event.target.name]: event.target.value });
  };

  render() {
    return (
      <div className="App">
        <Form>
          <Input
            placeholder="Name"
            onChange={this.handleName}
            name="name"
            value={this.state.name}
          />
          <Input
            placeholder="Email"
            onChange={this.handleName}
            name="email"
            value="@yahoo.com"
          />
        </Form>
        <Button>Submit</Button>
      </div>
    );
  }
}
export default App;

</code>```

code: "https://codesandbox.io/s/reverent-fast-3w8sz"

答:
You need to use same {this.state.name} as a value for both field. for example:

```<code><Input
            placeholder="Name"
            onChange={this.handleName}
            name="name"
            value={this.state.name}
          />
          <Input
            placeholder="Email"
            onChange={this.handleName}
            name="email"
            value={this.state.name}
          />
</code>```

Body:
I'm new to reactjs. I'm bit confused how to do it, i want to write something in first input field and at the same time it should reflect on the second input field. If i delete the value in the first input field then it should delete the second input field also. Can anybody help me in this?

Here is the Code:

import React, { Component } from "react";
import "./styles.css";
import { Form, Input, Button } from "semantic-ui-react";

class App extends Component {
  constructor() {
    super();
    this.state = {
      name: "",
      email: ""
    };
  }

  handleName = event => {
    this.setState({ [event.target.name]: event.target.value });
  };

  render() {
    return (

        <Form>
          <Input
            placeholder="Name"
            onChange={this.handleName}
            name="name"
            value={this.state.name}
          />
          <Input
            placeholder="Email"
            onChange={this.handleName}
            name="email"
            value="@yahoo.com"
          />
        </Form>
        <Button>Submit</Button>

    );
  }
}
export default App;

code: "https://codesandbox.io/s/reverent-fast-3w8sz"

Body:
You need to use same {this.state.name} as a value for both field. for example:

<Input
            placeholder="Name"
            onChange={this.handleName}
            name="name"
            value={this.state.name}
          />
          <Input
            placeholder="Email"
            onChange={this.handleName}
            name="email"
            value={this.state.name}
          />


问:
Crud Generator with Laravel
Since 2 weeks I work in a projet of devlopment of a application. I must creat many CRUD and it may take many times. Now I want to know if I can use a free crud generator laravel.If yes, which generator?
Need your Help please.</p>

答:
Laravel already provides CRUD operation see: laravel.com/docs/5.8/controllers#resource-controllers

Laravel resource routing assigns the typical "CRUD" routes to a controller with a single line of code. For example, you may wish to create a controller that handles all HTTP requests for "photos" stored by your application. Using the make:controller Artisan command, we can quickly create such a controller:

php artisan make:controller PhotoController --resource
```

[EDIT 1]

Or you can choose for example: Laravel-Backpack/CRUD which comes with an Admin panel and others things like that.

[EDIT 2]

Also you can refer this Laravel blog to choose a generator:

https://laravel-news.com/13-laravel-admin-panel-generators

[EDIT 3]

Again on Laravel Blog you can see that Laravel is constantly evolving a new Artisan command have been added see:

laravel-news.com/laravel-resources-artisan-command

Title: Crud Generator with Laravel

Body:
Laravel already provides CRUD operation see: laravel.com/docs/5.8/controllers#resource-controllers

Laravel resource routing assigns the typical "CRUD" routes to a controller with a single line of code. For example, you may wish to create a controller that handles all HTTP requests for "photos" stored by your application. Using the make:controller Artisan command, we can quickly create such a controller:

php artisan make:controller PhotoController --resource

[EDIT 1]

Or you can choose for example: Laravel-Backpack/CRUD which comes with an Admin panel and others things like that.

[EDIT 2]

Also you can refer this Laravel blog to choose a generator:

https://laravel-news.com/13-laravel-admin-panel-generators

[EDIT 3]

Again on Laravel Blog you can see that Laravel is constantly evolving a new Artisan command have been added see:

laravel-news.com/laravel-resources-artisan-command


问:
Running Ruby on Rails in browser
Hi I really want to learn Ruby on Rails and I have heard it is a great community so hopefully someone can help with this. Couldn't find any direct answering this already but if there is one I'm sure someone will close this and point me in the right direction.

Is it possible to create Ruby on Rails applications from just a browser? I have bought a book and want the easiest possible way to do the exercises and experiment with building some applications, try Gems etc. I know the greatest chance of success is if I can do this when I have a spare 30 minutes ideally on my iPad.

As I am also looking at learning node.js I have signed upto Duostack and Joyent but both still need SSH setup, Github install etc. I'm looking for something that is just in a browser Window, I can write code and see it execute without having to setup any infrastructure. Found this on HackerNews today (reticular activation system?): http://bellard.org/jslinux/ . Looks promising will need to play with it to see if I can get Ruby on Rails working there but HN comments say no Internet connection so maybe not.

I do have a small netbook which I am going to run Ubuntu on which I guess is the other option but carrying this around will reduce my chances of success.

答:
If you have a server up and running, you could use SSH through a Webapp (I'm sure there are some open source solutions available) to create your application, use rake, the scripts and so on. Also you can use nano/VI/whatever to edit your codefiles.

This way it is possible to do it with an ipad, but I would definetly prefer the netbook since it is MUCH more easy to code this way!

Title: Running Ruby on Rails in browser


问:
how to get field value from model
I have a model for registering with some fields.
All fields are models I fill in through the form like this.

```<code>def get_name(request):
if request.method == 'POST':
    user_code = generate_code(8)
    subject = 'code'
    message = user_code
    phone=request.POST['phone']
    form = NameForm(request.POST)
    if form.is_valid():
        date_use = form.cleaned_data.get("date_visit")
        time_use = form.cleaned_data.get("time_visit")
        purpose_use = form.cleaned_data.get("purpose")
        if Registration.objects.filter(date_visit=date_use,time_visit=time_use,purpose=purpose_use).count()==0:
            Registration.objects.create(fio=request.POST['fio'],phone=request.POST['phone'],date_visit=request.POST['date_visit'],time_visit=request.POST['time_visit'],
                number_car=request.POST['number_car'],purpose=request.POST['purpose'],
                tso=request.POST['tso'])
            request.session["phone"] = phone
            request.session["code"] = user_code
            return HttpResponseRedirect('endreg')
else:
    form = NameForm()
return render(request, 'registers/detail.html', {'form': form})
</code>```

The model also has a field

```<code>date_register = models.DateTimeField(verbose_name = 'date register', auto_now_add=True)
</code>```

how can i write date_register value in request.session["date"] ?

答:
By default django use JSONSerializer and it can't dump datetime objects.

The simplest solution is using PickleSerializer as SESSION_SERIALIZER, but it can cause performance issues (docs: https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-SESSION_SERIALIZER)

Another way to do it - write you custom json serializer, based on django serializer, but with default function for dumping datetime objects, or simple convert date to string format or timestamp before saving to session.

Title: how to get field value from model

Body:
I have a model for registering with some fields.
All fields are models I fill in through the form like this.

def get_name(request):
if request.method == 'POST':
    user_code = generate_code(8)
    subject = 'code'
    message = user_code
    phone=request.POST['phone']
    form = NameForm(request.POST)
    if form.is_valid():
        date_use = form.cleaned_data.get("date_visit")
        time_use = form.cleaned_data.get("time_visit")
        purpose_use = form.cleaned_data.get("purpose")
        if Registration.objects.filter(date_visit=date_use,time_visit=time_use,purpose=purpose_use).count()==0:
            Registration.objects.create(fio=request.POST['fio'],phone=request.POST['phone'],date_visit=request.POST['date_visit'],time_visit=request.POST['time_visit'],
                number_car=request.POST['number_car'],purpose=request.POST['purpose'],
                tso=request.POST['tso'])
            request.session["phone"] = phone
            request.session["code"] = user_code
            return HttpResponseRedirect('endreg')
else:
    form = NameForm()
return render(request, 'registers/detail.html', {'form': form})

The model also has a field

date_register = models.DateTimeField(verbose_name = 'date register', auto_now_add=True)

how can i write date_register value in request.session["date"] ?


问:
modemmanager gsm registration timeout
Our OS is Yocto 2.4 Rocko running on i.MX6.
For testing SIMCOM SIM7600JC-H LTE module, We installed NetworkManager v1.4.4, ModemManager v1.6.4, and pppd v2.4.7.

We test the SIM7600JC-H LTE function, it worked well in Taiwan but worked failed in Japan. We tried to find the difference between the two tests. And we found the main reason is that if we don't set APN to LTE module before the modem manager starts to run in Japan, it would work failed. So if I set APN to LTE module and then start modem manager service in Japan, it would work well and connect to the internet.

We think if the modem is in register status is the root cause.
If the modem isn't in register status at first and then starting the modem manager, it would work failed to connect to the internet.

In Taiwan, we don't need to set APN to the LTE module, and then the LTE module would be in register status after a SIM card is inserted and powered on.

In Japan, we need to set APN to the LTE module, and then the LTE module would be in register status after a SIM card is inserted and powered on.

The log is about modem manager works failed

```Simple  connect state   (4/8):  Wait    to  get fully   enabled
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2):  --> 'ATX4<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2):  --> 'AT&C1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
loading power   state...
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CFUN?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CFUN: 1<CR><LF><CR><LF>OK<CR><LF>'
No  need    to  change  power   state:  already in  'on'    power   state
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2):  --> 'AT+IFC=1,1<CR>'
(ttyUSB2):  <-- '<CR><LF>ERROR<CR><LF>'
Got failure code    100:00:00   Unknown error
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CSCS=?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CSCS: ("IRA","GSM","UCS2")<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CSCS="UCS2"<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CSCS?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CSCS: UCS2<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  1   (close)
Modem   has 3GPP    capabilities,   enabling    the Modem   3GPP    interface...
Checking    indicator   support...
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CIND=?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CIND: ("battchg",(0-5)),("signal",(0-5)),("service",(0-1)),("call",(0-1)),("roam",(0-1)),("smsfull",(0-1)),("GPRS coverage",(0-1)),("callsetup",(0-3))<CR><LF><CR><LF>OK<CR><LF>'
Modem   supports    signal  quality indications via CIND    at  index   '2'(min:    0,  max:    5)
Modem   supports    roaming indications via CIND    at  index   '5'
Modem   supports    service indications via CIND    at  index   '3'
(ttyUSB2)   Setting 3GPP    unsolicited events  handlers
(ttyUSB3)   Setting 3GPP    unsolicited events  handlers
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMER=3,0,0,1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB3):  --> 'AT+CMER=3,0,0,1<CR>'
(ttyUSB3):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB3)   device  open    count   is  1   (close)
(ttyUSB2):  --> 'AT+CNSMOD=1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2):  --> 'AT+AUTOCSQ=1,1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   setting up  3GPP    unsolicited registration    messages    handlers
(ttyUSB3)   setting up  3GPP    unsolicited registration    messages    handlers
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CREG=2<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB3):  --> 'AT+CREG=2<CR>'
(ttyUSB3):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB3)   device  open    count   is  1   (close)
(ttyUSB2):  --> 'AT+CGREG=2<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB3):  --> 'AT+CGREG=2<CR>'
(ttyUSB3):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   device  open    count   is  1   (close)
Modem   has 3GPP/USSD   capabilities,   enabling    the Modem   3GPP/USSD   interface...
(ttyUSB2)   Setting unsolicited result  code    handlers
(ttyUSB3)   Setting unsolicited result  code    handlers
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CUSD=1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  1   (close)
Modem   has location    capabilities,   enabling    the Location    interface...
Need    to  enable  the following   location    sources:    '3gpp-lac-ci'
Running registration    checks  (CS:    'yes',  PS: 'yes',  EPS:    'no')
(ttyUSB2)   device  open    count   is  2   (open)
Modem   has messaging   capabilities,   enabling    the Messaging   interface...
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2):  --> 'AT+CREG?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CREG: 2,2<CR><LF><CR><LF>OK<CR><LF>'
Modem   /org/freedesktop/ModemManager1/Modem/0: 3GPP    Registration    state   changed (unknown    ->  searching)
Will    start   keeping track   of  state   for subsystem   '3gpp'
(ttyUSB2)   device  open    count   is  4   (open)
(ttyUSB2)   device  open    count   is  3   (close)
(ttyUSB2):  --> 'AT+CMGF=?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CMGF: (0-1)<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  4   (open)
(ttyUSB2)   device  open    count   is  3   (close)
(ttyUSB2):  --> 'AT+CGREG?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CGREG:    2,2<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMGF=0<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
Successfully    set preferred   SMS mode:   'PDU'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CPMS="SR","ME","ME"<CR>'
(ttyUSB2):  <-- '<CR><LF>+CPMS: 0,20,1,23,1,23<CR><LF><CR><LF>OK<CR><LF>'
Listing SMS parts   in  storage 'me'
Locking SMS storages    to: mem1    (ME),   mem2    (none)...
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CPMS="ME"<CR>'
(ttyUSB2):  <-- '<CR><LF>+CPMS: 1,23,1,23,1,23<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMGL=4<CR>'
(ttyUSB2):  <-- '<CR><LF>+CMGL: 0,1,"",151<CR><LF>0891180945123470F42414D0B01A0C87C3C160B11A0E0008918051518543638096FB8A71756A53F7FF1A00380031003800300032003100350038003400380038003525C630AD30FCFF1A0053004100430046002D005300500043004C002D0043003400390042002D0035004500410032002D003800320037003525C600550052004CFF1A0068007400740070003A002F002F0077006200720074002E006A0070<CR><LF><CR><LF>OK<CR><LF>'
Parsing PDU (0)...
SMSC    address parsed: '+8190542143074'
Deliver type    PDU detected
Number  parsed: '05088800158'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 128 elements
user    data    length: 128 bytes
Decoding    SMS text    with    '128'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '????:818021584885???:SACF-SPCL-C49B-5EA2-8275?URL:http://wbrt.jp'
Correctly   parsed  PDU 0
SMS part    at  'me/0'  is  from    a   singlepart  SMS
Added   received    SMS at  '/org/freedesktop/ModemManager1/SMS/0'
Listing SMS parts   in  storage 'sm'
Locking SMS storages    to: mem1    (SM),   mem2    (none)...
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CPMS="SM"<CR>'
(ttyUSB2):  <-- '<CR><LF>+CPMS: 4,20,1,23,1,23<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMGL=4<CR>'
(ttyUSB2):  <-- '<CR><LF>+CMGL: 0,1,"",161<CR><LF>0891180945123460F64012D04E2A15447C0E9FCD270008913010116561638B0608049E6A0401301030C930B330E2304B3089306E304A77E53089305B3011000D000A672C30E130FC30EB306F682A5F0F4F1A793E004E0054005430C930B330E2304B3089901A4FE16599712165993067914D4FE1305730663044307E30593002000D000A000D000A304A5BA269D8306E7AEF672B304C30C930B330E2306E30CD30C330C830EF30FC30AF<CR><LF>+CMGL:    1,1,"",161<CR><LF>0891180945123460F64012D04E2A15447C0E9FCD270008913010116561638B0608049E6A0402306B6B633057304F3064306A304C3063305F305330683092304A77E53089305B3044305F3057307E30593002000D000A000D000A0073007030E230FC30C93092305452297528306E969B306F300130A230AF30BB30B930DD30A430F330C83092300C00730070006D006F00640065002E006E0065002E006A0070300D306B8A2D5B9A3057<CR><LF>+CMGL:    2,1,"",161<CR><LF>0891180945123460F64012D04E2A15447C0E9FCD270008913010116561638B0608049E6A04033066304F3060305530443002000D000A000D000A3088308A5FEB9069306B3054522975283044305F3060304F305F3081306E8A2D5B9A65B96CD530016CE8610F4E8B98053001554F5408305B51487B49306B306430443066306F30014E0B8A1800550052004C3088308A305478BA8A8D304F3060305530443002FF08901A4FE165996709<CR><LF>+CMGL:    3,1,"",145<CR><LF>0891180945123460F64412D04E2A15447C0E9FCD270008913010116561637B0608049E6A04046599FF09000D000A0068007400740070003A002F002F0073006500720076006900630065002E0073006D0074002E0064006F0063006F006D006F002E006E0065002E006A0070002F0073006900740065002F006D00610069006C002F007300720063002F00630063006E002E00680074006D006C<CR><LF><CR><LF>OK<CR><LF>'
Parsing PDU (0)...
SMSC    address parsed: '+8190542143066'
Deliver type    PDU detected
Number  parsed: 'NTT    DOCOMO'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 139 elements
user    data    length: 139 bytes
Decoding    SMS text    with    '132'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '????????????#015#012?????????NTT???????????????????#015#012#015#012?????????????????'
Correctly   parsed  PDU 0
SMS part    at  'sm/0'  is  from    a   multipart   SMS (reference: '40554',    sequence:   '1')
Added   received    SMS at  '/org/freedesktop/ModemManager1/SMS/1'
Parsing PDU (1)...
SMSC    address parsed: '+8190542143066'
Deliver type    PDU detected
Number  parsed: 'NTT    DOCOMO'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 139 elements
user    data    length: 139 bytes
Decoding    SMS text    with    '132'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '??????????????????????#015#012#015#012sp?????????????????????spmode.ne.jp?????'
Correctly   parsed  PDU -1
SMS part    at  'sm/1'  is  from    a   multipart   SMS (reference: '40554',    sequence:   '2')
Parsing PDU (2)...
SMSC    address parsed: '+8190542143066'
Deliver type    PDU detected
Number  parsed: 'NTT    DOCOMO'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 139 elements
user    data    length: 139 bytes
Decoding    SMS text    with    '132'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '??????#015#012#015#012??????????????????????????????????????URL??????????(????'
Correctly   parsed  PDU -2
SMS part    at  'sm/2'  is  from    a   multipart   SMS (reference: '40554',    sequence:   '3')
Parsing PDU (3)...
SMSC    address parsed: '+8190542143066'
Deliver type    PDU detected
Number  parsed: 'NTT    DOCOMO'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 123 elements
user    data    length: 123 bytes
Decoding    SMS text    with    '116'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '?)#015#012http://service.smt.docomo.ne.jp/site/mail/src/ccn.html'
Correctly   parsed  PDU -3
SMS part    at  'sm/3'  is  from    a   multipart   SMS (reference: '40554',    sequence:   '4')
Listing SMS parts   in  storage 'sr'
Locking SMS storages    to: mem1    (SR),   mem2    (none)...
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CPMS="SR"<CR>'
(ttyUSB2):  <-- '<CR><LF>+CPMS: 0,20,1,23,1,23<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMGL=4<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   Setting messaging   unsolicited events  handlers
(ttyUSB3)   Setting messaging   unsolicited events  handlers
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB2)   Enabling    messaging   unsolicited events  on  primary port
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CNMI=2,1,2,1,0<CR>'
(ttyUSB2):  <-- '<CR><LF>+CMS   ERROR:  303<CR><LF>'
Got failure code    303:00:00   Operation   not supported
(ttyUSB2):  --> 'AT+CNMI=2,1,2,2,0<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   Messaging   unsolicited events  enabled on  primary
(ttyUSB3)   Enabling    messaging   unsolicited events  on  secondary   port
(ttyUSB3)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB3):  --> 'AT+CNMI=2,1,2,1,0<CR>'
(ttyUSB3):  <-- '<CR><LF>+CMS   ERROR:  303<CR><LF>'
Got failure code    303:00:00   Operation   not supported
(ttyUSB3):  --> 'AT+CNMI=2,1,2,2,0<CR>'
(ttyUSB3):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   Messaging   unsolicited events  enabled on  secondary
(ttyUSB3)   device  open    count   is  1   (close)
Modem   has voice   capabilities,   enabling    the Voice   interface...
(ttyUSB2)   Setting voice   unsolicited events  handlers
(ttyUSB3)   Setting voice   unsolicited events  handlers
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CLIP=1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2):  --> 'AT+CRC=1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  1   (close)
Modem   has time    capabilities,   enabling    the Time    interface...
Modem   /org/freedesktop/ModemManager1/Modem/0: state   changed (enabling   ->  searching)
Simple  connect state   (5/8):  Register
```

<p>We had checked and compared the two syslog and found something.</p>

<p>If modem worked failed, the log would appear as below</p>

```Modem /org/freedesktop/ModemManager1/Modem/0: 3GPP Registration state changed (unknown -> searching)
```

<p>If modem worked well, the log would appear as below</p>

```Modem /org/freedesktop/ModemManager1/Modem/0: 3GPP Registration state changed (unknown -> registering)
```

Between the two steps in log

(1)Simple connect state (4/8): Wait to get fully enabled

and

(2)Simple connect state (5/8): Register

We could not find any AT command about setting APN to LTE module.

Is there a network manager command or modem manager command to fix the issue?
Or I have to download modem manager source code and modify it for Japan case?

答:
What you're probably missing is the configuration of the "APN of the default LTE bearer". If the network in Japan requires a specific APN for the default LTE bearer, you would need that preconfigured even just to get registered in the network.

ModemManager has APIs to configure this, see SetInitialEpsBearerSettings(), but I'm afraid the API is not implemented for the specific case of your SIMCOM modem. The initial EPS bearer settings can only be changed in MBIM modems supporting it as of right now.

If you'd like to improve MM to add the SIMCOM-specific implementation needed for SetInitialEpsBearerSettings(), please do so and send the changes to upstream for review in the fd.o gitlab. Otherwise, you could build ModemManager using the --with-at-command-via-dbus configure option, so that you can send the AT commands you need via DBus using Command().

Title: modemmanager gsm registration timeout

Body:
Our OS is Yocto 2.4 Rocko running on i.MX6.
For testing SIMCOM SIM7600JC-H LTE module, We installed NetworkManager v1.4.4, ModemManager v1.6.4, and pppd v2.4.7.

We test the SIM7600JC-H LTE function, it worked well in Taiwan but worked failed in Japan. We tried to find the difference between the two tests. And we found the main reason is that if we don't set APN to LTE module before the modem manager starts to run in Japan, it would work failed. So if I set APN to LTE module and then start modem manager service in Japan, it would work well and connect to the internet.

We think if the modem is in register status is the root cause.
If the modem isn't in register status at first and then starting the modem manager, it would work failed to connect to the internet.

In Taiwan, we don't need to set APN to the LTE module, and then the LTE module would be in register status after a SIM card is inserted and powered on.

In Japan, we need to set APN to the LTE module, and then the LTE module would be in register status after a SIM card is inserted and powered on.

The log is about modem manager works failed

Simple  connect state   (4/8):  Wait    to  get fully   enabled
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2):  --> 'ATX4<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2):  --> 'AT&C1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
loading power   state...
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CFUN?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CFUN: 1<CR><LF><CR><LF>OK<CR><LF>'
No  need    to  change  power   state:  already in  'on'    power   state
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2):  --> 'AT+IFC=1,1<CR>'
(ttyUSB2):  <-- '<CR><LF>ERROR<CR><LF>'
Got failure code    100:00:00   Unknown error
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CSCS=?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CSCS: ("IRA","GSM","UCS2")<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CSCS="UCS2"<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CSCS?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CSCS: UCS2<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  1   (close)
Modem   has 3GPP    capabilities,   enabling    the Modem   3GPP    interface...
Checking    indicator   support...
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CIND=?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CIND: ("battchg",(0-5)),("signal",(0-5)),("service",(0-1)),("call",(0-1)),("roam",(0-1)),("smsfull",(0-1)),("GPRS coverage",(0-1)),("callsetup",(0-3))<CR><LF><CR><LF>OK<CR><LF>'
Modem   supports    signal  quality indications via CIND    at  index   '2'(min:    0,  max:    5)
Modem   supports    roaming indications via CIND    at  index   '5'
Modem   supports    service indications via CIND    at  index   '3'
(ttyUSB2)   Setting 3GPP    unsolicited events  handlers
(ttyUSB3)   Setting 3GPP    unsolicited events  handlers
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMER=3,0,0,1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB3):  --> 'AT+CMER=3,0,0,1<CR>'
(ttyUSB3):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB3)   device  open    count   is  1   (close)
(ttyUSB2):  --> 'AT+CNSMOD=1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2):  --> 'AT+AUTOCSQ=1,1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   setting up  3GPP    unsolicited registration    messages    handlers
(ttyUSB3)   setting up  3GPP    unsolicited registration    messages    handlers
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CREG=2<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB3):  --> 'AT+CREG=2<CR>'
(ttyUSB3):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB3)   device  open    count   is  1   (close)
(ttyUSB2):  --> 'AT+CGREG=2<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB3):  --> 'AT+CGREG=2<CR>'
(ttyUSB3):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   device  open    count   is  1   (close)
Modem   has 3GPP/USSD   capabilities,   enabling    the Modem   3GPP/USSD   interface...
(ttyUSB2)   Setting unsolicited result  code    handlers
(ttyUSB3)   Setting unsolicited result  code    handlers
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CUSD=1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  1   (close)
Modem   has location    capabilities,   enabling    the Location    interface...
Need    to  enable  the following   location    sources:    '3gpp-lac-ci'
Running registration    checks  (CS:    'yes',  PS: 'yes',  EPS:    'no')
(ttyUSB2)   device  open    count   is  2   (open)
Modem   has messaging   capabilities,   enabling    the Messaging   interface...
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2):  --> 'AT+CREG?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CREG: 2,2<CR><LF><CR><LF>OK<CR><LF>'
Modem   /org/freedesktop/ModemManager1/Modem/0: 3GPP    Registration    state   changed (unknown    ->  searching)
Will    start   keeping track   of  state   for subsystem   '3gpp'
(ttyUSB2)   device  open    count   is  4   (open)
(ttyUSB2)   device  open    count   is  3   (close)
(ttyUSB2):  --> 'AT+CMGF=?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CMGF: (0-1)<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  4   (open)
(ttyUSB2)   device  open    count   is  3   (close)
(ttyUSB2):  --> 'AT+CGREG?<CR>'
(ttyUSB2):  <-- '<CR><LF>+CGREG:    2,2<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMGF=0<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
Successfully    set preferred   SMS mode:   'PDU'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CPMS="SR","ME","ME"<CR>'
(ttyUSB2):  <-- '<CR><LF>+CPMS: 0,20,1,23,1,23<CR><LF><CR><LF>OK<CR><LF>'
Listing SMS parts   in  storage 'me'
Locking SMS storages    to: mem1    (ME),   mem2    (none)...
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CPMS="ME"<CR>'
(ttyUSB2):  <-- '<CR><LF>+CPMS: 1,23,1,23,1,23<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMGL=4<CR>'
(ttyUSB2):  <-- '<CR><LF>+CMGL: 0,1,"",151<CR><LF>0891180945123470F42414D0B01A0C87C3C160B11A0E0008918051518543638096FB8A71756A53F7FF1A00380031003800300032003100350038003400380038003525C630AD30FCFF1A0053004100430046002D005300500043004C002D0043003400390042002D0035004500410032002D003800320037003525C600550052004CFF1A0068007400740070003A002F002F0077006200720074002E006A0070<CR><LF><CR><LF>OK<CR><LF>'
Parsing PDU (0)...
SMSC    address parsed: '+8190542143074'
Deliver type    PDU detected
Number  parsed: '05088800158'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 128 elements
user    data    length: 128 bytes
Decoding    SMS text    with    '128'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '????:818021584885???:SACF-SPCL-C49B-5EA2-8275?URL:http://wbrt.jp'
Correctly   parsed  PDU 0
SMS part    at  'me/0'  is  from    a   singlepart  SMS
Added   received    SMS at  '/org/freedesktop/ModemManager1/SMS/0'
Listing SMS parts   in  storage 'sm'
Locking SMS storages    to: mem1    (SM),   mem2    (none)...
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CPMS="SM"<CR>'
(ttyUSB2):  <-- '<CR><LF>+CPMS: 4,20,1,23,1,23<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMGL=4<CR>'
(ttyUSB2):  <-- '<CR><LF>+CMGL: 0,1,"",161<CR><LF>0891180945123460F64012D04E2A15447C0E9FCD270008913010116561638B0608049E6A0401301030C930B330E2304B3089306E304A77E53089305B3011000D000A672C30E130FC30EB306F682A5F0F4F1A793E004E0054005430C930B330E2304B3089901A4FE16599712165993067914D4FE1305730663044307E30593002000D000A000D000A304A5BA269D8306E7AEF672B304C30C930B330E2306E30CD30C330C830EF30FC30AF<CR><LF>+CMGL:    1,1,"",161<CR><LF>0891180945123460F64012D04E2A15447C0E9FCD270008913010116561638B0608049E6A0402306B6B633057304F3064306A304C3063305F305330683092304A77E53089305B3044305F3057307E30593002000D000A000D000A0073007030E230FC30C93092305452297528306E969B306F300130A230AF30BB30B930DD30A430F330C83092300C00730070006D006F00640065002E006E0065002E006A0070300D306B8A2D5B9A3057<CR><LF>+CMGL:    2,1,"",161<CR><LF>0891180945123460F64012D04E2A15447C0E9FCD270008913010116561638B0608049E6A04033066304F3060305530443002000D000A000D000A3088308A5FEB9069306B3054522975283044305F3060304F305F3081306E8A2D5B9A65B96CD530016CE8610F4E8B98053001554F5408305B51487B49306B306430443066306F30014E0B8A1800550052004C3088308A305478BA8A8D304F3060305530443002FF08901A4FE165996709<CR><LF>+CMGL:    3,1,"",145<CR><LF>0891180945123460F64412D04E2A15447C0E9FCD270008913010116561637B0608049E6A04046599FF09000D000A0068007400740070003A002F002F0073006500720076006900630065002E0073006D0074002E0064006F0063006F006D006F002E006E0065002E006A0070002F0073006900740065002F006D00610069006C002F007300720063002F00630063006E002E00680074006D006C<CR><LF><CR><LF>OK<CR><LF>'
Parsing PDU (0)...
SMSC    address parsed: '+8190542143066'
Deliver type    PDU detected
Number  parsed: 'NTT    DOCOMO'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 139 elements
user    data    length: 139 bytes
Decoding    SMS text    with    '132'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '????????????#015#012?????????NTT???????????????????#015#012#015#012?????????????????'
Correctly   parsed  PDU 0
SMS part    at  'sm/0'  is  from    a   multipart   SMS (reference: '40554',    sequence:   '1')
Added   received    SMS at  '/org/freedesktop/ModemManager1/SMS/1'
Parsing PDU (1)...
SMSC    address parsed: '+8190542143066'
Deliver type    PDU detected
Number  parsed: 'NTT    DOCOMO'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 139 elements
user    data    length: 139 bytes
Decoding    SMS text    with    '132'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '??????????????????????#015#012#015#012sp?????????????????????spmode.ne.jp?????'
Correctly   parsed  PDU -1
SMS part    at  'sm/1'  is  from    a   multipart   SMS (reference: '40554',    sequence:   '2')
Parsing PDU (2)...
SMSC    address parsed: '+8190542143066'
Deliver type    PDU detected
Number  parsed: 'NTT    DOCOMO'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 139 elements
user    data    length: 139 bytes
Decoding    SMS text    with    '132'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '??????#015#012#015#012??????????????????????????????????????URL??????????(????'
Correctly   parsed  PDU -2
SMS part    at  'sm/2'  is  from    a   multipart   SMS (reference: '40554',    sequence:   '3')
Parsing PDU (3)...
SMSC    address parsed: '+8190542143066'
Deliver type    PDU detected
Number  parsed: 'NTT    DOCOMO'
PID:    0
user    data    encoding    is  UCS2
user    data    length: 123 elements
user    data    length: 123 bytes
Decoding    SMS text    with    '116'   elements
Converting  SMS part    text    from    UCS-2BE to  UTF8...
Got UTF-8   text:   '?)#015#012http://service.smt.docomo.ne.jp/site/mail/src/ccn.html'
Correctly   parsed  PDU -3
SMS part    at  'sm/3'  is  from    a   multipart   SMS (reference: '40554',    sequence:   '4')
Listing SMS parts   in  storage 'sr'
Locking SMS storages    to: mem1    (SR),   mem2    (none)...
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CPMS="SR"<CR>'
(ttyUSB2):  <-- '<CR><LF>+CPMS: 0,20,1,23,1,23<CR><LF><CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  3   (open)
(ttyUSB2)   device  open    count   is  2   (close)
(ttyUSB2):  --> 'AT+CMGL=4<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   Setting messaging   unsolicited events  handlers
(ttyUSB3)   Setting messaging   unsolicited events  handlers
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB2)   Enabling    messaging   unsolicited events  on  primary port
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CNMI=2,1,2,1,0<CR>'
(ttyUSB2):  <-- '<CR><LF>+CMS   ERROR:  303<CR><LF>'
Got failure code    303:00:00   Operation   not supported
(ttyUSB2):  --> 'AT+CNMI=2,1,2,2,0<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   Messaging   unsolicited events  enabled on  primary
(ttyUSB3)   Enabling    messaging   unsolicited events  on  secondary   port
(ttyUSB3)   device  open    count   is  2   (open)
(ttyUSB2)   device  open    count   is  1   (close)
(ttyUSB3):  --> 'AT+CNMI=2,1,2,1,0<CR>'
(ttyUSB3):  <-- '<CR><LF>+CMS   ERROR:  303<CR><LF>'
Got failure code    303:00:00   Operation   not supported
(ttyUSB3):  --> 'AT+CNMI=2,1,2,2,0<CR>'
(ttyUSB3):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB3)   Messaging   unsolicited events  enabled on  secondary
(ttyUSB3)   device  open    count   is  1   (close)
Modem   has voice   capabilities,   enabling    the Voice   interface...
(ttyUSB2)   Setting voice   unsolicited events  handlers
(ttyUSB3)   Setting voice   unsolicited events  handlers
(ttyUSB2)   device  open    count   is  2   (open)
(ttyUSB2):  --> 'AT+CLIP=1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2):  --> 'AT+CRC=1<CR>'
(ttyUSB2):  <-- '<CR><LF>OK<CR><LF>'
(ttyUSB2)   device  open    count   is  1   (close)
Modem   has time    capabilities,   enabling    the Time    interface...
Modem   /org/freedesktop/ModemManager1/Modem/0: state   changed (enabling   ->  searching)
Simple  connect state   (5/8):  Register

We had checked and compared the two syslog and found something.

If modem worked failed, the log would appear as below

Modem /org/freedesktop/ModemManager1/Modem/0: 3GPP Registration state changed (unknown -> searching)

If modem worked well, the log would appear as below

Modem /org/freedesktop/ModemManager1/Modem/0: 3GPP Registration state changed (unknown -> registering)

Between the two steps in log

(1)Simple connect state (4/8): Wait to get fully enabled

and

(2)Simple connect state (5/8): Register

We could not find any AT command about setting APN to LTE module.

Is there a network manager command or modem manager command to fix the issue?
Or I have to download modem manager source code and modify it for Japan case?