顯示具有 ARM mbed OS 標籤的文章。 顯示所有文章
顯示具有 ARM mbed OS 標籤的文章。 顯示所有文章

2016年11月16日 星期三

ARM mbed 系統架構(1)



 ARM mbed 系統架構, 基本類似於OIC/OCF的參考實作 ,任何sensor或硬體都是以抽象的資源來定義(也就是OIC的Resource Oriented Architecture 的實作架構, 遠端存取這些資源則使用Restful API (採OMA LWM2M的Resource path) 方式, 存取不同的硬體資源, 就是給不同的資源路徑.

物聯網目前協定就是要走IP-Based , 所以基本上不論底層協定是什麼, 如短距離 Bluetooth、Wi-Fi、 Zigbee、 Thread, 或長距離 Cellular 3G/LTE 最終都必須是IP或透過 6LoWPAN介接成IP (IPv4或IPv6).

在應用層協定使用

MQTT、HTTP--> TCP--> TLS (如須加密)
CoAP-->UDP--> DTLS  (如須加密)

其資源描述使用OMA LWM2M的架構, 對資源存取的行為包含CRUDN

C: create
R: read   --> GET
U:update--> PUT
D:delete
N:notify
「arm mbed architecture」的圖片搜尋結果
mbed device (mbed os)


「arm mbed architecture」的圖片搜尋結果
mbed connector service


https://goo.gl/wzIHdR

2016年8月7日 星期日

ARM mbed client Code


What is mbed client?

ARM mbed Client is a library that provides the means to connect constrained embedded devices to mbed Device Connector Service, mbed Device Server and to mbed-enabled cloud services from our partners.


  • Manage devices on mbed Device Server.
  • Securely communicate with internet services over the industry standard TLS/DTLS.
  • Fully control the endpoint and application logic.
class MbedClient: public M2MInterfaceObserver {
public:
    MbedClient(){
        _security = NULL;
        _interface = NULL;    // 產生M2M Interface : M2MInterfaceFactory::create_interface
        _device = NULL;     // 產生Device Object : M2MInterfaceFactory::create_device();
        _object = NULL;    // 產生Resource Object : M2MInterfaceFactory::create_object("Monitor");
_object_gpio = NULL;
        _error = false;
        _registered = false;   //,一旦 M2MObjectList object_registered 成功後, 將 _registered設為true
        _unregistered = false;
        _registration_updated = false;

    }

 ....

}


M2MInterface  --> register_object()          ----callback--> object_register()
                               unregistered_object()  ----callback--> object_unregister()
                               update_registration()    ----callback--> registration_updated()



M2MInterfaceObserver 類別上的5個Callback函式列表

virtual void bootstrap_done (M2MSecurity *server_object)=0
A callback indicating that the bootstap has been performed successfully. More...
virtual void object_registered (M2MSecurity *security_object, const M2MServer &server_object)=0
A callback indicating that the device object has been registered successfully to the LWM2M server. More...
virtual void object_unregistered (M2MSecurity *server_object)=0
A callback indicating that the device object has been successfully unregistered from the LWM2M server. More...
virtual void registration_updated (M2MSecurity *security_object, const M2MServer &server_object)=0
A callback indicating that the device object registration has been successfully updated on the LWM2M server. More...
virtual void error (M2MInterface::Error error)=0
A callback indicating that there was an error during the operation. More...
virtual void value_updated (M2MBase *base, M2MBase::BaseType type)=0
A callback indicating that the value of the resource object is updated by the server.Whenever there is a valid PUT operation for any of the resources, the application will receive a callback:


void error(M2MInterface::Error error){
        _error = true;
        String error_code;
switch(error) {
        case M2MInterface::ErrorNone:
             error_code += "M2MInterface::ErrorNone";
             break;
        case M2MInterface::AlreadyExists:
             error_code += "M2MInterface::AlreadyExists";
             break;

  .....


           }
        printf("\nError occured  : %s\n", error_code.c_str());
    }



There are two types of resources you can create
Dynamic: 值會改變, 當server 請求時要負責傳回值
Static: 值不改變
 configure different types of Objects, Object Instances and Resources 



  • mbed client Document

  1. ARM mbed Client Guide
  2. ARM mbed Client API





2016年7月30日 星期六

Introduction to mbed Device Connector










    


# ARM mbed #IoT # Raspberry Pi 







相關連結:

1)Raspberry Pi 上編譯mbed client http://blog.ittraining.com.tw/2016/06/raspberry-pi-mbed-client.html#links

2) To Deploy mbed IoT cloud
http://blog.ittraining.com.tw/2016/07/to-deploy-mbed-iot-cloud.html

3)ARM mbed cloud server https://connector.mbed.com/ 4)ARM mbed cloud slide http://blog.ittraining.com.tw/2016/08/arm-mbed-client-code.html



艾鍗 ARM mbed GitHub:

ARM mbed Client on Raspberry Pi 3
git clone https://github.com/ntu-joseph/iot_demo.git

ARM mbed Cloud WebAPP
git clone https://github.com/it-robot/mbed-webapp.git



2016年6月28日 星期二

mbed client using Raspberry Pi with IT-Pi Shield



介紹如何利用yotta 工具進行編譯 linux mbed client

what is yotta ? 

  • mbed OS applications as yotta executables 
  • yotta - to build the mbed example programs
  • yotta is a module management system for C++ and C designed to make it easier to build better software by re-using code.
  • yotta uses the CMake build system, and targets describe how the compiler should be run by providing a CMake
  • yotta is written in python, and distributed using pip, the python package manager
  • 利用yotta 可以到yotta 公開的 module registry (http://yotta.mbed.com/)下載 module (即library)來使用. 另外, yotta 目標希望可以用同一份原始碼來編譯出不同平台上的code
     (yotta target <target_name>)  

yottta 工具安裝

成功安裝完必要的dependency後 , 接著進行安裝 yotta

1.) Installing Package Dependencies

sudo apt-get install python-setuptools cmake build-essential ninja-build python-dev 
sudo apt-get install libffi-dev 
sudo apt-get install libssl-dev
sudo easy_install pip

2) Installing yotta

sudo pip install yotta     //wait and pray......


問題排除 

如果按照上面步驟,安裝yotta, 套件找不到情況, 建立virtualenv , 解決python 相依套件的問題

Installing in a Virtualenv


Virtualenv is a way of separating different python programs installed on the same system from each other. If you have a complex python environment on your system it’s recommended that you install yotta inside a virtualenv. 

  1. Ensure you have virtualenv itself installed. It can be installed with:
    pip install virtualenv
    
    Check that your installation is succesful by running virtualenv --version.
  2. Create a directory to use for the yotta virtualenv:
    mkdir yotta-venv
    virtualenv ./yotta-venv
    
  3. activate the new virtualenv:
    source ./yotta-venv/bin/activate
    
  4. install yotta in the virtualenv:
    pip install yotta
    
  5. (optional) add the binary directory of your virtualenv to your PATH: (if you omit this step, you will need to run yotta as../path/to/yotta-venv/bin/yotta instead of simply yotta.
    export PATH="/path/to/yotta-venv/bin:$PATH"
    
Now yotta should work as normal. You will need to activate the virtualenv any time you want to run yotta commands (you can deactivate it afterwards, by simply running deactivate).

Yotta 成功安裝畫面

 編譯 mbed client linux Source 

 made sure you have installed yotta and all necessary toolchains.

  1. In the command prompt, go to mbed-client-linux-example.
  2. Set up the application with correct Certificate and Domain:
    B. Go to My devices -> Security credentials.
    C. Click GET MY DEVICE SECURITY CREDENTIALS. You will get the needed certificate information as well as the endpoint name and domain.
    D. Copy the security credentials to source/security.h.
  3. In the command prompt, type yotta target arm-linux-native to set up the target device., 這裡會產生出資料匣 build/arm-linux-native
  4. In the command prompt, type yotta build. The executable file will be created in the folder build/arm-linux-native/source/.

    (yotta build -d: 可加入debug 訊息輸出)
編譯code 時會去pubic repository 下載module , 故要求驗證身份

5. In the folder mbed-client-linux-example/build/arm-linux-native/source/, run the executable from the command line, type ./mbed-client-linux-example.

         6. 若要將整個project 清空: 執行 yotta clean


The build process (what is ninja?)



---------------------
參考文件

2016年4月14日 星期四

Seeed Arch Link 板子介紹

Seeed Arch Link

Arch Link is an mbed enabled development board based on Nordic nRF51822 and WIZnet W5500 ethernet interface. With Arduino form factor, Grove connectors and micro SD interface, it is extremely easy to create a bluetooth low energy device.



/media/uploads/JackyZhangFromSeeed/arch_link_pinout_a_20150602.png

什麼是CMSIS-DAP?


  簡單說, CMSIS-DAP 就是長出一個USB Flash disk , 可以用拖曳檔案到flash disk , 即是進行傳輸firmware到板子上的動作(upgrade firmware。  Windows 上出現隨身碟USB MSC界面,並不代表這是一個真實的file system, 可以用來儲存/更新檔案資料。DAP 就是Debug Access Port,只是以隨身碟的面貌存在於系統。

  • The CMSIS-DAP Interface is a microcontroller based single chip solution that provides, Drag and Drop programming, CMSIS-DAP debugger and USB serial interface to a range of Cortex-M based microcontrollers.
  • DAP over JTAG or SWD
  • The mbed HDK and mbed-enabled hardware support the CMSIS-DAP debug interface, which consists of an abstraction of the Cortex Debug Access Port (DAP) command set over a driver-less USB HID connection.
  • USB Serial interface between the host computer and the target
  • Packets are exchanged between the host debugger and the Interface Chip. Basically, the host sends a command and the debug unit sends the response of the command. 
  • The firmware that supports CMSIS-DAP for your target and an offline tool that support CMSIS-DAP - Keil MDK v4.60 for example

Notes on JTAG and SWD

JTAG (Joint Test Action Group) : 5 pin
SWD ((Serial Wire Debug): 2 pin
Serial Wire Debug technology is available as part of the CoreSight™ Debug Access Port and provides a 2-pin debug port, the low pin count and high-performance alternative to JTAG.
SWD 可以完全用來取代JTAG, 原本JTAG 的5 pin中的TMS and TCK pins, 就是SWD的SWDIO and SWCLK,


/media/uploads/samux/cmsis-dap-6.png




/media/uploads/emilmont/board.png
When the Onboard Interface ( LPC11U35 or KL25Z,..) is plugged to an host PC it enumerates as a composite device with the following interfaces:
  • MSD, mass storage device class
  • CDC, communications device class
  • HID, human interface device class
It is connected to the following pins of the target microcontroller:
  • SWD + Reset
  • UART
  • Sleep and Wake (Not currently implemented, reserved for future use)
/media/uploads/emilmont/interface.png
參考: 



2016年1月9日 星期六

CMSIS-RTOS API



CMSIS-RTOS它是一種作業系統軟體設計架構,  藉由CMSIS RTOS的架構可以用來隠藏底層不同作業系統的差異性。上層應用程式要想利用到OS提供的功能時, CMSIS RTOS 提供一個標準的API供上層來呼叫使用,這個API就如同Linux System call概念一樣。(The CMSIS-RTOS API is a generic RTOS interface for ARM® Cortex®-M processor-based devices)

CMSIS-RTOS 的API界面提作為底層 Real Time kernel (RTOS)與上層應用程式的一個標準介面,並使用一套標準的API, 如此可以讓上層程式不用管底層RTOS的差異, 如此程式碼可以跑在不用RTOS上, 也縮短學習新的RTOS的曲線。

不同RTOS都各自實現自己關於多工處理,例如排程、記憶體管理等功能,但希望有中介層界面存在,使用RTOS API 不必再管底層RTOS是那一套,所有函式呼叫都相同。而CMSIS-RTOS 正是一種基於 ARM® Cortex®-M processor-based 的RTOS中介層界面。


API_Structure.png