Generic Pelion Device Management example for various Advantech modules.

This example is known to work great on the following platforms:

Example Functionality

This example showcases the following device functionality:

  • On timer button increment, simulate Pelion LWM2M button resource change

Use this example with Mbed CLI

1. Import the application into your desktop:

mbed import https://os.mbed.com/teams/Advantech/code/pelion-example-common
cd pelion-example-common

2. Download your developer certificate from pelion portal

3. Compile the program

mbed compile -t <toolchain> -m <TARGET_BOARD>

(supported toolchains : GCC_ARM / ARM / IAR)

4. Copy the binary file pelion-example-common.bin to your mbed device.

Committer:
chuanga
Date:
Tue Mar 12 13:48:39 2019 +0800
Revision:
0:43ff9e3bc244
copying sources from github repository

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chuanga 0:43ff9e3bc244 1 /* SPWFSA01 Device
chuanga 0:43ff9e3bc244 2 * Copyright (c) 2015 ARM Limited
chuanga 0:43ff9e3bc244 3 *
chuanga 0:43ff9e3bc244 4 * Licensed under the Apache License, Version 2.0 (the "License");
chuanga 0:43ff9e3bc244 5 * you may not use this file except in compliance with the License.
chuanga 0:43ff9e3bc244 6 * You may obtain a copy of the License at
chuanga 0:43ff9e3bc244 7 *
chuanga 0:43ff9e3bc244 8 * http://www.apache.org/licenses/LICENSE-2.0
chuanga 0:43ff9e3bc244 9 *
chuanga 0:43ff9e3bc244 10 * Unless required by applicable law or agreed to in writing, software
chuanga 0:43ff9e3bc244 11 * distributed under the License is distributed on an "AS IS" BASIS,
chuanga 0:43ff9e3bc244 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
chuanga 0:43ff9e3bc244 13 * See the License for the specific language governing permissions and
chuanga 0:43ff9e3bc244 14 * limitations under the License.
chuanga 0:43ff9e3bc244 15 */
chuanga 0:43ff9e3bc244 16
chuanga 0:43ff9e3bc244 17 #ifndef SPWFSA01_H
chuanga 0:43ff9e3bc244 18 #define SPWFSA01_H
chuanga 0:43ff9e3bc244 19
chuanga 0:43ff9e3bc244 20 #include "mbed.h"
chuanga 0:43ff9e3bc244 21 #include "ATCmdParser.h"
chuanga 0:43ff9e3bc244 22 #include "BlockExecuter.h"
chuanga 0:43ff9e3bc244 23
chuanga 0:43ff9e3bc244 24 #include "./spwfsa01_at_strings.h"
chuanga 0:43ff9e3bc244 25 #include "../SPWFSAxx.h"
chuanga 0:43ff9e3bc244 26
chuanga 0:43ff9e3bc244 27 class SpwfSAInterface;
chuanga 0:43ff9e3bc244 28
chuanga 0:43ff9e3bc244 29 /** SPWFSA01 Interface class.
chuanga 0:43ff9e3bc244 30 This is an interface to a SPWFSA01 module.
chuanga 0:43ff9e3bc244 31 */
chuanga 0:43ff9e3bc244 32 class SPWFSA01 : public SPWFSAxx
chuanga 0:43ff9e3bc244 33 {
chuanga 0:43ff9e3bc244 34 public:
chuanga 0:43ff9e3bc244 35 SPWFSA01(PinName tx, PinName rx,
chuanga 0:43ff9e3bc244 36 PinName rts, PinName cts,
chuanga 0:43ff9e3bc244 37 SpwfSAInterface &ifce, bool debug,
chuanga 0:43ff9e3bc244 38 PinName wakeup, PinName reset);
chuanga 0:43ff9e3bc244 39
chuanga 0:43ff9e3bc244 40 /**
chuanga 0:43ff9e3bc244 41 * Open a socketed connection
chuanga 0:43ff9e3bc244 42 *
chuanga 0:43ff9e3bc244 43 * @param type the type of socket to open "u" (UDP) or "t" (TCP)
chuanga 0:43ff9e3bc244 44 * @param id id to get the new socket number, valid 0-7
chuanga 0:43ff9e3bc244 45 * @param port port to open connection with
chuanga 0:43ff9e3bc244 46 * @param addr the IP address of the destination
chuanga 0:43ff9e3bc244 47 * @return true only if socket opened successfully
chuanga 0:43ff9e3bc244 48 */
chuanga 0:43ff9e3bc244 49 bool open(const char *type, int* id, const char* addr, int port);
chuanga 0:43ff9e3bc244 50
chuanga 0:43ff9e3bc244 51 /** Scan for available networks
chuanga 0:43ff9e3bc244 52 *
chuanga 0:43ff9e3bc244 53 * @param ap Pointer to allocated array to store discovered AP
chuanga 0:43ff9e3bc244 54 * @param limit Size of allocated @a res array, or 0 to only count available AP
chuanga 0:43ff9e3bc244 55 * @return Number of entries in @a res, or if @a count was 0 number of available networks, negative on error
chuanga 0:43ff9e3bc244 56 * see @a nsapi_error
chuanga 0:43ff9e3bc244 57 */
chuanga 0:43ff9e3bc244 58 nsapi_size_or_error_t scan(WiFiAccessPoint *res, unsigned limit);
chuanga 0:43ff9e3bc244 59
chuanga 0:43ff9e3bc244 60 private:
chuanga 0:43ff9e3bc244 61 bool _recv_ap(nsapi_wifi_ap_t *ap);
chuanga 0:43ff9e3bc244 62
chuanga 0:43ff9e3bc244 63 virtual int _read_in(char*, int, uint32_t);
chuanga 0:43ff9e3bc244 64 };
chuanga 0:43ff9e3bc244 65
chuanga 0:43ff9e3bc244 66 #endif // SPWFSA01_H