Added support for the WNC M14A2A Cellular LTE Data Module.

Dependencies:   WNC14A2AInterface

Easy Connect

Easily add all supported connectivity methods to your mbed OS project

This project is derived from https://developer.mbed.org/teams/sandbox/code/simple-mbed-client-example/file/dd6231df71bb/easy-connect.lib. It give user the ability to switch between connectivity methods and includes support for the WNC14A2A Data Module. The `NetworkInterface` API makes this easy, but you still need a mechanism for the user to select the connection method, The selection is made by modifying the `mbed_app.json` file and using `easy_connect()` from your application.

Specifying connectivity method

To add support for the WNC14A2A, add the following to your ``mbed_app.json`` file:

mbed_app.json

{
    "config": {
        "network-interface":{
            "help": "options are ETHERNET,WIFI_ESP8266,WIFI_ODIN,MESH_LOWPAN_ND,MESH_THREAD,WNC14A2A",
            "value": "WNC14A2A"
        }
    },
}

After you choose `WNC14A2A` you'll also need to indicate if you want debug output or not by Enabling (true) or Disabling (false) WNC_DEBUG.

If WNC_DEBUG is enabled, there are 3 different levels of debug output (selected via bit settings). These debug levels are set using the following values:

ValueDescription
1Basic WNC driver debug output
2Comprehensive WNC driver debug output
4Network Layer debug output

You can have any combination of these three bit values for a total value of 0 – 7.

WNC Debug Settings

    "config": {
        "WNC_DEBUG": {
            "value": false
        },
        "WNC_DEBUG_SETTING": {
            "value": 4
        },
    }

Using Easy Connect from your application

Easy Connect has just one function which will either return a `NetworkInterface`-pointer or `NULL`:

Sample Code

#include "easy-connect.h"

int main(int, char**) {
    NetworkInterface* network = easy_connect(true); /* has 1 argument, enable_logging (pass in true to log to serial port) */
    if (!network) {
        printf("Connecting to the network failed... See serial output.\r\n");
        return 1;
    }
 
    // Rest of your program
}

Tested on

  • K64F with Ethernet.
  • AT&T Cellular IoT Starter Kit with WNC M14A2A Cellular Data Module

The WNCInterface class currently supports the following version(s):

  • MPSS: M14A2A_v11.50.164451 APSS: M14A2A_v11.53.164451

License

This library is released under the Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License and may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Committer:
group-Avnet
Date:
Wed Apr 19 01:08:11 2017 +0000
Revision:
0:478cfd88041f
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
group-Avnet 0:478cfd88041f 1 #!/bin/sh
group-Avnet 0:478cfd88041f 2 #
group-Avnet 0:478cfd88041f 3 # Copyright (c) 2006, 2008 Junio C Hamano
group-Avnet 0:478cfd88041f 4 #
group-Avnet 0:478cfd88041f 5 # The "pre-rebase" hook is run just before "git rebase" starts doing
group-Avnet 0:478cfd88041f 6 # its job, and can prevent the command from running by exiting with
group-Avnet 0:478cfd88041f 7 # non-zero status.
group-Avnet 0:478cfd88041f 8 #
group-Avnet 0:478cfd88041f 9 # The hook is called with the following parameters:
group-Avnet 0:478cfd88041f 10 #
group-Avnet 0:478cfd88041f 11 # $1 -- the upstream the series was forked from.
group-Avnet 0:478cfd88041f 12 # $2 -- the branch being rebased (or empty when rebasing the current branch).
group-Avnet 0:478cfd88041f 13 #
group-Avnet 0:478cfd88041f 14 # This sample shows how to prevent topic branches that are already
group-Avnet 0:478cfd88041f 15 # merged to 'next' branch from getting rebased, because allowing it
group-Avnet 0:478cfd88041f 16 # would result in rebasing already published history.
group-Avnet 0:478cfd88041f 17
group-Avnet 0:478cfd88041f 18 publish=next
group-Avnet 0:478cfd88041f 19 basebranch="$1"
group-Avnet 0:478cfd88041f 20 if test "$#" = 2
group-Avnet 0:478cfd88041f 21 then
group-Avnet 0:478cfd88041f 22 topic="refs/heads/$2"
group-Avnet 0:478cfd88041f 23 else
group-Avnet 0:478cfd88041f 24 topic=`git symbolic-ref HEAD` ||
group-Avnet 0:478cfd88041f 25 exit 0 ;# we do not interrupt rebasing detached HEAD
group-Avnet 0:478cfd88041f 26 fi
group-Avnet 0:478cfd88041f 27
group-Avnet 0:478cfd88041f 28 case "$topic" in
group-Avnet 0:478cfd88041f 29 refs/heads/??/*)
group-Avnet 0:478cfd88041f 30 ;;
group-Avnet 0:478cfd88041f 31 *)
group-Avnet 0:478cfd88041f 32 exit 0 ;# we do not interrupt others.
group-Avnet 0:478cfd88041f 33 ;;
group-Avnet 0:478cfd88041f 34 esac
group-Avnet 0:478cfd88041f 35
group-Avnet 0:478cfd88041f 36 # Now we are dealing with a topic branch being rebased
group-Avnet 0:478cfd88041f 37 # on top of master. Is it OK to rebase it?
group-Avnet 0:478cfd88041f 38
group-Avnet 0:478cfd88041f 39 # Does the topic really exist?
group-Avnet 0:478cfd88041f 40 git show-ref -q "$topic" || {
group-Avnet 0:478cfd88041f 41 echo >&2 "No such branch $topic"
group-Avnet 0:478cfd88041f 42 exit 1
group-Avnet 0:478cfd88041f 43 }
group-Avnet 0:478cfd88041f 44
group-Avnet 0:478cfd88041f 45 # Is topic fully merged to master?
group-Avnet 0:478cfd88041f 46 not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
group-Avnet 0:478cfd88041f 47 if test -z "$not_in_master"
group-Avnet 0:478cfd88041f 48 then
group-Avnet 0:478cfd88041f 49 echo >&2 "$topic is fully merged to master; better remove it."
group-Avnet 0:478cfd88041f 50 exit 1 ;# we could allow it, but there is no point.
group-Avnet 0:478cfd88041f 51 fi
group-Avnet 0:478cfd88041f 52
group-Avnet 0:478cfd88041f 53 # Is topic ever merged to next? If so you should not be rebasing it.
group-Avnet 0:478cfd88041f 54 only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
group-Avnet 0:478cfd88041f 55 only_next_2=`git rev-list ^master ${publish} | sort`
group-Avnet 0:478cfd88041f 56 if test "$only_next_1" = "$only_next_2"
group-Avnet 0:478cfd88041f 57 then
group-Avnet 0:478cfd88041f 58 not_in_topic=`git rev-list "^$topic" master`
group-Avnet 0:478cfd88041f 59 if test -z "$not_in_topic"
group-Avnet 0:478cfd88041f 60 then
group-Avnet 0:478cfd88041f 61 echo >&2 "$topic is already up-to-date with master"
group-Avnet 0:478cfd88041f 62 exit 1 ;# we could allow it, but there is no point.
group-Avnet 0:478cfd88041f 63 else
group-Avnet 0:478cfd88041f 64 exit 0
group-Avnet 0:478cfd88041f 65 fi
group-Avnet 0:478cfd88041f 66 else
group-Avnet 0:478cfd88041f 67 not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
group-Avnet 0:478cfd88041f 68 /usr/bin/perl -e '
group-Avnet 0:478cfd88041f 69 my $topic = $ARGV[0];
group-Avnet 0:478cfd88041f 70 my $msg = "* $topic has commits already merged to public branch:\n";
group-Avnet 0:478cfd88041f 71 my (%not_in_next) = map {
group-Avnet 0:478cfd88041f 72 /^([0-9a-f]+) /;
group-Avnet 0:478cfd88041f 73 ($1 => 1);
group-Avnet 0:478cfd88041f 74 } split(/\n/, $ARGV[1]);
group-Avnet 0:478cfd88041f 75 for my $elem (map {
group-Avnet 0:478cfd88041f 76 /^([0-9a-f]+) (.*)$/;
group-Avnet 0:478cfd88041f 77 [$1 => $2];
group-Avnet 0:478cfd88041f 78 } split(/\n/, $ARGV[2])) {
group-Avnet 0:478cfd88041f 79 if (!exists $not_in_next{$elem->[0]}) {
group-Avnet 0:478cfd88041f 80 if ($msg) {
group-Avnet 0:478cfd88041f 81 print STDERR $msg;
group-Avnet 0:478cfd88041f 82 undef $msg;
group-Avnet 0:478cfd88041f 83 }
group-Avnet 0:478cfd88041f 84 print STDERR " $elem->[1]\n";
group-Avnet 0:478cfd88041f 85 }
group-Avnet 0:478cfd88041f 86 }
group-Avnet 0:478cfd88041f 87 ' "$topic" "$not_in_next" "$not_in_master"
group-Avnet 0:478cfd88041f 88 exit 1
group-Avnet 0:478cfd88041f 89 fi
group-Avnet 0:478cfd88041f 90
group-Avnet 0:478cfd88041f 91 <<\DOC_END
group-Avnet 0:478cfd88041f 92
group-Avnet 0:478cfd88041f 93 This sample hook safeguards topic branches that have been
group-Avnet 0:478cfd88041f 94 published from being rewound.
group-Avnet 0:478cfd88041f 95
group-Avnet 0:478cfd88041f 96 The workflow assumed here is:
group-Avnet 0:478cfd88041f 97
group-Avnet 0:478cfd88041f 98 * Once a topic branch forks from "master", "master" is never
group-Avnet 0:478cfd88041f 99 merged into it again (either directly or indirectly).
group-Avnet 0:478cfd88041f 100
group-Avnet 0:478cfd88041f 101 * Once a topic branch is fully cooked and merged into "master",
group-Avnet 0:478cfd88041f 102 it is deleted. If you need to build on top of it to correct
group-Avnet 0:478cfd88041f 103 earlier mistakes, a new topic branch is created by forking at
group-Avnet 0:478cfd88041f 104 the tip of the "master". This is not strictly necessary, but
group-Avnet 0:478cfd88041f 105 it makes it easier to keep your history simple.
group-Avnet 0:478cfd88041f 106
group-Avnet 0:478cfd88041f 107 * Whenever you need to test or publish your changes to topic
group-Avnet 0:478cfd88041f 108 branches, merge them into "next" branch.
group-Avnet 0:478cfd88041f 109
group-Avnet 0:478cfd88041f 110 The script, being an example, hardcodes the publish branch name
group-Avnet 0:478cfd88041f 111 to be "next", but it is trivial to make it configurable via
group-Avnet 0:478cfd88041f 112 $GIT_DIR/config mechanism.
group-Avnet 0:478cfd88041f 113
group-Avnet 0:478cfd88041f 114 With this workflow, you would want to know:
group-Avnet 0:478cfd88041f 115
group-Avnet 0:478cfd88041f 116 (1) ... if a topic branch has ever been merged to "next". Young
group-Avnet 0:478cfd88041f 117 topic branches can have stupid mistakes you would rather
group-Avnet 0:478cfd88041f 118 clean up before publishing, and things that have not been
group-Avnet 0:478cfd88041f 119 merged into other branches can be easily rebased without
group-Avnet 0:478cfd88041f 120 affecting other people. But once it is published, you would
group-Avnet 0:478cfd88041f 121 not want to rewind it.
group-Avnet 0:478cfd88041f 122
group-Avnet 0:478cfd88041f 123 (2) ... if a topic branch has been fully merged to "master".
group-Avnet 0:478cfd88041f 124 Then you can delete it. More importantly, you should not
group-Avnet 0:478cfd88041f 125 build on top of it -- other people may already want to
group-Avnet 0:478cfd88041f 126 change things related to the topic as patches against your
group-Avnet 0:478cfd88041f 127 "master", so if you need further changes, it is better to
group-Avnet 0:478cfd88041f 128 fork the topic (perhaps with the same name) afresh from the
group-Avnet 0:478cfd88041f 129 tip of "master".
group-Avnet 0:478cfd88041f 130
group-Avnet 0:478cfd88041f 131 Let's look at this example:
group-Avnet 0:478cfd88041f 132
group-Avnet 0:478cfd88041f 133 o---o---o---o---o---o---o---o---o---o "next"
group-Avnet 0:478cfd88041f 134 / / / /
group-Avnet 0:478cfd88041f 135 / a---a---b A / /
group-Avnet 0:478cfd88041f 136 / / / /
group-Avnet 0:478cfd88041f 137 / / c---c---c---c B /
group-Avnet 0:478cfd88041f 138 / / / \ /
group-Avnet 0:478cfd88041f 139 / / / b---b C \ /
group-Avnet 0:478cfd88041f 140 / / / / \ /
group-Avnet 0:478cfd88041f 141 ---o---o---o---o---o---o---o---o---o---o---o "master"
group-Avnet 0:478cfd88041f 142
group-Avnet 0:478cfd88041f 143
group-Avnet 0:478cfd88041f 144 A, B and C are topic branches.
group-Avnet 0:478cfd88041f 145
group-Avnet 0:478cfd88041f 146 * A has one fix since it was merged up to "next".
group-Avnet 0:478cfd88041f 147
group-Avnet 0:478cfd88041f 148 * B has finished. It has been fully merged up to "master" and "next",
group-Avnet 0:478cfd88041f 149 and is ready to be deleted.
group-Avnet 0:478cfd88041f 150
group-Avnet 0:478cfd88041f 151 * C has not merged to "next" at all.
group-Avnet 0:478cfd88041f 152
group-Avnet 0:478cfd88041f 153 We would want to allow C to be rebased, refuse A, and encourage
group-Avnet 0:478cfd88041f 154 B to be deleted.
group-Avnet 0:478cfd88041f 155
group-Avnet 0:478cfd88041f 156 To compute (1):
group-Avnet 0:478cfd88041f 157
group-Avnet 0:478cfd88041f 158 git rev-list ^master ^topic next
group-Avnet 0:478cfd88041f 159 git rev-list ^master next
group-Avnet 0:478cfd88041f 160
group-Avnet 0:478cfd88041f 161 if these match, topic has not merged in next at all.
group-Avnet 0:478cfd88041f 162
group-Avnet 0:478cfd88041f 163 To compute (2):
group-Avnet 0:478cfd88041f 164
group-Avnet 0:478cfd88041f 165 git rev-list master..topic
group-Avnet 0:478cfd88041f 166
group-Avnet 0:478cfd88041f 167 if this is empty, it is fully merged to "master".
group-Avnet 0:478cfd88041f 168
group-Avnet 0:478cfd88041f 169 DOC_END