Custom Channel Plan version of MTDOT Box firmware

Dependencies:   DOGS102 GpsParser ISL29011 MMA845x MPL3115A2 MTS-Serial NCP5623B libmDot-Custom mDot_Channel_Plans

Fork of MTDOT-BOX-EVB-Factory-Firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LayoutSemtechJoin.cpp Source File

LayoutSemtechJoin.cpp

00001 /* Copyright (c) <2016> <MultiTech Systems>, MIT License
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00005  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00006  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00007  * furnished to do so, subject to the following conditions:
00008  *
00009  * The above copyright notice and this permission notice shall be included in all copies or
00010  * substantial portions of the Software.
00011  *
00012  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017  */
00018 
00019 #include "LayoutSemtechJoin.h"
00020 
00021 LayoutSemtechJoin::LayoutSemtechJoin(DOGS102* lcd, uint8_t band)
00022     : Layout(lcd),
00023       _band(band),
00024       _lId(0, 1, "NI="),
00025       _lKey(0, 2, "NK="),
00026       _lFsb(0, 3, "FSB="),
00027       _lRate(0, 5, "DR="),
00028       _lPower(6, 5, "P="),
00029       _lJoin(0, 7, "Join"),
00030       _fId(3, 1, 14),
00031       _fKey(3, 2, 14),
00032       _fFsb(4, 3, 2),
00033       _fRate(3, 5, 2),
00034       _fPower(8, 5, 2),
00035       _fStatus(0, 0, 17),
00036       _fSubBand(16,7,1)
00037 {}
00038 
00039 LayoutSemtechJoin::~LayoutSemtechJoin() {}
00040 
00041 void LayoutSemtechJoin::display()
00042 {
00043     clear();
00044     startUpdate();
00045 
00046     writeLabel(_lId);
00047     writeLabel(_lKey);
00048     writeLabel(_lFsb);    
00049     writeLabel(_lRate);
00050     writeLabel(_lPower);
00051     writeLabel(_lJoin);
00052     
00053     endUpdate();
00054 }
00055 
00056 void LayoutSemtechJoin::updateId(std::string id)
00057 {
00058     writeField(_fId, id, true);
00059 }
00060 
00061 void LayoutSemtechJoin::updateKey(std::string key)
00062 {
00063     writeField(_fKey, key, true);
00064 }
00065 
00066 void LayoutSemtechJoin::updateFsb(uint8_t band)
00067 {
00068     char buf[8];
00069     size_t size;
00070     size = snprintf(buf, sizeof(buf), "%u", band);
00071     writeField(_fFsb, buf, size, true);
00072     writeField(_fSubBand, buf, size, true);
00073 }
00074 
00075 void LayoutSemtechJoin::updateRate(std::string rate)
00076 {
00077     writeField(_fRate, rate, true);
00078 }
00079 
00080 void LayoutSemtechJoin::updatePower(uint32_t power)
00081 {
00082     char buf[16];
00083     size_t size;
00084 
00085     size = snprintf(buf, sizeof(buf), "%lu", power);
00086     writeField(_fPower, buf, size, true);
00087 }