zcl_se.c 324 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669
  1. /**************************************************************************************************
  2. Filename: zcl_se.c
  3. Revised: $Date: 2012-03-11 00:25:21 -0800 (Sun, 11 Mar 2012) $
  4. Revision: $Revision: 29708 $
  5. Description: Zigbee Cluster Library - SE (Smart Energy) Profile.
  6. Copyright 2007-2012 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. /*********************************************************************
  34. * INCLUDES
  35. */
  36. #include "ZComDef.h"
  37. #include "OSAL.h"
  38. #include "zcl.h"
  39. #include "zcl_general.h"
  40. #include "zcl_se.h"
  41. #include "DebugTrace.h"
  42. #if defined ( INTER_PAN )
  43. #include "stub_aps.h"
  44. #endif
  45. #include "zcl_key_establish.h"
  46. /*********************************************************************
  47. * MACROS
  48. */
  49. // Clusters that are supported thru Inter-PAN communication
  50. #define INTER_PAN_CLUSTER( id ) ( (id) == ZCL_CLUSTER_ID_SE_PRICING || \
  51. (id) == ZCL_CLUSTER_ID_SE_MESSAGE )
  52. /*********************************************************************
  53. * CONSTANTS
  54. */
  55. /*********************************************************************
  56. * TYPEDEFS
  57. */
  58. typedef struct zclSECBRec
  59. {
  60. struct zclSECBRec *next;
  61. uint8 endpoint; // Used to link it into the endpoint descriptor
  62. zclSE_AppCallbacks_t *CBs; // Pointer to Callback function
  63. } zclSECBRec_t;
  64. /*********************************************************************
  65. * GLOBAL VARIABLES
  66. */
  67. /*********************************************************************
  68. * GLOBAL FUNCTIONS
  69. */
  70. /*********************************************************************
  71. * LOCAL VARIABLES
  72. */
  73. static zclSECBRec_t *zclSECBs = (zclSECBRec_t *)NULL;
  74. static uint8 zclSEPluginRegisted = FALSE;
  75. /*********************************************************************
  76. * LOCAL FUNCTIONS
  77. */
  78. static ZStatus_t zclSE_HdlIncoming( zclIncoming_t *pInMsg );
  79. static ZStatus_t zclSE_HdlInSpecificCommands( zclIncoming_t *pInMsg );
  80. #ifdef ZCL_SIMPLE_METERING
  81. static ZStatus_t zclSE_ProcessInSimpleMeteringCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  82. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_GetProfileCmd( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  83. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_GetProfileRsp( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  84. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_ReqMirrorCmd( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  85. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_ReqMirrorRsp( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  86. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_MirrorRemCmd( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  87. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_MirrorRemRsp( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  88. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_ReqFastPollModeCmd( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  89. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_ReqFastPollModeRsp( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  90. #ifdef SE_UK_EXT
  91. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_GetSnapshotCmd( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  92. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_GetSnapshotRsp( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  93. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_TakeSnapshotCmd( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  94. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_MirrorReportAttrRsp( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  95. #endif // SE_UK_EXT
  96. #endif // ZCL_SIMPLE_METERING
  97. #ifdef ZCL_PRICING
  98. static ZStatus_t zclSE_ProcessInPricingCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  99. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetCurrentPrice( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  100. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetScheduledPrice( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  101. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishPrice( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  102. static ZStatus_t zclSE_ProcessInCmd_Pricing_PriceAcknowledgement( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  103. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetBlockPeriod( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  104. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishBlockPeriod( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  105. #ifdef SE_UK_EXT
  106. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishTariffInformation( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  107. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishPriceMatrix( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  108. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishBlockThreshold( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  109. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishConversionFactor( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  110. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishCalorificValue( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  111. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishCO2Value( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  112. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishCPPEvent( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  113. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishBillingPeriod( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  114. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishConsolidatedBill( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  115. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishCreditPaymentInfo( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  116. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetTariffInformation( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  117. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetPriceMatrix( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  118. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetBlockThresholds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  119. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetConversionFactor( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  120. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetCalorificValue( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  121. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetCO2Value( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  122. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetBillingPeriod( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  123. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetConsolidatedBill( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  124. static ZStatus_t zclSE_ProcessInCmd_Pricing_CPPEventResponse( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  125. #endif // SE_UK_EXT
  126. #endif // ZCL_PRICING
  127. #ifdef ZCL_MESSAGE
  128. static ZStatus_t zclSE_ProcessInMessageCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  129. static ZStatus_t zclSE_ProcessInCmd_Message_DisplayMessage( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  130. static ZStatus_t zclSE_ProcessInCmd_Message_CancelMessage( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  131. static ZStatus_t zclSE_ProcessInCmd_Message_GetLastMessage( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  132. static ZStatus_t zclSE_ProcessInCmd_Message_MessageConfirmation( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  133. #endif // ZCL_MESSAGE
  134. #ifdef ZCL_LOAD_CONTROL
  135. static ZStatus_t zclSE_ProcessInLoadControlCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  136. static ZStatus_t zclSE_ProcessInCmd_LoadControl_LoadControlEvent( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  137. static ZStatus_t zclSE_ProcessInCmd_LoadControl_CancelLoadControlEvent( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  138. static ZStatus_t zclSE_ProcessInCmd_LoadControl_CancelAllLoadControlEvents( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  139. static ZStatus_t zclSE_ProcessInCmd_LoadControl_ReportEventStatus( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  140. static ZStatus_t zclSE_ProcessInCmd_LoadControl_GetScheduledEvents( zclIncoming_t *pInMsg,
  141. zclSE_AppCallbacks_t *pCBs );
  142. #endif // ZCL_LOAD_CONTROL
  143. #ifdef ZCL_TUNNELING
  144. static ZStatus_t zclSE_ProcessInTunnelingCmds(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  145. static ZStatus_t zclSE_ProcessInCmd_Tunneling_RequestTunnel(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  146. static ZStatus_t zclSE_ProcessInCmd_Tunneling_ReqTunnelRsp(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  147. static ZStatus_t zclSE_ProcessInCmd_Tunneling_CloseTunnel(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  148. static ZStatus_t zclSE_ProcessInCmd_Tunneling_TransferData(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  149. static ZStatus_t zclSE_ProcessInCmd_Tunneling_TransferDataError(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  150. static ZStatus_t zclSE_ProcessInCmd_Tunneling_AckTransferData(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  151. static ZStatus_t zclSE_ProcessInCmd_Tunneling_ReadyData(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  152. #ifdef SE_UK_EXT
  153. static ZStatus_t zclSE_ProcessInCmd_Tunneling_GetSuppTunnelProt(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  154. static ZStatus_t zclSE_ProcessInCmd_Tunneling_SuppTunnelProtRsp(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  155. static ZStatus_t zclSE_ProcessInCmd_Tunneling_TunnelClosureNotification(zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  156. #endif // SE_UK_EXT
  157. #endif // ZCL_TUNNELING
  158. #ifdef ZCL_PREPAYMENT
  159. static ZStatus_t zclSE_ProcessInPrepaymentCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  160. static ZStatus_t zclSE_ProcessInCmd_Prepayment_SelAvailEmergencyCredit( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs);
  161. #ifndef SE_UK_EXT
  162. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ChangeSupply( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  163. static ZStatus_t zclSE_ProcessInCmd_Prepayment_SupplyStatusResponse( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  164. #else // SE_UK_EXT
  165. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ChangeDebt( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  166. static ZStatus_t zclSE_ProcessInCmd_Prepayment_EmergencyCreditSetup( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  167. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ConsumerTopup( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  168. static ZStatus_t zclSE_ProcessInCmd_Prepayment_CreditAdjustment( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  169. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ChangePaymentMode( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  170. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetPrepaySnapshot( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  171. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetTopupLog( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  172. static ZStatus_t zclSE_ProcessInCmd_Prepayment_SetLowCreditWarningLevel( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  173. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetDebtRepaymentLog( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  174. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetPrepaySnapshotResponse( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  175. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ChangePaymentModeResponse( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  176. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ConsumerTopupResponse( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  177. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetCommands( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  178. static ZStatus_t zclSE_ProcessInCmd_Prepayment_PublishTopupLog( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  179. static ZStatus_t zclSE_ProcessInCmd_Prepayment_PublishDebtLog( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  180. #endif // SE_UK_EXT
  181. #endif // ZCL_PREPAYMENT
  182. #ifdef ZCL_TOU
  183. #ifdef SE_UK_EXT
  184. static ZStatus_t zclSE_ProcessInTouCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  185. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishCalendar( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  186. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishDayProfile( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  187. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishWeekProfile( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  188. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishSeasons( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  189. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishSpecialDays( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  190. static ZStatus_t zclSE_ProcessInCmd_Tou_GetCalendar( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  191. static ZStatus_t zclSE_ProcessInCmd_Tou_GetDayProfiles( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  192. static ZStatus_t zclSE_ProcessInCmd_Tou_GetWeekProfiles( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  193. static ZStatus_t zclSE_ProcessInCmd_Tou_GetSeasons( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  194. static ZStatus_t zclSE_ProcessInCmd_Tou_GetSpecialDays( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  195. #endif // SE_UK_EXT
  196. #endif // ZCL_TOU
  197. #ifdef ZCL_DEVICE_MGMT
  198. #ifdef SE_UK_EXT
  199. static ZStatus_t zclSE_ProcessInDeviceMgmtCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  200. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_GetChangeTenancy( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  201. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_GetChangeSupplier( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  202. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_GetChangeSupply( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  203. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_SupplyStatusResponse( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  204. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_GetPassword( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  205. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_PublishChangeTenancy( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  206. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_PublishChangeSupplier( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  207. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_ChangeSupply( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  208. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_ChangePassword( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  209. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_LocalChangeSupply( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs );
  210. #endif // SE_UK_EXT
  211. #endif // ZCL_DEVICE_MGMT
  212. #ifdef SE_UK_EXT
  213. static uint8 zclSE_Parse_UTF8String( uint8 *pBuf, UTF8String_t *pString, uint8 maxLen );
  214. #endif // SE_UK_EXT
  215. #ifdef ZCL_SIMPLE_METERING
  216. /*********************************************************************
  217. * @fn zclSE_SimpleMetering_Send_GetProfileCmd
  218. *
  219. * @brief Call to send out a Get Profile Command
  220. *
  221. * @param srcEP - Sending application's endpoint
  222. * @param dstAddr - where you want the message to go
  223. * @param channel - returned inteval (delivered @ 0; received @ 1)
  224. * @param endTime - UTC time for the starting time of requested interval
  225. * @param numOfPeriods - number of periods requested
  226. * @param disableDefaultRsp - disable default response
  227. * @param seqNum - ZCL sequence number
  228. *
  229. * @return ZStatus_t
  230. */
  231. ZStatus_t zclSE_SimpleMetering_Send_GetProfileCmd( uint8 srcEP, afAddrType_t *dstAddr,
  232. uint8 channel, uint32 endTime, uint8 numOfPeriods,
  233. uint8 disableDefaultRsp, uint8 seqNum )
  234. {
  235. uint8 buf[6];
  236. buf[0] = channel;
  237. osal_buffer_uint32( &buf[1], endTime );
  238. buf[5] = numOfPeriods;
  239. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  240. COMMAND_SE_GET_PROFILE_CMD, TRUE,
  241. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 6, buf );
  242. }
  243. /*********************************************************************
  244. * @fn zclSE_SimpleMetering_Send_GetProfileRsp
  245. *
  246. * @brief Call to send out a Get Profile Response
  247. *
  248. * @param srcEP - Sending application's endpoint
  249. * @param dstAddr - where you want the message to go
  250. * @param endTime - UTC time for the starting time of requested interval
  251. * @param intervals - data buffer holding an array of interval data captured
  252. * using the period
  253. * specified by the ProfileIntervalPeriod attribute. Data is organized
  254. * in a reverse chronological order, the most recent interval is
  255. * transmitted first and the oldest interval is transmitted last.
  256. * Invalid intervals intervals should be marked as 0xFFFFFF
  257. * @param len - length of the intervals buffer
  258. * @param disableDefaultRsp - disable default response
  259. * @param seqNum - ZCL sequence number
  260. *
  261. * @return ZStatus_t
  262. */
  263. ZStatus_t zclSE_SimpleMetering_Send_GetProfileRsp( uint8 srcEP, afAddrType_t *dstAddr,
  264. uint32 endTime, uint8 rspStatus, uint8 profileIntervalPeriod,
  265. uint8 numOfPeriodDelivered, uint24 *intervals,
  266. uint8 disableDefaultRsp, uint8 seqNum )
  267. {
  268. uint8 *buf;
  269. uint8 *pBuf;
  270. uint8 i;
  271. uint8 len;
  272. ZStatus_t status;
  273. // endTime + status + profileIntervalPeriod + numOfEntry + array
  274. len = 4 + 1 + 1 + 1 + (3 * numOfPeriodDelivered);
  275. buf = osal_mem_alloc( len );
  276. if ( buf == NULL )
  277. {
  278. return ( ZMemError );
  279. }
  280. osal_buffer_uint32( buf, endTime );
  281. buf[4] = rspStatus;
  282. buf[5] = profileIntervalPeriod;
  283. // Starting of the array of uint24
  284. buf[6] = numOfPeriodDelivered; // Number of entries in the array
  285. pBuf = &buf[7];
  286. for ( i = 0; i < numOfPeriodDelivered; i++ )
  287. {
  288. pBuf = osal_buffer_uint24( pBuf, *intervals++ );
  289. }
  290. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  291. COMMAND_SE_GET_PROFILE_RSP, TRUE,
  292. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum, len, buf );
  293. osal_mem_free( buf );
  294. return status;
  295. }
  296. /*********************************************************************
  297. * @fn zclSE_SimpleMetering_Send_ReqMirrorRsp
  298. *
  299. * @brief Call to send out a Request Mirror Response
  300. *
  301. * @param srcEP - Sending application's endpoint
  302. * @param dstAddr - where you want the message to go
  303. *
  304. * @return ZStatus_t
  305. */
  306. ZStatus_t zclSE_SimpleMetering_Send_ReqMirrorRsp( uint8 srcEP, afAddrType_t *dstAddr,
  307. uint16 endpointId,
  308. uint8 disableDefaultRsp, uint8 seqNum )
  309. {
  310. ZStatus_t status;
  311. uint8 buf[2];
  312. buf[0] = (uint8) endpointId ;
  313. buf[1] = (uint8)( endpointId >> 8 );
  314. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  315. COMMAND_SE_REQ_MIRROR_RSP, TRUE,
  316. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 2, buf );
  317. return status ;
  318. }
  319. /*********************************************************************
  320. * @fn zclSE_SimpleMetering_Send_RemMirrorRsp
  321. *
  322. * @brief Call to send out a Remove Mirror Response
  323. *
  324. * @param srcEP - Sending application's endpoint
  325. * @param dstAddr - where you want the message to go
  326. *
  327. * @return ZStatus_t
  328. */
  329. ZStatus_t zclSE_SimpleMetering_Send_RemMirrorRsp( uint8 srcEP, afAddrType_t *dstAddr,
  330. uint16 endpointId,
  331. uint8 disableDefaultRsp, uint8 seqNum )
  332. {
  333. ZStatus_t status;
  334. uint8 buf[2];
  335. buf[0] = (uint8) endpointId ;
  336. buf[1] = (uint8)( endpointId >> 8 );
  337. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  338. COMMAND_SE_MIRROR_REM_RSP, TRUE,
  339. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 2, buf );
  340. return status ;
  341. }
  342. /*********************************************************************
  343. * @fn zclSE_SimpleMetering_Send_ReqFastPollModeCmd
  344. *
  345. * @brief Call to send out a Request Fast Poll Mode Command
  346. *
  347. * @param srcEP - Sending application's endpoint
  348. * @param dstAddr - where you want the message to go
  349. * @param pCmd - zclCCReqFastPollModeCmd_t command
  350. * @param disableDefaultRsp - disable default response
  351. * @param seqNum - ZCL sequence number
  352. *
  353. * @return ZStatus_t
  354. */
  355. ZStatus_t zclSE_SimpleMetering_Send_ReqFastPollModeCmd( uint8 srcEP, afAddrType_t *dstAddr,
  356. zclCCReqFastPollModeCmd_t *pCmd,
  357. uint8 disableDefaultRsp, uint8 seqNum )
  358. {
  359. ZStatus_t status;
  360. uint8 buf[PACKET_LEN_SE_METERING_FAST_POLLING_REQ];
  361. buf[0] = pCmd->fastPollUpdatePeriod;
  362. buf[1] = pCmd->duration;
  363. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  364. COMMAND_SE_REQ_FAST_POLL_MODE_CMD, TRUE,
  365. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum,
  366. PACKET_LEN_SE_METERING_FAST_POLLING_REQ, buf );
  367. return status ;
  368. }
  369. /*********************************************************************
  370. * @fn zclSE_SimpleMetering_Send_ReqFastPollModeRsp
  371. *
  372. * @brief Call to send out a Request Fast Poll Mode Response
  373. *
  374. * @param srcEP - Sending application's endpoint
  375. * @param dstAddr - where you want the message to go
  376. * @param pCmd - zclCCReqFastPollModeRsp_t command
  377. * @param disableDefaultRsp - disable default response
  378. * @param seqNum - ZCL sequence number
  379. *
  380. * @return ZStatus_t
  381. */
  382. ZStatus_t zclSE_SimpleMetering_Send_ReqFastPollModeRsp( uint8 srcEP, afAddrType_t *dstAddr,
  383. zclCCReqFastPollModeRsp_t *pCmd,
  384. uint8 disableDefaultRsp, uint8 seqNum )
  385. {
  386. ZStatus_t status;
  387. uint8 buf[PACKET_LEN_SE_METERING_FAST_POLLING_RSP];
  388. buf[0] = pCmd->appliedUpdatePeriod;
  389. osal_buffer_uint32( &buf[1], pCmd->fastPollModeEndTime );
  390. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  391. COMMAND_SE_REQ_FAST_POLL_MODE_RSP, TRUE,
  392. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum,
  393. PACKET_LEN_SE_METERING_FAST_POLLING_RSP, buf );
  394. return status ;
  395. }
  396. #ifdef SE_UK_EXT
  397. /*********************************************************************
  398. * @fn zclSE_SimpleMetering_Send_GetSnapshotCmd
  399. *
  400. * @brief Call to send out a Get Snapshot Command
  401. *
  402. * @param srcEP - Sending application's endpoint
  403. * @param dstAddr - where you want the message to go
  404. * @param pCmd - zclCCReqGetSnapshotCmd_t command
  405. * @param disableDefaultRsp - disable default response
  406. * @param seqNum - ZCL sequence number
  407. *
  408. * @return ZStatus_t
  409. */
  410. ZStatus_t zclSE_SimpleMetering_Send_GetSnapshotCmd( uint8 srcEP, afAddrType_t *dstAddr,
  411. zclCCReqGetSnapshotCmd_t *pCmd,
  412. uint8 disableDefaultRsp, uint8 seqNum )
  413. {
  414. ZStatus_t status;
  415. uint8 buf[PACKET_LEN_SE_GET_SNAPSHOT_CMD];
  416. osal_buffer_uint32( &buf[0], pCmd->StartTime );
  417. buf[4] = pCmd->NumberOfSnapshots;
  418. buf[5] = LO_UINT16( pCmd->SnapshotCause );
  419. buf[6] = HI_UINT16( pCmd->SnapshotCause );
  420. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  421. COMMAND_SE_GET_SNAPSHOT_CMD, TRUE,
  422. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum,
  423. PACKET_LEN_SE_GET_SNAPSHOT_CMD, buf );
  424. return status;
  425. }
  426. /*********************************************************************
  427. * @fn zclSE_SimpleMetering_Send_GetSnapshotRsp
  428. *
  429. * @brief Call to send out a Get Snapshot Response
  430. *
  431. * @param srcEP - Sending application's endpoint
  432. * @param dstAddr - where you want the message to go
  433. * @param pCmd - zclCCReqGetSnapshotRsp_t command
  434. * @param disableDefaultRsp - disable default response
  435. * @param seqNum - ZCL sequence number
  436. *
  437. * @return ZStatus_t
  438. */
  439. ZStatus_t zclSE_SimpleMetering_Send_GetSnapshotRsp( uint8 srcEP, afAddrType_t *dstAddr,
  440. zclCCReqGetSnapshotRsp_t *pCmd,
  441. uint8 disableDefaultRsp, uint8 seqNum )
  442. {
  443. uint8 *buf;
  444. uint8 *pBuf;
  445. uint16 bufLen;
  446. ZStatus_t status;
  447. uint16 payloadLen;
  448. if ( pCmd->pSnapshotPayload )
  449. {
  450. switch( pCmd->SnapshotPayloadType )
  451. {
  452. case SE_SNAPSHOT_TYPE_CSD_AND_RCV_REGISTER:
  453. payloadLen = SE_SNAPSHOT_CSD_AND_RCV_REGISTER_PAYLOAD_LEN;
  454. break;
  455. case SE_SNAPSHOT_TYPE_TOU_INFO_RECEIVED:
  456. case SE_SNAPSHOT_TYPE_TOU_INFO_DELIVERED:
  457. // Len in Bytes = (uint8) + (NumberOfTiersInUse * (48BitIntegers))
  458. payloadLen = 1 + (pCmd->pSnapshotPayload[0] * 6);
  459. break;
  460. case SE_SNAPSHOT_TYPE_BLOCK_INFO_RECEIVED:
  461. case SE_SNAPSHOT_TYPE_BLOCK_INFO_DELIVERED:
  462. // Len in Bytes = (uint8) + (NumberOfTiersAndBlockThresholdsInUse * (32BitIntegers))
  463. payloadLen = 1 + (pCmd->pSnapshotPayload[0] * 4);
  464. break;
  465. default:
  466. return ZInvalidParameter;
  467. }
  468. bufLen = PACKET_LEN_SE_GET_SNAPSHOT_RSP + payloadLen;
  469. buf = osal_mem_alloc( bufLen );
  470. if ( buf == NULL )
  471. {
  472. return ( ZMemError );
  473. }
  474. pBuf = osal_buffer_uint32( buf, pCmd->IssuerEventID );
  475. pBuf = osal_buffer_uint32( pBuf, pCmd->SnapshotTime );
  476. *pBuf++ = pCmd->CommandIndex;
  477. *pBuf++ = LO_UINT16( pCmd->SnapshotCause );
  478. *pBuf++ = HI_UINT16( pCmd->SnapshotCause );
  479. *pBuf++ = pCmd->SnapshotPayloadType;
  480. osal_memcpy(pBuf, pCmd->pSnapshotPayload, payloadLen);
  481. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  482. COMMAND_SE_GET_SNAPSHOT_RSP, TRUE,
  483. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum,
  484. bufLen, buf );
  485. osal_mem_free( buf );
  486. return status;
  487. }
  488. else
  489. {
  490. return ZInvalidParameter;
  491. }
  492. }
  493. /*********************************************************************
  494. * @fn zclSE_SimpleMetering_Send_TakeSnapshot
  495. *
  496. * @brief Call to send out a Take Snapshot
  497. *
  498. * @param srcEP - Sending application's endpoint
  499. * @param dstAddr - where you want the message to go
  500. * @param disableDefaultRsp - disable default response
  501. * @param seqNum - ZCL sequence number
  502. *
  503. * @return ZStatus_t
  504. */
  505. ZStatus_t zclSE_SimpleMetering_Send_TakeSnapshot( uint8 srcEP, afAddrType_t *dstAddr,
  506. uint8 disableDefaultRsp, uint8 seqNum )
  507. {
  508. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  509. COMMAND_SE_TAKE_SNAPSHOT_CMD, TRUE,
  510. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum,
  511. 0, NULL );
  512. }
  513. /*********************************************************************
  514. * @fn zclSE_SimpleMetering_Send_MirrorReportAttrRsp
  515. *
  516. * @brief Call to send out a Mirror Report Attribute Response
  517. *
  518. * @param srcEP - Sending application's endpoint
  519. * @param dstAddr - where you want the message to go
  520. * @param pCmd - zclCCReqMirrorReportAttrRsp_t command
  521. * @param disableDefaultRsp - disable default response
  522. * @param seqNum - ZCL sequence number
  523. *
  524. * @return ZStatus_t
  525. */
  526. ZStatus_t zclSE_SimpleMetering_Send_MirrorReportAttrRsp( uint8 srcEP, afAddrType_t *dstAddr,
  527. zclCCReqMirrorReportAttrRsp_t *pCmd,
  528. uint8 disableDefaultRsp, uint8 seqNum )
  529. {
  530. ZStatus_t status;
  531. uint8 buf[PACKET_LEN_SE_MIRROR_REPORT_ATTR_RSP];
  532. buf[0] = pCmd->NotificationFlags;
  533. buf[1] = LO_UINT16( pCmd->PriceNotificationFlags );
  534. buf[2] = HI_UINT16( pCmd->PriceNotificationFlags );
  535. buf[3] = pCmd->CalendarNotificationFlags;
  536. buf[4] = LO_UINT16( pCmd->PrePayNotificationFlags );
  537. buf[5] = HI_UINT16( pCmd->PrePayNotificationFlags );
  538. buf[6] = pCmd->DeviceMgmtNotificationFlags;
  539. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  540. COMMAND_SE_MIRROR_REPORT_ATTR_RSP, TRUE,
  541. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum,
  542. PACKET_LEN_SE_MIRROR_REPORT_ATTR_RSP, buf );
  543. return status;
  544. }
  545. #endif // SE_UK_EXT
  546. #endif // ZCL_SIMPLE_METERING
  547. #ifdef ZCL_PRICING
  548. /*********************************************************************
  549. * @fn zclSE_Pricing_Send_GetScheduledPrice
  550. *
  551. * @brief Call to send out a Get Scheduled Price Command
  552. *
  553. * @param srcEP - Sending application's endpoint
  554. * @param dstAddr - where you want the message to go
  555. * @param pCmd - command payload
  556. * @param disableDefaultRsp - disable default response
  557. * @param seqNum - ZCL sequence number
  558. *
  559. * @return ZStatus_t
  560. */
  561. ZStatus_t zclSE_Pricing_Send_GetScheduledPrice( uint8 srcEP, afAddrType_t *dstAddr,
  562. zclCCGetScheduledPrice_t *pCmd,
  563. uint8 disableDefaultRsp, uint8 seqNum )
  564. {
  565. uint8 buf[5];
  566. ZStatus_t status;
  567. osal_buffer_uint32( buf, pCmd->startTime );
  568. buf[4] = pCmd->numEvents;
  569. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  570. COMMAND_SE_GET_SCHEDULED_PRICE, TRUE,
  571. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  572. seqNum, 5, buf );
  573. return status;
  574. }
  575. /*********************************************************************
  576. * @fn zclSE_Pricing_Send_PublishPrice
  577. *
  578. * @brief Call to send out a Publish Price Command
  579. *
  580. * @param srcEP - Sending application's endpoint
  581. * @param dstAddr - where you want the message to go
  582. * @param pCmd - command payload
  583. * @param disableDefaultRsp - disable default response
  584. * @param seqNum - ZCL sequence number
  585. *
  586. * @return ZStatus_t
  587. */
  588. ZStatus_t zclSE_Pricing_Send_PublishPrice( uint8 srcEP, afAddrType_t *dstAddr,
  589. zclCCPublishPrice_t *pCmd,
  590. uint8 disableDefaultRsp, uint8 seqNum )
  591. {
  592. uint8 *buf;
  593. uint8 *pBuf;
  594. uint16 bufLen;
  595. ZStatus_t status;
  596. bufLen = PACKET_LEN_SE_PUBLISH_PRICE + pCmd->rateLabel.strLen;
  597. buf = osal_mem_alloc( bufLen );
  598. if ( buf == NULL )
  599. {
  600. return ( ZMemError );
  601. }
  602. pBuf = osal_buffer_uint32( buf, pCmd->providerId );
  603. *pBuf++ = pCmd->rateLabel.strLen;
  604. pBuf = osal_memcpy( pBuf, pCmd->rateLabel.pStr, pCmd->rateLabel.strLen );
  605. pBuf = osal_buffer_uint32( pBuf, pCmd->issuerEventId );
  606. pBuf = osal_buffer_uint32( pBuf, pCmd->currentTime );
  607. *pBuf++ = pCmd->unitOfMeasure;
  608. *pBuf++ = LO_UINT16( pCmd->currency );
  609. *pBuf++ = HI_UINT16( pCmd->currency );
  610. *pBuf++ = pCmd->priceTrailingDigit;
  611. *pBuf++ = pCmd->numberOfPriceTiers;
  612. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  613. *pBuf++ = LO_UINT16( pCmd->durationInMinutes );
  614. *pBuf++ = HI_UINT16( pCmd->durationInMinutes );
  615. pBuf = osal_buffer_uint32( pBuf, pCmd->price );
  616. *pBuf++ = pCmd->priceRatio;
  617. pBuf = osal_buffer_uint32( pBuf, pCmd->generationPrice );
  618. *pBuf++ = pCmd->generationPriceRatio;
  619. pBuf = osal_buffer_uint32( pBuf, pCmd->alternateCostDelivered );
  620. *pBuf++ = pCmd->alternateCostUnit;
  621. *pBuf++ = pCmd->alternateCostTrailingDigit;
  622. *pBuf++ = pCmd->numberOfBlockThresholds;
  623. *pBuf = pCmd->priceControl;
  624. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  625. COMMAND_SE_PUBLISH_PRICE, TRUE,
  626. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  627. seqNum, bufLen, buf );
  628. osal_mem_free( buf );
  629. return status;
  630. }
  631. /*********************************************************************
  632. * @fn zclSE_Pricing_Send_PriceAcknowledgement
  633. *
  634. * @brief Call to send out a Price Acknowledgement
  635. *
  636. * @param srcEP - Sending application's endpoint
  637. * @param dstAddr - where you want the message to go
  638. * @param pCmd - command payload
  639. * @param disableDefaultRsp - disable default response
  640. * @param seqNum - ZCL sequence number
  641. *
  642. * @return ZStatus_t
  643. */
  644. ZStatus_t zclSE_Pricing_Send_PriceAcknowledgement( uint8 srcEP, afAddrType_t *dstAddr,
  645. zclCCPriceAcknowledgement_t *pCmd,
  646. uint8 disableDefaultRsp, uint8 seqNum )
  647. {
  648. uint8 *buf;
  649. uint8 *pBuf;
  650. ZStatus_t status;
  651. buf = osal_mem_alloc( PACKET_LEN_SE_PRICE_ACKNOWLEDGEMENT );
  652. if ( buf == NULL )
  653. {
  654. return ( ZMemError );
  655. }
  656. pBuf = osal_buffer_uint32( buf, pCmd->providerId );
  657. pBuf = osal_buffer_uint32( pBuf, pCmd->issuerEventId );
  658. pBuf = osal_buffer_uint32( pBuf, pCmd->priceAckTime );
  659. *pBuf = pCmd->control;
  660. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  661. COMMAND_SE_PRICE_ACKNOWLEDGEMENT, TRUE,
  662. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  663. seqNum, PACKET_LEN_SE_PRICE_ACKNOWLEDGEMENT, buf );
  664. osal_mem_free( buf );
  665. return status;
  666. }
  667. /*********************************************************************
  668. * @fn zclSE_Pricing_Send_GetBlockPeriod
  669. *
  670. * @brief Call to send out a Get Block Period
  671. *
  672. * @param srcEP - Sending application's endpoint
  673. * @param dstAddr - where you want the message to go
  674. * @param pCmd - command payload
  675. * @param disableDefaultRsp - disable default response
  676. * @param seqNum - ZCL sequence number
  677. *
  678. * @return ZStatus_t
  679. */
  680. ZStatus_t zclSE_Pricing_Send_GetBlockPeriod( uint8 srcEP, afAddrType_t *dstAddr,
  681. zclCCGetBlockPeriod_t *pCmd,
  682. uint8 disableDefaultRsp, uint8 seqNum )
  683. {
  684. uint8 buf[5];
  685. ZStatus_t status;
  686. osal_buffer_uint32( buf, pCmd->startTime );
  687. buf[4] = pCmd->numEvents;
  688. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  689. COMMAND_SE_GET_BLOCK_PERIOD, TRUE,
  690. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  691. seqNum, 5, buf );
  692. return status;
  693. }
  694. /*********************************************************************
  695. * @fn zclSE_Pricing_Send_PublishBlockPeriod
  696. *
  697. * @brief Call to send out a Publish Block Period
  698. *
  699. * @param srcEP - Sending application's endpoint
  700. * @param dstAddr - where you want the message to go
  701. * @param pCmd - command payload
  702. * @param disableDefaultRsp - disable default response
  703. * @param seqNum - ZCL sequence number
  704. *
  705. * @return ZStatus_t
  706. */
  707. ZStatus_t zclSE_Pricing_Send_PublishBlockPeriod( uint8 srcEP, afAddrType_t *dstAddr,
  708. zclCCPublishBlockPeriod_t *pCmd,
  709. uint8 disableDefaultRsp, uint8 seqNum )
  710. {
  711. uint8 *buf;
  712. uint8 *pBuf;
  713. uint16 bufLen;
  714. ZStatus_t status;
  715. bufLen = PACKET_LEN_SE_PUBLISH_BLOCK_PERIOD;
  716. buf = osal_mem_alloc( bufLen );
  717. if ( buf == NULL )
  718. {
  719. return ( ZMemError );
  720. }
  721. pBuf = osal_buffer_uint32( buf, pCmd->providerId );
  722. pBuf = osal_buffer_uint32( pBuf, pCmd->issuerEventId );
  723. pBuf = osal_buffer_uint32( pBuf, pCmd->blockPeriodStartTime );
  724. pBuf = osal_buffer_uint24( pBuf, pCmd->blockPeriodDurInMins );
  725. *pBuf++ = pCmd->numPriceTiersAndBlock;
  726. #ifdef SE_UK_EXT
  727. *pBuf++ = pCmd->tariffType;
  728. #endif
  729. *pBuf = pCmd->blockPeriodControl;
  730. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  731. COMMAND_SE_PUBLISH_BLOCK_PERIOD, TRUE,
  732. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  733. seqNum, bufLen, buf );
  734. osal_mem_free( buf );
  735. return status;
  736. }
  737. #ifdef SE_UK_EXT
  738. /*********************************************************************
  739. * @fn zclSE_Pricing_Send_PublishTariffInformation
  740. *
  741. * @brief Call to send out a Publish Tariff Information
  742. *
  743. * @param srcEP - Sending application's endpoint
  744. * @param dstAddr - where you want the message to go
  745. * @param pCmd - command payload
  746. * @param disableDefaultRsp - disable default response
  747. * @param seqNum - ZCL sequence number
  748. *
  749. * @return ZStatus_t
  750. */
  751. ZStatus_t zclSE_Pricing_Send_PublishTariffInformation( uint8 srcEP, afAddrType_t *dstAddr,
  752. zclCCPublishTariffInformation_t *pCmd,
  753. uint8 disableDefaultRsp, uint8 seqNum )
  754. {
  755. uint8 *buf;
  756. uint8 *pBuf;
  757. uint16 bufLen;
  758. ZStatus_t status;
  759. bufLen = PACKET_LEN_SE_MIN_PUBLISH_TARIFF_INFORMATION + pCmd->tarifLabel.strLen;
  760. buf = osal_mem_alloc( bufLen );
  761. if ( buf == NULL )
  762. {
  763. return ( ZMemError );
  764. }
  765. pBuf = osal_buffer_uint32( buf, pCmd->supplierId );
  766. pBuf = osal_buffer_uint32( pBuf, pCmd->issuerTariffId );
  767. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  768. *pBuf++ = pCmd->tariffType;
  769. *pBuf++ = pCmd->tarifLabel.strLen;
  770. pBuf = osal_memcpy( pBuf, pCmd->tarifLabel.pStr, pCmd->tarifLabel.strLen );
  771. *pBuf++ = pCmd->numPriceTiersInUse;
  772. *pBuf++ = pCmd->numBlockThresholdsInUse;
  773. *pBuf++ = pCmd->unitOfMeasure;
  774. *pBuf++ = LO_UINT16( pCmd->currency );
  775. *pBuf++ = HI_UINT16( pCmd->currency );
  776. *pBuf++ = pCmd->priceTrailingDigit;
  777. pBuf = osal_buffer_uint32( pBuf, pCmd->standingCharge );
  778. *pBuf++ = pCmd->tierBlockMode;
  779. *pBuf++ = LO_UINT16( pCmd->blockThresholdMask );
  780. *pBuf++ = HI_UINT16( pCmd->blockThresholdMask );
  781. pBuf = osal_buffer_uint24( pBuf, pCmd->BlockThresholdMultiplier );
  782. pBuf = osal_buffer_uint24( pBuf, pCmd->BlockThresholdDivisor );
  783. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  784. COMMAND_SE_PUBLISH_TARIFF_INFO, TRUE,
  785. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  786. seqNum, bufLen, buf );
  787. osal_mem_free( buf );
  788. return status;
  789. }
  790. /*********************************************************************
  791. * @fn zclSE_Pricing_Send_PublishPriceMatrix
  792. *
  793. * @brief Call to send out a Publish Price Matrix
  794. *
  795. * @param srcEP - Sending application's endpoint
  796. * @param dstAddr - where you want the message to go
  797. * @param pCmd - command payload
  798. * @param disableDefaultRsp - disable default response
  799. * @param seqNum - ZCL sequence number
  800. *
  801. * @return ZStatus_t
  802. */
  803. ZStatus_t zclSE_Pricing_Send_PublishPriceMatrix( uint8 srcEP, afAddrType_t *dstAddr,
  804. zclCCPublishPriceMatrix_t *pCmd,
  805. uint8 disableDefaultRsp, uint8 seqNum )
  806. {
  807. uint8 *buf;
  808. uint8 *pBuf;
  809. uint16 bufLen;
  810. ZStatus_t status;
  811. uint8 i;
  812. bufLen = PACKET_LEN_SE_MIN_PUBLISH_PRICE_MATRIX + (pCmd->numElements * sizeof(uint32));
  813. buf = osal_mem_alloc( bufLen );
  814. if ( buf == NULL )
  815. {
  816. return ( ZMemError );
  817. }
  818. pBuf = osal_buffer_uint32( buf, pCmd->issuerTariffId );
  819. *pBuf++ = pCmd->commandIndex;
  820. for ( i = 0; i < pCmd->numElements; i++ )
  821. {
  822. pBuf = osal_buffer_uint32( pBuf, pCmd->pTierBlockPrice[i] );
  823. }
  824. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  825. COMMAND_SE_PUBLISH_PRICE_MATRIX, TRUE,
  826. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  827. seqNum, bufLen, buf );
  828. osal_mem_free( buf );
  829. return status;
  830. }
  831. /*********************************************************************
  832. * @fn zclSE_Pricing_Send_PublishBlockThresholds
  833. *
  834. * @brief Call to send out a Publish Block Thresholds
  835. *
  836. * @param srcEP - Sending application's endpoint
  837. * @param dstAddr - where you want the message to go
  838. * @param pCmd - command payload
  839. * @param disableDefaultRsp - disable default response
  840. * @param seqNum - ZCL sequence number
  841. *
  842. * @return ZStatus_t
  843. */
  844. ZStatus_t zclSE_Pricing_Send_PublishBlockThresholds( uint8 srcEP, afAddrType_t *dstAddr,
  845. zclCCPublishBlockThresholds_t *pCmd,
  846. uint8 disableDefaultRsp, uint8 seqNum )
  847. {
  848. uint8 *buf;
  849. uint8 *pBuf;
  850. uint16 bufLen;
  851. ZStatus_t status;
  852. uint8 i;
  853. bufLen = PACKET_LEN_SE_MIN_PUBLISH_BLOCK_THRESHOLD + (pCmd->numElements * 6);
  854. buf = osal_mem_alloc( bufLen );
  855. if ( buf == NULL )
  856. {
  857. return ( ZMemError );
  858. }
  859. pBuf = osal_buffer_uint32( buf, pCmd->issuerTariffId );
  860. *pBuf++ = pCmd->commandIndex;
  861. for ( i = 0; i < pCmd->numElements; i++ )
  862. {
  863. pBuf = osal_memcpy( pBuf, pCmd->pTierBlockThreshold[i], 6 );
  864. }
  865. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  866. COMMAND_SE_PUBLISH_BLOCK_THRESHOLD, TRUE,
  867. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  868. seqNum, bufLen, buf );
  869. osal_mem_free( buf );
  870. return status;
  871. }
  872. /*********************************************************************
  873. * @fn zclSE_Pricing_Send_PublishConversionFactor
  874. *
  875. * @brief Call to send out a Publish Conversion Factor
  876. *
  877. * @param srcEP - Sending application's endpoint
  878. * @param dstAddr - where you want the message to go
  879. * @param pCmd - command payload
  880. * @param disableDefaultRsp - disable default response
  881. * @param seqNum - ZCL sequence number
  882. *
  883. * @return ZStatus_t
  884. */
  885. ZStatus_t zclSE_Pricing_Send_PublishConversionFactor( uint8 srcEP, afAddrType_t *dstAddr,
  886. zclCCPublishConversionFactor_t *pCmd,
  887. uint8 disableDefaultRsp, uint8 seqNum )
  888. {
  889. uint8 buf[PACKET_LEN_SE_PUBLISH_CONVERSION_FACTOR];
  890. uint8 *pBuf;
  891. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventId );
  892. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  893. pBuf = osal_buffer_uint32( pBuf, pCmd->conversionFactor );
  894. *pBuf = pCmd->trailingDigit;
  895. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  896. COMMAND_SE_PUBLISH_CONVERSION_FACTOR, TRUE,
  897. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  898. seqNum, PACKET_LEN_SE_PUBLISH_CONVERSION_FACTOR, buf );
  899. }
  900. /*********************************************************************
  901. * @fn zclSE_Pricing_Send_PublishCalorificValue
  902. *
  903. * @brief Call to send out a Publish Calorific Value
  904. *
  905. * @param srcEP - Sending application's endpoint
  906. * @param dstAddr - where you want the message to go
  907. * @param pCmd - command payload
  908. * @param disableDefaultRsp - disable default response
  909. * @param seqNum - ZCL sequence number
  910. *
  911. * @return ZStatus_t
  912. */
  913. ZStatus_t zclSE_Pricing_Send_PublishCalorificValue( uint8 srcEP, afAddrType_t *dstAddr,
  914. zclCCPublishCalorificValue_t *pCmd,
  915. uint8 disableDefaultRsp, uint8 seqNum )
  916. {
  917. uint8 buf[PACKET_LEN_SE_PUBLISH_CALORIFIC_VALUE];
  918. uint8 *pBuf;
  919. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventId );
  920. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  921. pBuf = osal_buffer_uint32( pBuf, pCmd->calorificValue );
  922. *pBuf++ = pCmd->calorificValueUnit;
  923. *pBuf = pCmd->trailingDigit;
  924. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  925. COMMAND_SE_PUBLISH_CALORIFIC_VALUE, TRUE,
  926. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  927. seqNum, PACKET_LEN_SE_PUBLISH_CALORIFIC_VALUE, buf );
  928. }
  929. /*********************************************************************
  930. * @fn zclSE_Pricing_Send_PublishCO2Value
  931. *
  932. * @brief Call to send out a Publish CO2 Value
  933. *
  934. * @param srcEP - Sending application's endpoint
  935. * @param dstAddr - where you want the message to go
  936. * @param pCmd - command payload
  937. * @param disableDefaultRsp - disable default response
  938. * @param seqNum - ZCL sequence number
  939. *
  940. * @return ZStatus_t
  941. */
  942. ZStatus_t zclSE_Pricing_Send_PublishCO2Value( uint8 srcEP, afAddrType_t *dstAddr,
  943. zclCCPublishCO2Value_t *pCmd,
  944. uint8 disableDefaultRsp, uint8 seqNum )
  945. {
  946. uint8 buf[PACKET_LEN_SE_PUBLISH_CO2_VALUE];
  947. uint8 *pBuf;
  948. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventId );
  949. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  950. *pBuf++ = pCmd->tariffType;
  951. pBuf = osal_buffer_uint32( pBuf, pCmd->CO2Value );
  952. *pBuf++ = pCmd->CO2ValueUnit;
  953. *pBuf = pCmd->trailingDigit;
  954. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  955. COMMAND_SE_PUBLISH_CO2_VALUE, TRUE,
  956. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  957. seqNum, PACKET_LEN_SE_PUBLISH_CO2_VALUE, buf );
  958. }
  959. /*********************************************************************
  960. * @fn zclSE_Pricing_Send_PublishCPPEvent
  961. *
  962. * @brief Call to send out a Publish CPP Event
  963. *
  964. * @param srcEP - Sending application's endpoint
  965. * @param dstAddr - where you want the message to go
  966. * @param pCmd - command payload
  967. * @param disableDefaultRsp - disable default response
  968. * @param seqNum - ZCL sequence number
  969. *
  970. * @return ZStatus_t
  971. */
  972. ZStatus_t zclSE_Pricing_Send_PublishCPPEvent( uint8 srcEP, afAddrType_t *dstAddr,
  973. zclCCPublishCPPEvent_t *pCmd,
  974. uint8 disableDefaultRsp, uint8 seqNum )
  975. {
  976. uint8 buf[PACKET_LEN_SE_PUBLISH_CPP_EVENT];
  977. uint8 *pBuf;
  978. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventId );
  979. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  980. *pBuf++ = LO_UINT16( pCmd->durationInMinutes );
  981. *pBuf++ = HI_UINT16( pCmd->durationInMinutes );
  982. *pBuf++ = pCmd->tariffType;
  983. *pBuf++ = pCmd->CPPPriceTier;
  984. *pBuf = pCmd->CPPAuth;
  985. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  986. COMMAND_SE_PUBLISH_CPP_EVENT, TRUE,
  987. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  988. seqNum, PACKET_LEN_SE_PUBLISH_CPP_EVENT, buf );
  989. }
  990. /*********************************************************************
  991. * @fn zclSE_Pricing_Send_PublishBillingPeriod
  992. *
  993. * @brief Call to send out a Publish Billing Period
  994. *
  995. * @param srcEP - Sending application's endpoint
  996. * @param dstAddr - where you want the message to go
  997. * @param pCmd - command payload
  998. * @param disableDefaultRsp - disable default response
  999. * @param seqNum - ZCL sequence number
  1000. *
  1001. * @return ZStatus_t
  1002. */
  1003. ZStatus_t zclSE_Pricing_Send_PublishBillingPeriod( uint8 srcEP, afAddrType_t *dstAddr,
  1004. zclCCPublishBillingPeriod_t *pCmd,
  1005. uint8 disableDefaultRsp, uint8 seqNum )
  1006. {
  1007. uint8 buf[PACKET_LEN_SE_PUBLISH_BILLING_PERIOD];
  1008. uint8 *pBuf;
  1009. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventId );
  1010. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  1011. pBuf = osal_buffer_uint24( pBuf, pCmd->duration );
  1012. *pBuf = pCmd->tariffType;
  1013. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1014. COMMAND_SE_PUBLISH_BILLING_PERIOD, TRUE,
  1015. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  1016. seqNum, PACKET_LEN_SE_PUBLISH_BILLING_PERIOD, buf );
  1017. }
  1018. /*********************************************************************
  1019. * @fn zclSE_Pricing_Send_PublishConsolidatedBill
  1020. *
  1021. * @brief Call to send out a Publish Consolidated Bill
  1022. *
  1023. * @param srcEP - Sending application's endpoint
  1024. * @param dstAddr - where you want the message to go
  1025. * @param pCmd - command payload
  1026. * @param disableDefaultRsp - disable default response
  1027. * @param seqNum - ZCL sequence number
  1028. *
  1029. * @return ZStatus_t
  1030. */
  1031. ZStatus_t zclSE_Pricing_Send_PublishConsolidatedBill( uint8 srcEP, afAddrType_t *dstAddr,
  1032. zclCCPublishConsolidatedBill_t *pCmd,
  1033. uint8 disableDefaultRsp, uint8 seqNum )
  1034. {
  1035. uint8 buf[PACKET_LEN_SE_PUBLISH_CONSOLIDATED_BILL];
  1036. uint8 *pBuf;
  1037. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventId );
  1038. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  1039. pBuf = osal_buffer_uint24( pBuf, pCmd->duration );
  1040. *pBuf++ = pCmd->tariffType;
  1041. pBuf = osal_buffer_uint32( pBuf, pCmd->consolidatedBill );
  1042. *pBuf++ = LO_UINT16( pCmd->currency );
  1043. *pBuf++ = HI_UINT16( pCmd->currency );
  1044. *pBuf = pCmd->trailingDigit;
  1045. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1046. COMMAND_SE_PUBLISH_CONSOLIDATED_BILL, TRUE,
  1047. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  1048. seqNum, PACKET_LEN_SE_PUBLISH_CONSOLIDATED_BILL, buf );
  1049. }
  1050. /*********************************************************************
  1051. * @fn zclSE_Pricing_Send_PublishCreditPaymentInfo
  1052. *
  1053. * @brief Call to send out a Publish Credit Payment Info
  1054. *
  1055. * @param srcEP - Sending application's endpoint
  1056. * @param dstAddr - where you want the message to go
  1057. * @param pCmd - command payload
  1058. * @param disableDefaultRsp - disable default response
  1059. * @param seqNum - ZCL sequence number
  1060. *
  1061. * @return ZStatus_t
  1062. */
  1063. ZStatus_t zclSE_Pricing_Send_PublishCreditPaymentInfo( uint8 srcEP, afAddrType_t *dstAddr,
  1064. zclCCPublishCreditPaymentInfo_t *pCmd,
  1065. uint8 disableDefaultRsp, uint8 seqNum )
  1066. {
  1067. uint8 *buf;
  1068. uint8 *pBuf;
  1069. uint16 bufLen;
  1070. ZStatus_t status;
  1071. bufLen = PACKET_LEN_SE_MIN_PUBLISH_CREDIT_PAYMENT_INFO + pCmd->creditPaymentRef.strLen;
  1072. buf = osal_mem_alloc( bufLen );
  1073. if ( buf == NULL )
  1074. {
  1075. return ( ZMemError );
  1076. }
  1077. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventId );
  1078. pBuf = osal_buffer_uint32( pBuf, pCmd->paymentDueDate );
  1079. pBuf = osal_buffer_uint32( pBuf, pCmd->creditPaymentOverdueAmt );
  1080. *pBuf++ = pCmd->creditPaymentStatus;
  1081. pBuf = osal_buffer_uint32( pBuf, pCmd->creditPayment );
  1082. pBuf = osal_buffer_uint32( pBuf, pCmd->creditPaymentDate );
  1083. *pBuf++ = pCmd->creditPaymentRef.strLen;
  1084. osal_memcpy( pBuf, pCmd->creditPaymentRef.pStr, pCmd->creditPaymentRef.strLen );
  1085. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1086. COMMAND_SE_PUBLISH_CREDIT_PAYMENT_INFO, TRUE,
  1087. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  1088. seqNum, bufLen, buf );
  1089. osal_mem_free( buf );
  1090. return status;
  1091. }
  1092. /*********************************************************************
  1093. * @fn zclSE_Pricing_Send_GetTariffInformation
  1094. *
  1095. * @brief Call to send out a Get Tariff Information
  1096. *
  1097. * @param srcEP - Sending application's endpoint
  1098. * @param dstAddr - where you want the message to go
  1099. * @param pCmd - command payload
  1100. * @param disableDefaultRsp - disable default response
  1101. * @param seqNum - ZCL sequence number
  1102. *
  1103. * @return ZStatus_t
  1104. */
  1105. ZStatus_t zclSE_Pricing_Send_GetTariffInformation( uint8 srcEP, afAddrType_t *dstAddr,
  1106. zclCCGetTariffInformation_t *pCmd,
  1107. uint8 disableDefaultRsp, uint8 seqNum )
  1108. {
  1109. uint8 buf[PACKET_LEN_SE_GET_TARIFF_INFO];
  1110. uint8 *pBuf;
  1111. pBuf = osal_buffer_uint32( buf, pCmd->startTime );
  1112. *pBuf++ = pCmd->numEvents;
  1113. *pBuf = pCmd->tariffType;
  1114. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1115. COMMAND_SE_GET_TARIFF_INFO, TRUE,
  1116. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1117. seqNum, PACKET_LEN_SE_GET_TARIFF_INFO, buf );
  1118. }
  1119. /*********************************************************************
  1120. * @fn zclSE_Pricing_Send_GetPriceMatrix
  1121. *
  1122. * @brief Call to send out a Get Price Matrix
  1123. *
  1124. * @param srcEP - Sending application's endpoint
  1125. * @param dstAddr - where you want the message to go
  1126. * @param issuerId - Issuer ID
  1127. * @param disableDefaultRsp - disable default response
  1128. * @param seqNum - ZCL sequence number
  1129. *
  1130. * @return ZStatus_t
  1131. */
  1132. ZStatus_t zclSE_Pricing_Send_GetPriceMatrix( uint8 srcEP, afAddrType_t *dstAddr,
  1133. uint32 issuerId,
  1134. uint8 disableDefaultRsp, uint8 seqNum )
  1135. {
  1136. uint8 buf[PACKET_LEN_SE_GET_PRICE_MATRIX];
  1137. osal_buffer_uint32( buf, issuerId );
  1138. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1139. COMMAND_SE_GET_PRICE_MATRIX, TRUE,
  1140. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1141. seqNum, PACKET_LEN_SE_GET_PRICE_MATRIX, buf );
  1142. }
  1143. /*********************************************************************
  1144. * @fn zclSE_Pricing_Send_GetBlockThresholds
  1145. *
  1146. * @brief Call to send out a Get Block Thresholds
  1147. *
  1148. * @param srcEP - Sending application's endpoint
  1149. * @param dstAddr - where you want the message to go
  1150. * @param issuerId - Issuer ID
  1151. * @param disableDefaultRsp - disable default response
  1152. * @param seqNum - ZCL sequence number
  1153. *
  1154. * @return ZStatus_t
  1155. */
  1156. ZStatus_t zclSE_Pricing_Send_GetBlockThresholds( uint8 srcEP, afAddrType_t *dstAddr,
  1157. uint32 issuerId,
  1158. uint8 disableDefaultRsp, uint8 seqNum )
  1159. {
  1160. uint8 buf[PACKET_LEN_SE_GET_BLOCK_THRESHOLD];
  1161. osal_buffer_uint32( buf, issuerId );
  1162. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1163. COMMAND_SE_GET_BLOCK_THRESHOLD, TRUE,
  1164. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1165. seqNum, PACKET_LEN_SE_GET_BLOCK_THRESHOLD, buf );
  1166. }
  1167. /*********************************************************************
  1168. * @fn zclSE_Pricing_Send_GetConversionFactor
  1169. *
  1170. * @brief Call to send out a Get Conversion Factor
  1171. *
  1172. * @param srcEP - Sending application's endpoint
  1173. * @param dstAddr - where you want the message to go
  1174. * @param pCmd - command payload
  1175. * @param disableDefaultRsp - disable default response
  1176. * @param seqNum - ZCL sequence number
  1177. *
  1178. * @return ZStatus_t
  1179. */
  1180. ZStatus_t zclSE_Pricing_Send_GetConversionFactor( uint8 srcEP, afAddrType_t *dstAddr,
  1181. zclCCGetConversionFactor_t *pCmd,
  1182. uint8 disableDefaultRsp, uint8 seqNum )
  1183. {
  1184. uint8 buf[PACKET_LEN_SE_GET_CONVERSION_FACTOR];
  1185. uint8 *pBuf;
  1186. pBuf = osal_buffer_uint32( buf, pCmd->startTime );
  1187. *pBuf = pCmd->numEvents;
  1188. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1189. COMMAND_SE_GET_CONVERSION_FACTOR, TRUE,
  1190. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1191. seqNum, PACKET_LEN_SE_GET_CONVERSION_FACTOR, buf );
  1192. }
  1193. /*********************************************************************
  1194. * @fn zclSE_Pricing_Send_GetCalorificValue
  1195. *
  1196. * @brief Call to send out a Get Calorific Value
  1197. *
  1198. * @param srcEP - Sending application's endpoint
  1199. * @param dstAddr - where you want the message to go
  1200. * @param pCmd - command payload
  1201. * @param disableDefaultRsp - disable default response
  1202. * @param seqNum - ZCL sequence number
  1203. *
  1204. * @return ZStatus_t
  1205. */
  1206. ZStatus_t zclSE_Pricing_Send_GetCalorificValue( uint8 srcEP, afAddrType_t *dstAddr,
  1207. zclCCGetCalorificValue_t *pCmd,
  1208. uint8 disableDefaultRsp, uint8 seqNum )
  1209. {
  1210. uint8 buf[PACKET_LEN_SE_GET_CALORIFIC_VALUE];
  1211. uint8 *pBuf;
  1212. pBuf = osal_buffer_uint32( buf, pCmd->startTime );
  1213. *pBuf = pCmd->numEvents;
  1214. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1215. COMMAND_SE_GET_CALORIFIC_VALUE, TRUE,
  1216. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1217. seqNum, PACKET_LEN_SE_GET_CALORIFIC_VALUE, buf );
  1218. }
  1219. /*********************************************************************
  1220. * @fn zclSE_Pricing_Send_GetCO2Value
  1221. *
  1222. * @brief Call to send out a Get CO2 Value
  1223. *
  1224. * @param srcEP - Sending application's endpoint
  1225. * @param dstAddr - where you want the message to go
  1226. * @param pCmd - command payload
  1227. * @param disableDefaultRsp - disable default response
  1228. * @param seqNum - ZCL sequence number
  1229. *
  1230. * @return ZStatus_t
  1231. */
  1232. ZStatus_t zclSE_Pricing_Send_GetCO2Value( uint8 srcEP, afAddrType_t *dstAddr,
  1233. zclCCGetCO2Value_t *pCmd,
  1234. uint8 disableDefaultRsp, uint8 seqNum )
  1235. {
  1236. uint8 buf[PACKET_LEN_SE_GET_CO2_VALUE];
  1237. uint8 *pBuf;
  1238. pBuf = osal_buffer_uint32( buf, pCmd->startTime );
  1239. *pBuf++ = pCmd->numEvents;
  1240. *pBuf = pCmd->tariffType;
  1241. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1242. COMMAND_SE_GET_CO2_VALUE, TRUE,
  1243. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1244. seqNum, PACKET_LEN_SE_GET_CO2_VALUE, buf );
  1245. }
  1246. /*********************************************************************
  1247. * @fn zclSE_Pricing_Send_GetBillingPeriod
  1248. *
  1249. * @brief Call to send out a Get Billing Period
  1250. *
  1251. * @param srcEP - Sending application's endpoint
  1252. * @param dstAddr - where you want the message to go
  1253. * @param pCmd - command payload
  1254. * @param disableDefaultRsp - disable default response
  1255. * @param seqNum - ZCL sequence number
  1256. *
  1257. * @return ZStatus_t
  1258. */
  1259. ZStatus_t zclSE_Pricing_Send_GetBillingPeriod( uint8 srcEP, afAddrType_t *dstAddr,
  1260. zclCCGetBillingPeriod_t *pCmd,
  1261. uint8 disableDefaultRsp, uint8 seqNum )
  1262. {
  1263. uint8 buf[PACKET_LEN_SE_GET_BILLING_PERIOD];
  1264. uint8 *pBuf;
  1265. pBuf = osal_buffer_uint32( buf, pCmd->startTime );
  1266. *pBuf++ = pCmd->numEvents;
  1267. *pBuf = pCmd->tariffType;
  1268. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1269. COMMAND_SE_GET_BILLING_PERIOD, TRUE,
  1270. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1271. seqNum, PACKET_LEN_SE_GET_BILLING_PERIOD, buf );
  1272. }
  1273. /*********************************************************************
  1274. * @fn zclSE_Pricing_Send_GetConsolidatedBill
  1275. *
  1276. * @brief Call to send out a Get Consolidated Bill
  1277. *
  1278. * @param srcEP - Sending application's endpoint
  1279. * @param dstAddr - where you want the message to go
  1280. * @param pCmd - command payload
  1281. * @param disableDefaultRsp - disable default response
  1282. * @param seqNum - ZCL sequence number
  1283. *
  1284. * @return ZStatus_t
  1285. */
  1286. ZStatus_t zclSE_Pricing_Send_GetConsolidatedBill( uint8 srcEP, afAddrType_t *dstAddr,
  1287. zclCCGetConsolidatedBill_t *pCmd,
  1288. uint8 disableDefaultRsp, uint8 seqNum )
  1289. {
  1290. uint8 buf[PACKET_LEN_SE_GET_CONSOLIDATED_BILL];
  1291. uint8 *pBuf;
  1292. pBuf = osal_buffer_uint32( buf, pCmd->startTime );
  1293. *pBuf++ = pCmd->numEvents;
  1294. *pBuf = pCmd->tariffType;
  1295. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1296. COMMAND_SE_GET_CONSOLIDATED_BILL, TRUE,
  1297. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1298. seqNum, PACKET_LEN_SE_GET_CONSOLIDATED_BILL, buf );
  1299. }
  1300. /*********************************************************************
  1301. * @fn zclSE_Pricing_Send_CPPEventResponse
  1302. *
  1303. * @brief Call to send out a CPP Event Response
  1304. *
  1305. * @param srcEP - Sending application's endpoint
  1306. * @param dstAddr - where you want the message to go
  1307. * @param pCmd - command payload
  1308. * @param disableDefaultRsp - disable default response
  1309. * @param seqNum - ZCL sequence number
  1310. *
  1311. * @return ZStatus_t
  1312. */
  1313. ZStatus_t zclSE_Pricing_Send_CPPEventResponse( uint8 srcEP, afAddrType_t *dstAddr,
  1314. zclCCCPPEventResponse_t *pCmd,
  1315. uint8 disableDefaultRsp, uint8 seqNum )
  1316. {
  1317. uint8 buf[PACKET_LEN_SE_CPP_EVENT_RESPONSE];
  1318. uint8 *pBuf;
  1319. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventId );
  1320. *pBuf = pCmd->CPPAuth;
  1321. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PRICING,
  1322. COMMAND_SE_CPP_EVENT_RESPONSE, TRUE,
  1323. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1324. seqNum, PACKET_LEN_SE_CPP_EVENT_RESPONSE, buf );
  1325. }
  1326. #endif // SE_UK_EXT
  1327. #endif // ZCL_PRICING
  1328. #ifdef ZCL_MESSAGE
  1329. /*********************************************************************
  1330. * @fn zclSE_Message_Send_DisplayMessage
  1331. *
  1332. * @brief Call to send out a Display Message Command
  1333. *
  1334. * @param srcEP - Sending application's endpoint
  1335. * @param dstAddr - where you want the message to go
  1336. * @param pCmd - command payload
  1337. * @param disableDefaultRsp - disable default response
  1338. * @param seqNum - ZCL sequence number
  1339. *
  1340. * @return ZStatus_t
  1341. */
  1342. ZStatus_t zclSE_Message_Send_DisplayMessage( uint8 srcEP, afAddrType_t *dstAddr,
  1343. zclCCDisplayMessage_t *pCmd,
  1344. uint8 disableDefaultRsp, uint8 seqNum )
  1345. {
  1346. uint8 *buf;
  1347. uint8 *pBuf;
  1348. uint16 bufLen;
  1349. ZStatus_t status;
  1350. // msgId + msgCtrl + start time + duration + msgLen + msg
  1351. bufLen = 4 + 1 + 4 + 2 + 1 + pCmd->msgString.strLen;
  1352. buf = osal_mem_alloc( bufLen );
  1353. if ( buf == NULL )
  1354. {
  1355. return ( ZMemError );
  1356. }
  1357. pBuf = osal_buffer_uint32( buf, pCmd->messageId ); // Streamline the uint32 data
  1358. *pBuf++ = pCmd->messageCtrl.transmissionMode |
  1359. (pCmd->messageCtrl.importance << SE_PROFILE_MSGCTRL_IMPORTANCE) |
  1360. #if defined ( SE_UK_EXT )
  1361. (pCmd->messageCtrl.pinRequired << SE_PROFILE_MSGCTRL_PINREQUIRED ) |
  1362. (pCmd->messageCtrl.acceptanceRequired << SE_PROFILE_MSGCTRL_ACCEPTREQUIRED ) |
  1363. #endif
  1364. (pCmd->messageCtrl.confirmationRequired << SE_PROFILE_MSGCTRL_CONFREQUIRED);
  1365. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  1366. *pBuf++ = LO_UINT16( pCmd->durationInMinutes );
  1367. *pBuf++ = HI_UINT16( pCmd->durationInMinutes );
  1368. *pBuf++ = pCmd->msgString.strLen;
  1369. osal_memcpy( pBuf, pCmd->msgString.pStr, pCmd->msgString.strLen );
  1370. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_MESSAGE,
  1371. COMMAND_SE_DISPLAY_MESSAGE, TRUE,
  1372. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp,
  1373. 0, seqNum, bufLen, buf );
  1374. osal_mem_free( buf );
  1375. return status;
  1376. }
  1377. /*********************************************************************
  1378. * @fn zclSE_Message_Send_CancelMessage
  1379. *
  1380. * @brief Call to send out a Cancel Message Command
  1381. *
  1382. * @param srcEP - Sending application's endpoint
  1383. * @param dstAddr - where you want the message to go
  1384. * @param pCmd - command payload
  1385. * @param disableDefaultRsp - disable default response
  1386. * @param seqNum - ZCL sequence number
  1387. *
  1388. * @return ZStatus_t
  1389. */
  1390. ZStatus_t zclSE_Message_Send_CancelMessage( uint8 srcEP, afAddrType_t *dstAddr,
  1391. zclCCCancelMessage_t *pCmd,
  1392. uint8 disableDefaultRsp, uint8 seqNum )
  1393. {
  1394. uint8 buf[5];
  1395. osal_buffer_uint32( buf, pCmd->messageId ); // Streamline the uint32 data
  1396. buf[4] = pCmd->messageCtrl.transmissionMode |
  1397. (pCmd->messageCtrl.importance << SE_PROFILE_MSGCTRL_IMPORTANCE) |
  1398. #if defined ( SE_UK_EXT )
  1399. (pCmd->messageCtrl.pinRequired << SE_PROFILE_MSGCTRL_PINREQUIRED ) |
  1400. (pCmd->messageCtrl.acceptanceRequired << SE_PROFILE_MSGCTRL_ACCEPTREQUIRED ) |
  1401. #endif
  1402. (pCmd->messageCtrl.confirmationRequired << SE_PROFILE_MSGCTRL_CONFREQUIRED);
  1403. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_MESSAGE,
  1404. COMMAND_SE_CANCEL_MESSAGE, TRUE,
  1405. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp,
  1406. 0, seqNum, 5, buf );
  1407. }
  1408. /*********************************************************************
  1409. * @fn zclSE_Message_Send_MessageConfirmation
  1410. *
  1411. * @brief Call to send out a Message Confirmation
  1412. *
  1413. * @param srcEP - Sending application's endpoint
  1414. * @param dstAddr - where you want the message to go
  1415. * @param pCmd - command payload
  1416. * @param disableDefaultRsp - disable default response
  1417. * @param seqNum - ZCL sequence number
  1418. *
  1419. * @return ZStatus_t
  1420. */
  1421. ZStatus_t zclSE_Message_Send_MessageConfirmation( uint8 srcEP, afAddrType_t *dstAddr,
  1422. zclCCMessageConfirmation_t *pCmd,
  1423. uint8 disableDefaultRsp, uint8 seqNum )
  1424. {
  1425. uint8 *buf;
  1426. uint8 *pBuf;
  1427. uint16 bufLen = 4 + 4; // msgId + confirm time
  1428. ZStatus_t status;
  1429. #if defined ( SE_UK_EXT )
  1430. // Message Response length must be 0 - 20 octets
  1431. if ( pCmd->msgString.strLen > SE_PROFILE_MESSAGE_RESPONSE_LENGTH )
  1432. {
  1433. return (ZInvalidParameter);
  1434. }
  1435. // msgLen + msg
  1436. bufLen += 1 + pCmd->msgString.strLen;
  1437. #endif
  1438. buf = osal_mem_alloc( bufLen );
  1439. if ( buf == NULL )
  1440. {
  1441. return ( ZMemError );
  1442. }
  1443. pBuf = osal_buffer_uint32( buf, pCmd->messageId ); // Streamline the uint32 data
  1444. pBuf = osal_buffer_uint32( pBuf, pCmd->confirmTime );
  1445. #if defined ( SE_UK_EXT )
  1446. *pBuf++ = pCmd->msgString.strLen;
  1447. osal_memcpy( pBuf, pCmd->msgString.pStr, pCmd->msgString.strLen );
  1448. #endif
  1449. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_MESSAGE,
  1450. COMMAND_SE_MESSAGE_CONFIRMATION, TRUE,
  1451. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp,
  1452. 0, seqNum, bufLen, buf );
  1453. osal_mem_free( buf );
  1454. return status;
  1455. }
  1456. #endif // ZCL_MESSAGE
  1457. #ifdef ZCL_LOAD_CONTROL
  1458. /*********************************************************************
  1459. * @fn zclSE_LoadControl_Send_LoadControlEvent
  1460. *
  1461. * @brief Call to send out a Load Control Event
  1462. *
  1463. * @param srcEP - Sending application's endpoint
  1464. * @param dstAddr - where you want the message to go
  1465. * @param pCmd - command payload
  1466. * @param disableDefaultRsp - disable default response
  1467. * @param seqNum - ZCL sequence number
  1468. *
  1469. * @return ZStatus_t
  1470. */
  1471. ZStatus_t zclSE_LoadControl_Send_LoadControlEvent( uint8 srcEP, afAddrType_t *dstAddr,
  1472. zclCCLoadControlEvent_t *pCmd,
  1473. uint8 disableDefaultRsp, uint8 seqNum )
  1474. {
  1475. uint8 *buf;
  1476. uint8 *pBuf;
  1477. ZStatus_t status;
  1478. buf = osal_mem_alloc( PACKET_LEN_SE_LOAD_CONTROL_EVENT );
  1479. if ( buf == NULL )
  1480. {
  1481. return ( ZMemError );
  1482. }
  1483. pBuf = osal_buffer_uint32( buf, pCmd->issuerEvent );
  1484. pBuf = osal_buffer_uint24( pBuf, pCmd->deviceGroupClass );
  1485. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  1486. *pBuf++ = LO_UINT16( pCmd->durationInMinutes );
  1487. *pBuf++ = HI_UINT16( pCmd->durationInMinutes );
  1488. *pBuf++ = pCmd->criticalityLevel;
  1489. *pBuf++ = pCmd->coolingTemperatureOffset;
  1490. *pBuf++ = pCmd->heatingTemperatureOffset;
  1491. *pBuf++ = LO_UINT16( pCmd->coolingTemperatureSetPoint );
  1492. *pBuf++ = HI_UINT16( pCmd->coolingTemperatureSetPoint );
  1493. *pBuf++ = LO_UINT16( pCmd->heatingTemperatureSetPoint );
  1494. *pBuf++ = HI_UINT16( pCmd->heatingTemperatureSetPoint );
  1495. *pBuf++ = pCmd->averageLoadAdjustmentPercentage;
  1496. *pBuf++ = pCmd->dutyCycle;
  1497. *pBuf = pCmd->eventControl;
  1498. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  1499. COMMAND_SE_LOAD_CONTROL_EVENT, TRUE,
  1500. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum,
  1501. PACKET_LEN_SE_LOAD_CONTROL_EVENT, buf );
  1502. osal_mem_free( buf );
  1503. return status;
  1504. }
  1505. /*********************************************************************
  1506. * @fn zclSE_LoadControl_Send_CancelLoadControlEvent
  1507. *
  1508. * @brief Call to send out a Cancel Load Control Event
  1509. *
  1510. * @param srcEP - Sending application's endpoint
  1511. * @param dstAddr - where you want the message to go
  1512. * @param pCmd - command payload
  1513. * @param disableDefaultRsp - disable default response
  1514. * @param seqNum - ZCL sequence number
  1515. *
  1516. * @return ZStatus_t
  1517. */
  1518. ZStatus_t zclSE_LoadControl_Send_CancelLoadControlEvent( uint8 srcEP, afAddrType_t *dstAddr,
  1519. zclCCCancelLoadControlEvent_t *pCmd,
  1520. uint8 disableDefaultRsp, uint8 seqNum )
  1521. {
  1522. uint8 buf[PACKET_LEN_SE_CANCEL_LOAD_CONTROL_EVENT];
  1523. uint8 *pBuf;
  1524. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventID );
  1525. pBuf = osal_buffer_uint24( pBuf, pCmd->deviceGroupClass );
  1526. *pBuf++ = pCmd->cancelControl;
  1527. pBuf = osal_buffer_uint32( pBuf, pCmd->effectiveTime );
  1528. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  1529. COMMAND_SE_CANCEL_LOAD_CONTROL_EVENT, TRUE,
  1530. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum,
  1531. PACKET_LEN_SE_CANCEL_LOAD_CONTROL_EVENT, buf );
  1532. }
  1533. /*********************************************************************
  1534. * @fn zclSE_LoadControl_Send_ReportEventStatus
  1535. *
  1536. * @brief Call to send out a Report Event Status
  1537. *
  1538. * @param srcEP - Sending application's endpoint
  1539. * @param dstAddr - where you want the message to go
  1540. * @param pCmd - command payload
  1541. * @param disableDefaultRsp - disable default response
  1542. * @param seqNum - ZCL sequence number
  1543. *
  1544. * @return ZStatus_t
  1545. */
  1546. ZStatus_t zclSE_LoadControl_Send_ReportEventStatus( uint8 srcEP, afAddrType_t *dstAddr,
  1547. zclCCReportEventStatus_t *pCmd,
  1548. uint8 disableDefaultRsp, uint8 seqNum )
  1549. {
  1550. uint8 *buf;
  1551. uint8 *pBuf;
  1552. ZStatus_t status;
  1553. buf = osal_mem_alloc( PACKET_LEN_SE_REPORT_EVENT_STATUS );
  1554. if ( buf == NULL )
  1555. {
  1556. return ( ZMemError );
  1557. }
  1558. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventID );
  1559. *pBuf++ = pCmd->eventStatus;
  1560. pBuf = osal_buffer_uint32( pBuf, pCmd->eventStartTime );
  1561. *pBuf++ = pCmd->criticalityLevelApplied;
  1562. *pBuf++ = LO_UINT16( pCmd->coolingTemperatureSetPointApplied );
  1563. *pBuf++ = HI_UINT16( pCmd->coolingTemperatureSetPointApplied );
  1564. *pBuf++ = LO_UINT16( pCmd->heatingTemperatureSetPointApplied );
  1565. *pBuf++ = HI_UINT16( pCmd->heatingTemperatureSetPointApplied );
  1566. *pBuf++ = pCmd->averageLoadAdjustment;
  1567. *pBuf++ = pCmd->dutyCycleApplied;
  1568. *pBuf++ = pCmd->eventControl;
  1569. *pBuf++ = pCmd->signatureType;
  1570. zclGeneral_KeyEstablishment_ECDSASign( buf, PACKET_LEN_SE_REPORT_EVENT_STATUS_ONLY, pBuf);
  1571. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  1572. COMMAND_SE_REPORT_EVENT_STATUS, TRUE,
  1573. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum,
  1574. PACKET_LEN_SE_REPORT_EVENT_STATUS, buf );
  1575. osal_mem_free( buf );
  1576. return status;
  1577. }
  1578. /*********************************************************************
  1579. * @fn zclSE_LoadControl_Send_GetScheduledEvent
  1580. *
  1581. * @brief Call to send out a Get Scheduled Event
  1582. *
  1583. * @param srcEP - Sending application's endpoint
  1584. * @param dstAddr - where you want the message to go
  1585. * @param pCmd - command payload
  1586. * @param disableDefaultRsp - disable default response
  1587. * @param seqNum - ZCL sequence number
  1588. *
  1589. * @return ZStatus_t
  1590. */
  1591. ZStatus_t zclSE_LoadControl_Send_GetScheduledEvent( uint8 srcEP, afAddrType_t *dstAddr,
  1592. zclCCGetScheduledEvent_t *pCmd,
  1593. uint8 disableDefaultRsp, uint8 seqNum )
  1594. {
  1595. uint8 buf[PACKET_LEN_SE_GET_SCHEDULED_EVENT];
  1596. osal_buffer_uint32( buf, pCmd->startTime );
  1597. buf[4] = pCmd->numEvents;
  1598. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  1599. COMMAND_SE_GET_SCHEDULED_EVENT, TRUE,
  1600. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum,
  1601. PACKET_LEN_SE_GET_SCHEDULED_EVENT, buf );
  1602. }
  1603. #endif // ZCL_LOAD_CONTROL
  1604. #ifdef ZCL_PREPAYMENT
  1605. /*********************************************************************
  1606. * @fn zclSE_Prepayment_Send_SelAvailEmergencyCredit
  1607. *
  1608. * @brief Call to send out a Select Available Emergency Credit command
  1609. *
  1610. * @param srcEP - Sending application's endpoint
  1611. * @param dstAddr - where you want the message to go
  1612. * @param pCmd - command payload
  1613. * @param disableDefaultRsp - disable default response
  1614. * @param seqNum - ZCL sequence number
  1615. *
  1616. * @return ZStatus_t
  1617. */
  1618. ZStatus_t zclSE_Prepayment_Send_SelAvailEmergencyCredit( uint8 srcEP,
  1619. afAddrType_t *dstAddr,
  1620. zclCCSelAvailEmergencyCredit_t *pCmd,
  1621. uint8 disableDefaultRsp,
  1622. uint8 seqNum )
  1623. {
  1624. uint8 *buf;
  1625. uint8 *pBuf;
  1626. uint8 bufLen;
  1627. ZStatus_t status;
  1628. // include in length all variable length fields
  1629. bufLen = PACKET_LEN_SE_SEL_AVAIL_EMERGENCY_CREDIT +
  1630. pCmd->siteId.strLen +
  1631. pCmd->meterSerialNumber.strLen;
  1632. buf = osal_mem_alloc( bufLen );
  1633. if ( buf == NULL )
  1634. {
  1635. return ( ZMemError );
  1636. }
  1637. pBuf = osal_buffer_uint32( buf, pCmd->commandDateTime );
  1638. *pBuf++ = pCmd->originatingDevice;
  1639. *pBuf++ = pCmd->siteId.strLen;
  1640. pBuf = osal_memcpy( pBuf, pCmd->siteId.pStr, pCmd->siteId.strLen );
  1641. *pBuf++ = pCmd->meterSerialNumber.strLen;
  1642. osal_memcpy( pBuf, pCmd->meterSerialNumber.pStr, pCmd->meterSerialNumber.strLen );
  1643. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1644. COMMAND_SE_SEL_AVAIL_EMERGENCY_CREDIT, TRUE,
  1645. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1646. seqNum, bufLen, buf );
  1647. osal_mem_free( buf );
  1648. return status;
  1649. }
  1650. #ifndef SE_UK_EXT
  1651. /*********************************************************************
  1652. * @fn zclSE_Prepayment_Send_ChangeSupply
  1653. *
  1654. * @brief Call to send out a Change Supply command
  1655. *
  1656. * @param srcEP - Sending application's endpoint
  1657. * @param dstAddr - where you want the message to go
  1658. * @param pCmd - command payload
  1659. * @param disableDefaultRsp - disable default response
  1660. * @param seqNum - ZCL sequence number
  1661. *
  1662. * @return ZStatus_t
  1663. */
  1664. ZStatus_t zclSE_Prepayment_Send_ChangeSupply( uint8 srcEP, afAddrType_t *dstAddr,
  1665. zclCCChangeSupply_t *pCmd,
  1666. uint8 disableDefaultRsp,
  1667. uint8 seqNum )
  1668. {
  1669. uint8 *buf;
  1670. uint8 *pBuf;
  1671. uint8 bufLen;
  1672. ZStatus_t status;
  1673. // include in length all variable length fields
  1674. bufLen = PACKET_LEN_SE_CHANGE_SUPPLY +
  1675. pCmd->siteId.strLen +
  1676. pCmd->meterSerialNumber.strLen;
  1677. buf = osal_mem_alloc( bufLen );
  1678. if ( buf == NULL )
  1679. {
  1680. return ( ZMemError );
  1681. }
  1682. pBuf = osal_buffer_uint32( buf, pCmd->providerId );
  1683. pBuf = osal_buffer_uint32( pBuf, pCmd->requestDateTime );
  1684. *pBuf++ = pCmd->siteId.strLen;
  1685. pBuf = osal_memcpy( pBuf, pCmd->siteId.pStr, pCmd->siteId.strLen );
  1686. *pBuf++ = pCmd->meterSerialNumber.strLen;
  1687. pBuf = osal_memcpy( pBuf, pCmd->meterSerialNumber.pStr, pCmd->meterSerialNumber.strLen );
  1688. pBuf = osal_buffer_uint32( pBuf, pCmd->implementationDateTime );
  1689. *pBuf++ = pCmd->proposedSupplyStatus;
  1690. *pBuf = pCmd->origIdSupplyControlBits;
  1691. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1692. COMMAND_SE_CHANGE_SUPPLY, TRUE,
  1693. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1694. seqNum, bufLen, buf );
  1695. osal_mem_free( buf );
  1696. return status;
  1697. }
  1698. /*********************************************************************
  1699. * @fn zclSE_Prepayment_Send_SupplyStatusResponse
  1700. *
  1701. * @brief Call to send out a Supply Status Response
  1702. *
  1703. * @param srcEP - Sending application's endpoint
  1704. * @param dstAddr - where you want the message to go
  1705. * @param pCmd - command payload
  1706. * @param disableDefaultRsp - disable default response
  1707. * @param seqNum - ZCL sequence number
  1708. *
  1709. * @return ZStatus_t
  1710. */
  1711. ZStatus_t zclSE_Prepayment_Send_SupplyStatusResponse( uint8 srcEP,
  1712. afAddrType_t *dstAddr,
  1713. zclCCSupplyStatusResponse_t *pCmd,
  1714. uint8 disableDefaultRsp,
  1715. uint8 seqNum )
  1716. {
  1717. uint8 *buf;
  1718. uint8 *pBuf;
  1719. ZStatus_t status;
  1720. buf = osal_mem_alloc( PACKET_LEN_SE_SUPPLY_STATUS_RESPONSE );
  1721. if ( buf == NULL )
  1722. {
  1723. return ( ZMemError );
  1724. }
  1725. pBuf = osal_buffer_uint32( buf, pCmd->providerId );
  1726. pBuf = osal_buffer_uint32( pBuf, pCmd->implementationDateTime );
  1727. *pBuf = pCmd->supplyStatus;
  1728. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1729. COMMAND_SE_SUPPLY_STATUS_RESPONSE, TRUE,
  1730. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  1731. seqNum, PACKET_LEN_SE_SUPPLY_STATUS_RESPONSE, buf );
  1732. osal_mem_free( buf );
  1733. return status;
  1734. }
  1735. #else // SE_UK_EXT
  1736. /*********************************************************************
  1737. * @fn zclSE_Prepayment_Send_ChangeDebt
  1738. *
  1739. * @brief Call to send out a Change Debt
  1740. *
  1741. * @param srcEP - Sending application's endpoint
  1742. * @param dstAddr - where you want the message to go
  1743. * @param pCmd - command payload
  1744. * @param disableDefaultRsp - disable default response
  1745. * @param seqNum - ZCL sequence number
  1746. *
  1747. * @return ZStatus_t
  1748. */
  1749. ZStatus_t zclSE_Prepayment_Send_ChangeDebt( uint8 srcEP, afAddrType_t *dstAddr,
  1750. zclCCChangeDebt_t *pCmd,
  1751. uint8 disableDefaultRsp, uint8 seqNum )
  1752. {
  1753. uint8 *buf;
  1754. uint8 *pBuf;
  1755. ZStatus_t status;
  1756. uint8 bufLen = PACKET_LEN_SE_MIN_CHANGE_DEBT + pCmd->debtLabel.strLen + pCmd->signature.strLen;
  1757. buf = osal_mem_alloc( bufLen );
  1758. if ( buf == NULL )
  1759. {
  1760. return ( ZMemError );
  1761. }
  1762. pBuf = osal_buffer_uint32( buf, pCmd->cmdIssueTime );
  1763. *pBuf++ = pCmd->debtLabel.strLen;
  1764. pBuf = osal_memcpy( pBuf, pCmd->debtLabel.pStr, pCmd->debtLabel.strLen );
  1765. pBuf = osal_buffer_uint32( pBuf, pCmd->debtAmount );
  1766. *pBuf++ = pCmd->debtRecoveryMethod;
  1767. *pBuf++ = pCmd->debtType;
  1768. pBuf = osal_buffer_uint32( pBuf, pCmd->recoveryStartTime );
  1769. *pBuf++ = LO_UINT16( pCmd->debtRecoveryCollectionTime );
  1770. *pBuf++ = HI_UINT16( pCmd->debtRecoveryCollectionTime );
  1771. pBuf = osal_buffer_uint32( pBuf, pCmd->debtRecoveryFrequency );
  1772. pBuf = osal_buffer_uint32( pBuf, pCmd->debtRecoveryAmt );
  1773. *pBuf++ = LO_UINT16( pCmd->debtRecoveryBalancePct );
  1774. *pBuf++ = HI_UINT16( pCmd->debtRecoveryBalancePct );
  1775. *pBuf++ = pCmd->debtRecoveryMaxMissed;
  1776. *pBuf++ = pCmd->signature.strLen;
  1777. (void)osal_memcpy( pBuf, pCmd->signature.pStr, pCmd->signature.strLen );
  1778. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1779. COMMAND_SE_CHANGE_DEBT, TRUE,
  1780. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1781. seqNum, bufLen, buf );
  1782. osal_mem_free( buf );
  1783. return status;
  1784. }
  1785. /*********************************************************************
  1786. * @fn zclSE_Prepayment_Send_EmergencyCreditSetup
  1787. *
  1788. * @brief Call to send out a Emergency Credit Setup
  1789. *
  1790. * @param srcEP - Sending application's endpoint
  1791. * @param dstAddr - where you want the message to go
  1792. * @param pCmd - command payload
  1793. * @param disableDefaultRsp - disable default response
  1794. * @param seqNum - ZCL sequence number
  1795. *
  1796. * @return ZStatus_t
  1797. */
  1798. ZStatus_t zclSE_Prepayment_Send_EmergencyCreditSetup( uint8 srcEP, afAddrType_t *dstAddr,
  1799. zclCCEmergencyCreditSetup_t *pCmd,
  1800. uint8 disableDefaultRsp, uint8 seqNum )
  1801. {
  1802. uint8 buf[PACKET_LEN_SE_EMERGENCY_CREDIT_SETUP];
  1803. uint8 *pBuf;
  1804. pBuf = osal_buffer_uint32( buf, pCmd->cmdIssueTime );
  1805. pBuf = osal_buffer_uint32( pBuf, pCmd->emergencyCreditLimit );
  1806. pBuf = osal_buffer_uint32( pBuf, pCmd->emergencyCreditThreshold );
  1807. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1808. COMMAND_SE_EMERGENCY_CREDIT_SETUP, TRUE,
  1809. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1810. seqNum, PACKET_LEN_SE_EMERGENCY_CREDIT_SETUP, buf );
  1811. }
  1812. /*********************************************************************
  1813. * @fn zclSE_Prepayment_Send_ConsumerTopup
  1814. *
  1815. * @brief Call to send out a Consumer Topup
  1816. *
  1817. * @param srcEP - Sending application's endpoint
  1818. * @param dstAddr - where you want the message to go
  1819. * @param pCmd - command payload
  1820. * @param disableDefaultRsp - disable default response
  1821. * @param seqNum - ZCL sequence number
  1822. *
  1823. * @return ZStatus_t
  1824. */
  1825. ZStatus_t zclSE_Prepayment_Send_ConsumerTopup( uint8 srcEP, afAddrType_t *dstAddr,
  1826. zclCCConsumerTopup_t *pCmd,
  1827. uint8 disableDefaultRsp, uint8 seqNum )
  1828. {
  1829. uint8 *buf;
  1830. uint8 *pBuf;
  1831. ZStatus_t status;
  1832. uint8 bufLen = PACKET_LEN_SE_MIN_CONSUMER_TOPUP + pCmd->topupCode.strLen;
  1833. buf = osal_mem_alloc( bufLen );
  1834. if ( buf == NULL )
  1835. {
  1836. return ( ZMemError );
  1837. }
  1838. pBuf = buf;
  1839. *pBuf++ = pCmd->originatingDevice;
  1840. *pBuf++ = pCmd->topupCode.strLen;
  1841. pBuf = osal_memcpy( pBuf, pCmd->topupCode.pStr, pCmd->topupCode.strLen );
  1842. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1843. COMMAND_SE_CONSUMER_TOPUP, TRUE,
  1844. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1845. seqNum, bufLen, buf );
  1846. osal_mem_free( buf );
  1847. return status;
  1848. }
  1849. /*********************************************************************
  1850. * @fn zclSE_Prepayment_Send_CreditAdjustment
  1851. *
  1852. * @brief Call to send out a Credit Adjustment
  1853. *
  1854. * @param srcEP - Sending application's endpoint
  1855. * @param dstAddr - where you want the message to go
  1856. * @param pCmd - command payload
  1857. * @param disableDefaultRsp - disable default response
  1858. * @param seqNum - ZCL sequence number
  1859. *
  1860. * @return ZStatus_t
  1861. */
  1862. ZStatus_t zclSE_Prepayment_Send_CreditAdjustment( uint8 srcEP, afAddrType_t *dstAddr,
  1863. zclCCCreditAdjustment_t *pCmd,
  1864. uint8 disableDefaultRsp, uint8 seqNum )
  1865. {
  1866. uint8 *buf;
  1867. uint8 *pBuf;
  1868. ZStatus_t status;
  1869. uint8 bufLen = PACKET_LEN_SE_MIN_CREDIT_ADJUSTMENT + pCmd->signature.strLen;
  1870. buf = osal_mem_alloc( bufLen );
  1871. if ( buf == NULL )
  1872. {
  1873. return ( ZMemError );
  1874. }
  1875. pBuf = osal_buffer_uint32( buf, pCmd->cmdIssueTime );
  1876. *pBuf++ = pCmd->creditAdjustmentType;
  1877. pBuf = osal_memcpy( pBuf, pCmd->creditAdjustmentValue, 6 );
  1878. *pBuf++ = pCmd->signature.strLen;
  1879. pBuf = osal_memcpy( pBuf, pCmd->signature.pStr, pCmd->signature.strLen );
  1880. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1881. COMMAND_SE_CREDIT_ADJUSTMENT, TRUE,
  1882. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1883. seqNum, bufLen, buf );
  1884. osal_mem_free( buf );
  1885. return status;
  1886. }
  1887. /*********************************************************************
  1888. * @fn zclSE_Prepayment_Send_ChangePaymentMode
  1889. *
  1890. * @brief Call to send out a Change Payment Mode
  1891. *
  1892. * @param srcEP - Sending application's endpoint
  1893. * @param dstAddr - where you want the message to go
  1894. * @param pCmd - command payload
  1895. * @param disableDefaultRsp - disable default response
  1896. * @param seqNum - ZCL sequence number
  1897. *
  1898. * @return ZStatus_t
  1899. */
  1900. ZStatus_t zclSE_Prepayment_Send_ChangePaymentMode( uint8 srcEP, afAddrType_t *dstAddr,
  1901. zclCCChangePaymentMode_t *pCmd,
  1902. uint8 disableDefaultRsp, uint8 seqNum )
  1903. {
  1904. uint8 *buf;
  1905. uint8 *pBuf;
  1906. ZStatus_t status;
  1907. uint8 bufLen = PACKET_LEN_SE_MIN_CHANGE_PAYMENT_MODE + pCmd->signature.strLen;
  1908. buf = osal_mem_alloc( bufLen );
  1909. if ( buf == NULL )
  1910. {
  1911. return ( ZMemError );
  1912. }
  1913. pBuf = osal_buffer_uint32( buf, pCmd->supplierId );
  1914. pBuf = osal_buffer_uint32( pBuf, pCmd->modeEventId );
  1915. pBuf = osal_buffer_uint32( pBuf, pCmd->implementationDate );
  1916. *pBuf++ = pCmd->proposedPaymentControl;
  1917. pBuf = osal_buffer_uint32( pBuf, pCmd->cutOffValue );
  1918. *pBuf++ = pCmd->signature.strLen;
  1919. pBuf = osal_memcpy( pBuf, pCmd->signature.pStr, pCmd->signature.strLen );
  1920. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1921. COMMAND_SE_CHANGE_PAYMENT_MODE, TRUE,
  1922. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1923. seqNum, bufLen, buf );
  1924. osal_mem_free( buf );
  1925. return status;
  1926. }
  1927. /*********************************************************************
  1928. * @fn zclSE_Prepayment_Send_GetPrepaySnapshot
  1929. *
  1930. * @brief Call to send out a Get Prepay Snapshot
  1931. *
  1932. * @param srcEP - Sending application's endpoint
  1933. * @param dstAddr - where you want the message to go
  1934. * @param pCmd - command payload
  1935. * @param disableDefaultRsp - disable default response
  1936. * @param seqNum - ZCL sequence number
  1937. *
  1938. * @return ZStatus_t
  1939. */
  1940. ZStatus_t zclSE_Prepayment_Send_GetPrepaySnapshot( uint8 srcEP, afAddrType_t *dstAddr,
  1941. zclCCGetPrepaySnapshot_t *pCmd,
  1942. uint8 disableDefaultRsp, uint8 seqNum )
  1943. {
  1944. uint8 buf[PACKET_LEN_SE_GET_PREPAY_SNAPSHOT];
  1945. uint8 *pBuf;
  1946. pBuf = osal_buffer_uint32( buf, pCmd->startTime );
  1947. *pBuf++ = pCmd->numberOfSnapshots;
  1948. *pBuf++ = LO_UINT16( pCmd->snapshotCause );
  1949. *pBuf = HI_UINT16( pCmd->snapshotCause );
  1950. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1951. COMMAND_SE_GET_PREPAY_SNAPSHOT, TRUE,
  1952. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1953. seqNum, PACKET_LEN_SE_GET_PREPAY_SNAPSHOT, buf );
  1954. }
  1955. /*********************************************************************
  1956. * @fn zclSE_Prepayment_Send_GetTopupLog
  1957. *
  1958. * @brief Call to send out a Get Topup Log
  1959. *
  1960. * @param srcEP - Sending application's endpoint
  1961. * @param dstAddr - where you want the message to go
  1962. * @param numEvents - number of events
  1963. * @param disableDefaultRsp - disable default response
  1964. * @param seqNum - ZCL sequence number
  1965. *
  1966. * @return ZStatus_t
  1967. */
  1968. ZStatus_t zclSE_Prepayment_Send_GetTopupLog( uint8 srcEP, afAddrType_t *dstAddr,
  1969. uint8 numEvents, uint8 disableDefaultRsp, uint8 seqNum )
  1970. {
  1971. uint8 buf[PACKET_LEN_SE_GET_TOPUP_LOG];
  1972. buf[0] = numEvents;
  1973. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1974. COMMAND_SE_GET_TOPUP_LOG, TRUE,
  1975. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  1976. seqNum, PACKET_LEN_SE_GET_TOPUP_LOG, buf );
  1977. }
  1978. /*********************************************************************
  1979. * @fn zclSE_Prepayment_Send_SetLowCreditWarningLevel
  1980. *
  1981. * @brief Call to send out a Set Low Credit Warning Level
  1982. *
  1983. * @param srcEP - Sending application's endpoint
  1984. * @param dstAddr - where you want the message to go
  1985. * @param warningLevel - warning level
  1986. * @param disableDefaultRsp - disable default response
  1987. * @param seqNum - ZCL sequence number
  1988. *
  1989. * @return ZStatus_t
  1990. */
  1991. ZStatus_t zclSE_Prepayment_Send_SetLowCreditWarningLevel( uint8 srcEP, afAddrType_t *dstAddr,
  1992. uint8 warningLevel,
  1993. uint8 disableDefaultRsp, uint8 seqNum )
  1994. {
  1995. uint8 buf[PACKET_LEN_SE_SET_LOW_CREDIT_WARNING_LEVEL];
  1996. buf[0] = warningLevel;
  1997. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  1998. COMMAND_SE_SET_LOW_CREDIT_WARNING_LEVEL, TRUE,
  1999. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2000. seqNum, PACKET_LEN_SE_SET_LOW_CREDIT_WARNING_LEVEL, buf );
  2001. }
  2002. /*********************************************************************
  2003. * @fn zclSE_Prepayment_Send_GetDebtRepaymentLog
  2004. *
  2005. * @brief Call to send out a Get Debt Repayment Log
  2006. *
  2007. * @param srcEP - Sending application's endpoint
  2008. * @param dstAddr - where you want the message to go
  2009. * @param pCmd - command payload
  2010. * @param disableDefaultRsp - disable default response
  2011. * @param seqNum - ZCL sequence number
  2012. *
  2013. * @return ZStatus_t
  2014. */
  2015. ZStatus_t zclSE_Prepayment_Send_GetDebtRepaymentLog( uint8 srcEP, afAddrType_t *dstAddr,
  2016. zclCCGetDebtRepaymentLog_t *pCmd,
  2017. uint8 disableDefaultRsp, uint8 seqNum )
  2018. {
  2019. uint8 buf[PACKET_LEN_SE_GET_DEBT_REPAYMENT_LOG];
  2020. buf[0] = pCmd->numberOfDebt;
  2021. buf[1] = pCmd->debtType;
  2022. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  2023. COMMAND_SE_GET_DEBT_REPAYMENT_LOG, TRUE,
  2024. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2025. seqNum, PACKET_LEN_SE_GET_DEBT_REPAYMENT_LOG, buf );
  2026. }
  2027. /*********************************************************************
  2028. * @fn zclSE_Prepayment_Send_GetPrepaySnapshotResponse
  2029. *
  2030. * @brief Call to send out a Get Prepay Snapshot Response
  2031. *
  2032. * @param srcEP - Sending application's endpoint
  2033. * @param dstAddr - where you want the message to go
  2034. * @param pCmd - command payload
  2035. * @param disableDefaultRsp - disable default response
  2036. * @param seqNum - ZCL sequence number
  2037. *
  2038. * @return ZStatus_t
  2039. */
  2040. ZStatus_t zclSE_Prepayment_Send_GetPrepaySnapshotResponse( uint8 srcEP, afAddrType_t *dstAddr,
  2041. zclCCGetPrepaySnapshotResponse_t *pCmd,
  2042. uint8 disableDefaultRsp, uint8 seqNum )
  2043. {
  2044. uint8 buf[PACKET_LEN_SE_GET_PREPAY_SNAPSHOT_RESPONSE];
  2045. uint8 *pBuf;
  2046. pBuf = osal_buffer_uint32( buf, pCmd->eventIssuerId );
  2047. pBuf = osal_buffer_uint32( pBuf, pCmd->snapshotTime );
  2048. *pBuf++ = pCmd->commandIndex;
  2049. *pBuf++ = LO_UINT16( pCmd->snapshotCause );
  2050. *pBuf++ = HI_UINT16( pCmd->snapshotCause );
  2051. *pBuf++ = pCmd->snapshotPayloadType;
  2052. pBuf = osal_buffer_uint32( pBuf, pCmd->payload.type1DebtRemaining );
  2053. pBuf = osal_buffer_uint32( pBuf, pCmd->payload.type2DebtRemaining );
  2054. pBuf = osal_buffer_uint32( pBuf, pCmd->payload.type3DebtRemaining );
  2055. pBuf = osal_buffer_uint32( pBuf, pCmd->payload.emergencyCreditRemaining );
  2056. pBuf = osal_buffer_uint32( pBuf, pCmd->payload.creditRemaining );
  2057. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  2058. COMMAND_SE_GET_PREPAY_SNAPSHOT_RESPONSE, TRUE,
  2059. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2060. seqNum, PACKET_LEN_SE_GET_PREPAY_SNAPSHOT_RESPONSE, buf );
  2061. }
  2062. /*********************************************************************
  2063. * @fn zclSE_Prepayment_Send_ChangePaymentModeResponse
  2064. *
  2065. * @brief Call to send out a Change Payment Mode Response
  2066. *
  2067. * @param srcEP - Sending application's endpoint
  2068. * @param dstAddr - where you want the message to go
  2069. * @param pCmd - command payload
  2070. * @param disableDefaultRsp - disable default response
  2071. * @param seqNum - ZCL sequence number
  2072. *
  2073. * @return ZStatus_t
  2074. */
  2075. ZStatus_t zclSE_Prepayment_Send_ChangePaymentModeResponse( uint8 srcEP, afAddrType_t *dstAddr,
  2076. zclCCChangePaymentModeResponse_t *pCmd,
  2077. uint8 disableDefaultRsp, uint8 seqNum )
  2078. {
  2079. uint8 buf[PACKET_LEN_SE_CHANGE_PAYMENT_MODE_RESPONSE];
  2080. uint8 *pBuf = buf;
  2081. *pBuf++ = pCmd->friendlyCredit;
  2082. pBuf = osal_buffer_uint32( pBuf, pCmd->friendlyCreditCalendar );
  2083. pBuf = osal_buffer_uint32( pBuf, pCmd->emergencyCreditLimit );
  2084. pBuf = osal_buffer_uint32( pBuf, pCmd->cmergencyCreditThreshold );
  2085. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  2086. COMMAND_SE_CHANGE_PAYMENT_MODE_RESPONSE, TRUE,
  2087. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2088. seqNum, PACKET_LEN_SE_CHANGE_PAYMENT_MODE_RESPONSE, buf );
  2089. }
  2090. /*********************************************************************
  2091. * @fn zclSE_Prepayment_Send_ConsumerTopupResponse
  2092. *
  2093. * @brief Call to send out a Consumer Topup Response
  2094. *
  2095. * @param srcEP - Sending application's endpoint
  2096. * @param dstAddr - where you want the message to go
  2097. * @param pCmd - command payload
  2098. * @param disableDefaultRsp - disable default response
  2099. * @param seqNum - ZCL sequence number
  2100. *
  2101. * @return ZStatus_t
  2102. */
  2103. ZStatus_t zclSE_Prepayment_Send_ConsumerTopupResponse( uint8 srcEP, afAddrType_t *dstAddr,
  2104. zclCCConsumerTopupResponse_t *pCmd,
  2105. uint8 disableDefaultRsp, uint8 seqNum )
  2106. {
  2107. uint8 buf[PACKET_LEN_SE_SE_CONSUMER_TOPUP_RESPONSE];
  2108. uint8 *pBuf = buf;
  2109. *pBuf++ = pCmd->resultType;
  2110. pBuf = osal_buffer_uint32( pBuf, pCmd->topupValue );
  2111. *pBuf++ = pCmd->sourceofTopup;
  2112. pBuf = osal_buffer_uint32( pBuf, pCmd->creditRemaining );
  2113. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  2114. COMMAND_SE_CONSUMER_TOPUP_RESPONSE, TRUE,
  2115. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2116. seqNum, PACKET_LEN_SE_SE_CONSUMER_TOPUP_RESPONSE, buf );
  2117. }
  2118. /*********************************************************************
  2119. * @fn zclSE_Prepayment_Send_GetCommands
  2120. *
  2121. * @brief Call to send out a Get Commands
  2122. *
  2123. * @param srcEP - Sending application's endpoint
  2124. * @param dstAddr - where you want the message to go
  2125. * @param notificationFlags - notification flags
  2126. * @param disableDefaultRsp - disable default response
  2127. * @param seqNum - ZCL sequence number
  2128. *
  2129. * @return ZStatus_t
  2130. */
  2131. ZStatus_t zclSE_Prepayment_Send_GetCommands( uint8 srcEP, afAddrType_t *dstAddr,
  2132. uint8 notificationFlags, uint8 disableDefaultRsp, uint8 seqNum )
  2133. {
  2134. uint8 buf[PACKET_LEN_SE_GET_COMMANDS];
  2135. buf[0] = notificationFlags;
  2136. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  2137. COMMAND_SE_GET_COMMANDS, TRUE,
  2138. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2139. seqNum, PACKET_LEN_SE_GET_COMMANDS, buf );
  2140. }
  2141. /*********************************************************************
  2142. * @fn zclSE_Prepayment_Send_PublishTopupLog
  2143. *
  2144. * @brief Call to send out a Publish Topup Log
  2145. *
  2146. * @param srcEP - Sending application's endpoint
  2147. * @param dstAddr - where you want the message to go
  2148. * @param pCmd - command payload
  2149. * @param disableDefaultRsp - disable default response
  2150. * @param seqNum - ZCL sequence number
  2151. *
  2152. * @return ZStatus_t
  2153. */
  2154. ZStatus_t zclSE_Prepayment_Send_PublishTopupLog( uint8 srcEP, afAddrType_t *dstAddr,
  2155. zclCCPublishTopupLog_t *pCmd,
  2156. uint8 disableDefaultRsp, uint8 seqNum )
  2157. {
  2158. uint8 *buf;
  2159. uint8 *pBuf;
  2160. ZStatus_t status;
  2161. uint8 bufLen = PACKET_LEN_SE_MIN_PUBLISH_TOPUP_LOG + (pCmd->numCodes * SE_TOPUP_CODE_LEN);
  2162. uint8 i;
  2163. buf = osal_mem_alloc( bufLen );
  2164. if ( buf == NULL )
  2165. {
  2166. return ( ZMemError );
  2167. }
  2168. pBuf = buf;
  2169. *pBuf++ = pCmd->cmdIndex;
  2170. *pBuf++ = pCmd->totalCmds;
  2171. bufLen = 2;
  2172. for ( i = 0; i < pCmd->numCodes; i++ )
  2173. {
  2174. *pBuf++ = pCmd->pPayload[i].strLen;
  2175. pBuf = osal_memcpy( pBuf, pCmd->pPayload[i].pStr, pCmd->pPayload[i].strLen );
  2176. bufLen += 1 + pCmd->pPayload[i].strLen;
  2177. }
  2178. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  2179. COMMAND_SE_PUBLISH_TOPUP_LOG, TRUE,
  2180. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2181. seqNum, bufLen, buf );
  2182. osal_mem_free( buf );
  2183. return status;
  2184. }
  2185. /*********************************************************************
  2186. * @fn zclSE_Prepayment_Send_PublishDebtLog
  2187. *
  2188. * @brief Call to send out a Publish Debt Log
  2189. *
  2190. * @param srcEP - Sending application's endpoint
  2191. * @param dstAddr - where you want the message to go
  2192. * @param pCmd - command payload
  2193. * @param disableDefaultRsp - disable default response
  2194. * @param seqNum - ZCL sequence number
  2195. *
  2196. * @return ZStatus_t
  2197. */
  2198. ZStatus_t zclSE_Prepayment_Send_PublishDebtLog( uint8 srcEP, afAddrType_t *dstAddr,
  2199. zclCCPublishDebtLog_t *pCmd,
  2200. uint8 disableDefaultRsp, uint8 seqNum )
  2201. {
  2202. uint8 *buf;
  2203. uint8 *pBuf;
  2204. ZStatus_t status;
  2205. uint8 bufLen = PACKET_LEN_SE_MIN_PUBLISH_DEBT_LOG + (pCmd->numDebts * sizeof(zclCCDebtPayload_t));
  2206. uint8 i;
  2207. buf = osal_mem_alloc( bufLen );
  2208. if ( buf == NULL )
  2209. {
  2210. return ( ZMemError );
  2211. }
  2212. pBuf = buf;
  2213. *pBuf++ = pCmd->cmdIndex;
  2214. *pBuf++ = pCmd->totalCmds;
  2215. for ( i = 0; i < pCmd->numDebts; i++ )
  2216. {
  2217. pBuf = osal_buffer_uint32( pBuf, pCmd->pPayload[i].collectionTime );
  2218. pBuf = osal_buffer_uint32( pBuf, pCmd->pPayload[i].amountCollected );
  2219. *pBuf++ = pCmd->pPayload[i].debtType;
  2220. pBuf = osal_buffer_uint32( pBuf, pCmd->pPayload[i].outstandingDebt );
  2221. }
  2222. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_PREPAYMENT,
  2223. COMMAND_SE_PUBLISH_DEBT_LOG, TRUE,
  2224. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2225. seqNum, bufLen, buf );
  2226. osal_mem_free( buf );
  2227. return status;
  2228. }
  2229. #endif //SE_UK_EXT
  2230. #endif // ZCL_PREPAYMENT
  2231. #ifdef ZCL_TUNNELING
  2232. /*********************************************************************
  2233. * @fn zclSE_Tunneling_Send_RequestTunnel
  2234. *
  2235. * @brief Call to send out a Request Tunnel
  2236. *
  2237. * @param srcEP - Sending application's endpoint
  2238. * @param dstAddr - where you want the message to go
  2239. * @param pCmd - command payload
  2240. * @param disableDefaultRsp - disable default response
  2241. * @param seqNum - ZCL sequence number
  2242. *
  2243. * @return ZStatus_t
  2244. */
  2245. ZStatus_t zclSE_Tunneling_Send_RequestTunnel( uint8 srcEP, afAddrType_t *dstAddr,
  2246. zclCCRequestTunnel_t *pCmd,
  2247. uint8 disableDefaultRsp, uint8 seqNum )
  2248. {
  2249. uint8 *buf;
  2250. uint8 *pBuf;
  2251. ZStatus_t status;
  2252. buf = osal_mem_alloc( PACKET_LEN_SE_TUNNELING_REQUEST );
  2253. if ( buf == NULL )
  2254. {
  2255. return ZMemError;
  2256. }
  2257. pBuf = buf;
  2258. *pBuf++ = pCmd->protocolId;
  2259. *pBuf++ = LO_UINT16( pCmd->manufacturerCode );
  2260. *pBuf++ = HI_UINT16( pCmd->manufacturerCode );
  2261. *pBuf++ = pCmd->flowControlSupport;
  2262. *pBuf++ = LO_UINT16( pCmd->maxInTransferSize );
  2263. *pBuf = HI_UINT16( pCmd->maxInTransferSize );
  2264. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2265. COMMAND_SE_REQUEST_TUNNEL, TRUE,
  2266. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2267. seqNum, PACKET_LEN_SE_TUNNELING_REQUEST, buf );
  2268. osal_mem_free( buf );
  2269. return status;
  2270. }
  2271. /*********************************************************************
  2272. * @fn zclSE_Tunneling_Send_ReqTunnelRsp
  2273. *
  2274. * @brief Call to send out a Request Tunnel Response
  2275. *
  2276. * @param srcEP - Sending application's endpoint
  2277. * @param dstAddr - where you want the message to go
  2278. * @param pCmd - command payload
  2279. * @param disableDefaultRsp - disable default response
  2280. * @param seqNum - ZCL sequence number
  2281. *
  2282. * @return ZStatus_t
  2283. */
  2284. extern ZStatus_t zclSE_Tunneling_Send_ReqTunnelRsp( uint8 srcEP, afAddrType_t *dstAddr,
  2285. zclCCReqTunnelRsp_t *pCmd,
  2286. uint8 disableDefaultRsp, uint8 seqNum )
  2287. {
  2288. uint8 *buf;
  2289. uint8 *pBuf;
  2290. ZStatus_t status;
  2291. buf = osal_mem_alloc( PACKET_LEN_SE_TUNNELING_RESPONSE );
  2292. if ( buf == NULL )
  2293. {
  2294. return ZMemError;
  2295. }
  2296. pBuf = buf;
  2297. *pBuf++ = LO_UINT16( pCmd->tunnelId ) ;
  2298. *pBuf++ = HI_UINT16( pCmd->tunnelId );
  2299. *pBuf++ = pCmd->tunnelStatus;
  2300. *pBuf++ = LO_UINT16( pCmd->maxInTransferSize ) ;
  2301. *pBuf = HI_UINT16( pCmd->maxInTransferSize );
  2302. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2303. COMMAND_SE_REQUEST_TUNNEL_RESPONSE, TRUE,
  2304. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2305. seqNum, PACKET_LEN_SE_TUNNELING_RESPONSE, buf );
  2306. osal_mem_free( buf );
  2307. return status;
  2308. }
  2309. /*********************************************************************
  2310. * @fn zclSE_Tunneling_Send_CloseTunnel
  2311. *
  2312. * @brief Call to send out a Close Tunnel
  2313. *
  2314. * @param srcEP - Sending application's endpoint
  2315. * @param dstAddr - where you want the message to go
  2316. * @param pCmd - command payload
  2317. * @param disableDefaultRsp - disable default response
  2318. * @param seqNum - ZCL sequence number
  2319. *
  2320. * @return ZStatus_t
  2321. */
  2322. ZStatus_t zclSE_Tunneling_Send_CloseTunnel( uint8 srcEP, afAddrType_t *dstAddr,
  2323. zclCCCloseTunnel_t *pCmd,
  2324. uint8 disableDefaultRsp, uint8 seqNum )
  2325. {
  2326. uint8 buf[PACKET_LEN_SE_TUNNELING_CLOSE];
  2327. ZStatus_t status;
  2328. buf[0] = LO_UINT16( pCmd->tunnelId );
  2329. buf[1] = HI_UINT16( pCmd->tunnelId );
  2330. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2331. COMMAND_SE_CLOSE_TUNNEL, TRUE,
  2332. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2333. seqNum, PACKET_LEN_SE_TUNNELING_CLOSE, buf );
  2334. return status;
  2335. }
  2336. /*********************************************************************
  2337. * @fn zclSE_Tunneling_Send_TransferData
  2338. *
  2339. * @brief Call to send out a Transfer Data
  2340. *
  2341. * @param srcEP - Sending application's endpoint
  2342. * @param dstAddr - where you want the message to go
  2343. * @param pCmd - command payload
  2344. * @param cmdId - command identifier
  2345. * @param dataLen - length of transported data
  2346. * @param disableDefaultRsp - disable default response
  2347. * @param seqNum - ZCL sequence number
  2348. *
  2349. * @return ZStatus_t
  2350. */
  2351. ZStatus_t zclSE_Tunneling_Send_TransferData( uint8 srcEP, afAddrType_t *dstAddr,
  2352. zclCCTransferData_t *pCmd, uint8 cmdId,
  2353. uint16 dataLen, uint8 disableDefaultRsp, uint8 seqNum )
  2354. {
  2355. uint8 *buf;
  2356. uint8 *pBuf;
  2357. uint8 bufLen;
  2358. ZStatus_t status;
  2359. uint8 direction;
  2360. bufLen = PACKET_LEN_SE_TUNNELING_TRANSFER_DATA + dataLen;
  2361. buf = osal_mem_alloc( bufLen );
  2362. if ( buf == NULL )
  2363. {
  2364. return ZMemError;
  2365. }
  2366. pBuf = buf;
  2367. *pBuf++ = LO_UINT16( pCmd->tunnelId );
  2368. *pBuf++ = HI_UINT16( pCmd->tunnelId );
  2369. if ( cmdId == COMMAND_SE_DATA_CLIENT_SERVER_DIR )
  2370. {
  2371. direction = ZCL_FRAME_CLIENT_SERVER_DIR;
  2372. }
  2373. else
  2374. {
  2375. direction = ZCL_FRAME_SERVER_CLIENT_DIR;
  2376. }
  2377. osal_memcpy( pBuf, pCmd->data, dataLen );
  2378. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2379. cmdId, TRUE, direction, disableDefaultRsp, 0,
  2380. seqNum, bufLen, buf );
  2381. osal_mem_free( buf );
  2382. return status;
  2383. }
  2384. /*********************************************************************
  2385. * @fn zclSE_Tunneling_Send_TransferDataError
  2386. *
  2387. * @brief Call to send out a Transfer Data Error
  2388. *
  2389. * @param srcEP - Sending application's endpoint
  2390. * @param dstAddr - where you want the message to go
  2391. * @param pCmd - command payload
  2392. * @param cmdId - command identifier
  2393. * @param disableDefaultRsp - disable default response
  2394. * @param seqNum - ZCL sequence number
  2395. *
  2396. * @return ZStatus_t
  2397. */
  2398. ZStatus_t zclSE_Tunneling_Send_TransferDataError( uint8 srcEP, afAddrType_t *dstAddr,
  2399. zclCCTransferDataError_t *pCmd, uint8 cmdId,
  2400. uint8 disableDefaultRsp, uint8 seqNum )
  2401. {
  2402. uint8 buf[PACKET_LEN_SE_TUNNELING_DATA_ERROR];
  2403. ZStatus_t status;
  2404. uint8 direction;
  2405. buf[0] = LO_UINT16( pCmd->tunnelId );
  2406. buf[1] = HI_UINT16( pCmd->tunnelId );
  2407. buf[2] = pCmd->transferDataStatus;
  2408. if ( cmdId == COMMAND_SE_DATA_ERROR_CLIENT_SERVER_DIR)
  2409. {
  2410. direction = ZCL_FRAME_CLIENT_SERVER_DIR;
  2411. }
  2412. else
  2413. {
  2414. direction = ZCL_FRAME_SERVER_CLIENT_DIR;
  2415. }
  2416. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2417. cmdId, TRUE, direction, disableDefaultRsp, 0,
  2418. seqNum, PACKET_LEN_SE_TUNNELING_DATA_ERROR, buf );
  2419. return status;
  2420. }
  2421. /*********************************************************************
  2422. * @fn zclSE_Tunneling_Send_AckTransferData
  2423. *
  2424. * @brief Call to send out an Acknowledgment Transfer Data
  2425. *
  2426. * @param srcEP - Sending application's endpoint
  2427. * @param dstAddr - where you want the message to go
  2428. * @param pCmd - command payload
  2429. * @param cmdId - command identifier
  2430. * @param disableDefaultRsp - disable default response
  2431. * @param seqNum - ZCL sequence number
  2432. *
  2433. * @return ZStatus_t
  2434. */
  2435. ZStatus_t zclSE_Tunneling_Send_AckTransferData( uint8 srcEP, afAddrType_t *dstAddr,
  2436. zclCCAckTransferData_t *pCmd, uint8 cmdId,
  2437. uint8 disableDefaultRsp, uint8 seqNum )
  2438. {
  2439. uint8 buf[PACKET_LEN_SE_TUNNELING_DATA_ACK];
  2440. ZStatus_t status;
  2441. uint8 direction;
  2442. buf[0] = LO_UINT16( pCmd->tunnelId );
  2443. buf[1] = HI_UINT16( pCmd->tunnelId );
  2444. buf[2] = LO_UINT16( pCmd->numberOfBytesLeft );
  2445. buf[3] = HI_UINT16( pCmd->numberOfBytesLeft );
  2446. if ( cmdId == COMMAND_SE_ACK_SERVER_CLIENT_DIR )
  2447. {
  2448. direction = ZCL_FRAME_SERVER_CLIENT_DIR;
  2449. }
  2450. else
  2451. {
  2452. direction = ZCL_FRAME_CLIENT_SERVER_DIR;
  2453. }
  2454. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2455. cmdId, TRUE, direction, disableDefaultRsp, 0,
  2456. seqNum, PACKET_LEN_SE_TUNNELING_DATA_ACK, buf );
  2457. return status;
  2458. }
  2459. /*********************************************************************
  2460. * @fn zclSE_Tunneling_Send_ReadyData
  2461. *
  2462. * @brief Call to send out a Ready Data
  2463. *
  2464. * @param srcEP - Sending application's endpoint
  2465. * @param dstAddr - where you want the message to go
  2466. * @param pCmd - command payload
  2467. * @param cmdId - command identifier
  2468. * @param disableDefaultRsp - disable default response
  2469. * @param seqNum - ZCL sequence number
  2470. *
  2471. * @return ZStatus_t
  2472. */
  2473. ZStatus_t zclSE_Tunneling_Send_ReadyData( uint8 srcEP, afAddrType_t *dstAddr,
  2474. zclCCReadyData_t *pCmd, uint8 cmdId,
  2475. uint8 disableDefaultRsp, uint8 seqNum )
  2476. {
  2477. uint8 buf[PACKET_LEN_SE_TUNNELING_READY_DATA];
  2478. ZStatus_t status;
  2479. uint8 direction;
  2480. buf[0] = LO_UINT16( pCmd->tunnelId );
  2481. buf[1] = HI_UINT16( pCmd->tunnelId );
  2482. buf[2] = LO_UINT16( pCmd->numberOfOctetsLeft );
  2483. buf[3] = HI_UINT16( pCmd->numberOfOctetsLeft );
  2484. if ( cmdId == COMMAND_SE_READY_DATA_CLIENT_SERVER_DIR )
  2485. {
  2486. direction = ZCL_FRAME_CLIENT_SERVER_DIR;
  2487. }
  2488. else
  2489. {
  2490. direction = ZCL_FRAME_SERVER_CLIENT_DIR;
  2491. }
  2492. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2493. cmdId, TRUE, direction, disableDefaultRsp, 0,
  2494. seqNum, PACKET_LEN_SE_TUNNELING_READY_DATA, buf );
  2495. return status;
  2496. }
  2497. #ifdef SE_UK_EXT
  2498. /*********************************************************************
  2499. * @fn zclSE_Tunneling_Send_GetSuppTunnelProt
  2500. *
  2501. * @brief Call to send out a Get Supported Tunnel Protocols
  2502. *
  2503. * @param srcEP - Sending application's endpoint
  2504. * @param dstAddr - where you want the message to go
  2505. * @param pCmd - command payload
  2506. * @param disableDefaultRsp - disable default response
  2507. * @param seqNum - ZCL sequence number
  2508. *
  2509. * @return ZStatus_t
  2510. */
  2511. ZStatus_t zclSE_Tunneling_Send_GetSuppTunnelProt( uint8 srcEP, afAddrType_t *dstAddr,
  2512. zclCCGetSuppTunnProt_t *pCmd,
  2513. uint8 disableDefaultRsp, uint8 seqNum )
  2514. {
  2515. uint8 buf[PACKET_LEN_SE_TUNNELING_GET_SUPP_PROT];
  2516. ZStatus_t status;
  2517. buf[0] = pCmd->protocolOffset;
  2518. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2519. COMMAND_SE_GET_SUPP_TUNNEL_PROTOCOLS, TRUE,
  2520. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2521. seqNum, PACKET_LEN_SE_TUNNELING_GET_SUPP_PROT, buf );
  2522. return status;
  2523. }
  2524. /*********************************************************************
  2525. * @fn zclSE_Tunneling_Send_SuppTunnelProtRsp
  2526. *
  2527. * @brief Call to send out a Supported Tunnel Protocols Response
  2528. *
  2529. * @param srcEP - Sending application's endpoint
  2530. * @param dstAddr - where you want the message to go
  2531. * @param pCmd - command payload
  2532. * @param disableDefaultRsp - disable default response
  2533. * @param seqNum - ZCL sequence number
  2534. *
  2535. * @return ZStatus_t
  2536. */
  2537. ZStatus_t zclSE_Tunneling_Send_SuppTunnelProtRsp( uint8 srcEP, afAddrType_t *dstAddr,
  2538. zclCCSuppTunnProtRsp_t *pCmd,
  2539. uint8 disableDefaultRsp, uint8 seqNum )
  2540. {
  2541. uint8 *buf;
  2542. uint8 *pBuf;
  2543. uint8 bufLen;
  2544. uint8 i;
  2545. ZStatus_t status;
  2546. bufLen = PACKET_LEN_SE_TUNNELING_SUPP_PROT_RSP +
  2547. (pCmd->protocolCount * PACKET_LEN_SE_TUNNELING_PROTOCOL_PAYLOAD);
  2548. buf = osal_mem_alloc( bufLen );
  2549. if ( buf == NULL )
  2550. {
  2551. return ZMemError;
  2552. }
  2553. pBuf = buf;
  2554. *pBuf++ = pCmd->protocolListComp;
  2555. *pBuf++ = pCmd->protocolCount;
  2556. for ( i = 0; i < pCmd->protocolCount; i++ )
  2557. {
  2558. *pBuf++ = LO_UINT16( pCmd->protocol[i].manufacturerCode );
  2559. *pBuf++ = HI_UINT16( pCmd->protocol[i].manufacturerCode );
  2560. *pBuf++ = pCmd->protocol[i].protocolId;
  2561. }
  2562. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2563. COMMAND_SE_SUPP_TUNNEL_PROTOCOLS_RSP, TRUE,
  2564. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2565. seqNum, bufLen, buf );
  2566. osal_mem_free( buf );
  2567. return status;
  2568. }
  2569. /*********************************************************************
  2570. * @fn zclSE_Tunneling_Send_TunnelClosureNotification
  2571. *
  2572. * @brief Call to send out a Tunnel Closure Notification
  2573. *
  2574. * @param srcEP - Sending application's endpoint
  2575. * @param dstAddr - where you want the message to go
  2576. * @param pCmd - command payload
  2577. * @param disableDefaultRsp - disable default response
  2578. * @param seqNum - ZCL sequence number
  2579. *
  2580. * @return ZStatus_t
  2581. */
  2582. ZStatus_t zclSE_Tunneling_Send_TunnelClosureNotification( uint8 srcEP, afAddrType_t *dstAddr,
  2583. zclCCTunnelClosureNotification_t *pCmd,
  2584. uint8 disableDefaultRsp, uint8 seqNum )
  2585. {
  2586. uint8 buf[PACKET_LEN_SE_TUNNELING_TUNNEL_CLOSURE];
  2587. ZStatus_t status;
  2588. buf[0] = LO_UINT16( pCmd->tunnelId );
  2589. buf[1] = HI_UINT16( pCmd->tunnelId );
  2590. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  2591. COMMAND_SE_TUNNEL_CLOSURE_NOTIFICATION, TRUE,
  2592. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2593. seqNum, PACKET_LEN_SE_TUNNELING_TUNNEL_CLOSURE, buf );
  2594. return status;
  2595. }
  2596. #endif //SE_UK_EXT
  2597. #endif // ZCL_TUNNELING
  2598. #ifdef ZCL_TOU
  2599. #ifdef SE_UK_EXT
  2600. /*********************************************************************
  2601. * @fn zclSE_Tou_Send_PublishCalendar
  2602. *
  2603. * @brief Call to send out a Publish Calendar Command
  2604. *
  2605. * @param srcEP - Sending application's endpoint
  2606. * @param dstAddr - where you want the message to go
  2607. * @param pCmd - command payload
  2608. * @param disableDefaultRsp - disable default response
  2609. * @param seqNum - ZCL sequence number
  2610. *
  2611. * @return ZStatus_t
  2612. */
  2613. ZStatus_t zclSE_Tou_Send_PublishCalendar( uint8 srcEP, afAddrType_t *dstAddr,
  2614. zclCCPublishCalendar_t *pCmd,
  2615. uint8 disableDefaultRsp, uint8 seqNum )
  2616. {
  2617. uint8 *buf;
  2618. uint8 *pBuf;
  2619. uint16 bufLen;
  2620. ZStatus_t status;
  2621. bufLen = PACKET_LEN_SE_PUBLISH_CALENDAR + pCmd->calendarName.strLen;
  2622. buf = osal_mem_alloc( bufLen );
  2623. if ( buf == NULL )
  2624. {
  2625. return ( ZMemError );
  2626. }
  2627. pBuf = osal_buffer_uint32( buf, pCmd->issuerCalendarId );
  2628. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  2629. *pBuf++ = pCmd->calendarType;
  2630. *pBuf++ = pCmd->calendarTimeRef;
  2631. *pBuf++ = pCmd->calendarName.strLen;
  2632. pBuf = osal_memcpy( pBuf, pCmd->calendarName.pStr, pCmd->calendarName.strLen );
  2633. *pBuf++ = pCmd->numOfSeasons;
  2634. *pBuf++ = pCmd->numOfWeekProfiles;
  2635. *pBuf = pCmd->numOfDayProfiles;
  2636. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2637. COMMAND_SE_PUBLISH_CALENDAR, TRUE,
  2638. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2639. seqNum, bufLen, buf );
  2640. osal_mem_free( buf );
  2641. return status;
  2642. }
  2643. /*********************************************************************
  2644. * @fn zclSE_Tou_Send_PublishDayProfile
  2645. *
  2646. * @brief Call to send out a Publish Day Profile Command
  2647. *
  2648. * @param srcEP - Sending application's endpoint
  2649. * @param dstAddr - where you want the message to go
  2650. * @param pCmd - command payload
  2651. * @param disableDefaultRsp - disable default response
  2652. * @param seqNum - ZCL sequence number
  2653. *
  2654. * @return ZStatus_t
  2655. */
  2656. ZStatus_t zclSE_Tou_Send_PublishDayProfile( uint8 srcEP, afAddrType_t *dstAddr,
  2657. zclCCPublishDayProfile_t *pCmd,
  2658. uint8 disableDefaultRsp, uint8 seqNum )
  2659. {
  2660. uint8 *buf;
  2661. uint8 *pBuf;
  2662. uint16 bufLen;
  2663. ZStatus_t status;
  2664. uint8 i;
  2665. bufLen = PACKET_LEN_SE_PUBLISH_DAY_PROFILE + ( pCmd->numTransferEntries * SE_DAY_SCHEDULE_ENTRY_LEN );
  2666. buf = osal_mem_alloc( bufLen );
  2667. if ( buf == NULL )
  2668. {
  2669. return ( ZMemError );
  2670. }
  2671. pBuf = osal_buffer_uint32( buf, pCmd->issuerCalendarId );
  2672. *pBuf++ = pCmd->dayId;
  2673. *pBuf++ = pCmd->totalNumSchedEnt;
  2674. *pBuf++ = pCmd->commandIndex;
  2675. for ( i = 0; i < pCmd->numTransferEntries; i++ )
  2676. {
  2677. if ( pCmd->issuerCalendarId <= SE_CALENDAR_TYPE_IMPORT_EXPORT_CALENDAR )
  2678. {
  2679. zclCCRateEntry_t *pRateEntry = (zclCCRateEntry_t *)pCmd->pScheduleEntries;
  2680. pRateEntry += i;
  2681. *pBuf++ = LO_UINT16( pRateEntry->startTime );
  2682. *pBuf++ = HI_UINT16( pRateEntry->startTime );
  2683. *pBuf++ = pRateEntry->activePriceTier;
  2684. }
  2685. else
  2686. {
  2687. zclCCFriendlyCreditEntry_t *pFriendlyEntry = (zclCCFriendlyCreditEntry_t *)pCmd->pScheduleEntries;
  2688. pFriendlyEntry += i;
  2689. *pBuf++ = LO_UINT16( pFriendlyEntry->startTime );
  2690. *pBuf++ = HI_UINT16( pFriendlyEntry->startTime );
  2691. *pBuf++ = pFriendlyEntry->friendCreditEnable;
  2692. }
  2693. }
  2694. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2695. COMMAND_SE_PUBLISH_DAY_PROFILE, TRUE,
  2696. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2697. seqNum, bufLen, buf );
  2698. osal_mem_free( buf );
  2699. return status;
  2700. }
  2701. /*********************************************************************
  2702. * @fn zclSE_Tou_Send_PublishWeekProfile
  2703. *
  2704. * @brief Call to send out a Publish Week Profile Command
  2705. *
  2706. * @param srcEP - Sending application's endpoint
  2707. * @param dstAddr - where you want the message to go
  2708. * @param pCmd - command payload
  2709. * @param disableDefaultRsp - disable default response
  2710. * @param seqNum - ZCL sequence number
  2711. *
  2712. * @return ZStatus_t
  2713. */
  2714. ZStatus_t zclSE_Tou_Send_PublishWeekProfile( uint8 srcEP, afAddrType_t *dstAddr,
  2715. zclCCPublishWeekProfile_t *pCmd,
  2716. uint8 disableDefaultRsp, uint8 seqNum )
  2717. {
  2718. uint8 *buf;
  2719. uint8 *pBuf;
  2720. ZStatus_t status;
  2721. buf = osal_mem_alloc( PACKET_LEN_SE_PUBLISH_WEEK_PROFILE );
  2722. if ( buf == NULL )
  2723. {
  2724. return ( ZMemError );
  2725. }
  2726. pBuf = osal_buffer_uint32( buf, pCmd->issuerCalendarId );
  2727. *pBuf++ = pCmd->weekId;
  2728. *pBuf++ = pCmd->dayIdRefMonday;
  2729. *pBuf++ = pCmd->dayIdRefTuestday;
  2730. *pBuf++ = pCmd->dayIdRefWednesday;
  2731. *pBuf++ = pCmd->dayIdRefThursday;
  2732. *pBuf++ = pCmd->dayIdRefFriday;
  2733. *pBuf++ = pCmd->dayIdRefSaturday;
  2734. *pBuf = pCmd->dayIdRefSunday;
  2735. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2736. COMMAND_SE_PUBLISH_WEEK_PROFILE, TRUE,
  2737. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2738. seqNum, PACKET_LEN_SE_PUBLISH_WEEK_PROFILE, buf );
  2739. osal_mem_free( buf );
  2740. return status;
  2741. }
  2742. /*********************************************************************
  2743. * @fn zclSE_Tou_Send_PublishSeasons
  2744. *
  2745. * @brief Call to send out a Publish Seasons Command
  2746. *
  2747. * @param srcEP - Sending application's endpoint
  2748. * @param dstAddr - where you want the message to go
  2749. * @param pCmd - command payload
  2750. * @param disableDefaultRsp - disable default response
  2751. * @param seqNum - ZCL sequence number
  2752. *
  2753. * @return ZStatus_t
  2754. */
  2755. ZStatus_t zclSE_Tou_Send_PublishSeasons( uint8 srcEP, afAddrType_t *dstAddr,
  2756. zclCCPublishSeasons_t *pCmd,
  2757. uint8 disableDefaultRsp, uint8 seqNum )
  2758. {
  2759. uint8 *buf;
  2760. uint8 *pBuf;
  2761. uint16 bufLen;
  2762. ZStatus_t status;
  2763. uint8 i;
  2764. bufLen = PACKET_LEN_SE_PUBLISH_SEASONS + ( pCmd->numTransferEntries * SE_SEASON_ENTRY_LEN );
  2765. buf = osal_mem_alloc( bufLen );
  2766. if ( buf == NULL )
  2767. {
  2768. return ( ZMemError );
  2769. }
  2770. pBuf = osal_buffer_uint32( buf, pCmd->issuerCalendarId );
  2771. *pBuf++ = pCmd->commandIndex;
  2772. for ( i = 0; i < pCmd->numTransferEntries; i++ )
  2773. {
  2774. zclCCSeasonEntry_t *pEntry = &( pCmd->pSeasonEntry[i] );
  2775. pBuf = osal_buffer_uint32( pBuf, pEntry->seasonStartDate );
  2776. *pBuf++ = pEntry->weekIdRef;
  2777. }
  2778. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2779. COMMAND_SE_PUBLISH_SEASONS, TRUE,
  2780. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2781. seqNum, bufLen, buf );
  2782. osal_mem_free( buf );
  2783. return status;
  2784. }
  2785. /*********************************************************************
  2786. * @fn zclSE_Tou_Send_PublishSpecialDays
  2787. *
  2788. * @brief Call to send out a Publish Special Days Command
  2789. *
  2790. * @param srcEP - Sending application's endpoint
  2791. * @param dstAddr - where you want the message to go
  2792. * @param pCmd - command payload
  2793. * @param disableDefaultRsp - disable default response
  2794. * @param seqNum - ZCL sequence number
  2795. *
  2796. * @return ZStatus_t
  2797. */
  2798. ZStatus_t zclSE_Tou_Send_PublishSpecialDays( uint8 srcEP, afAddrType_t *dstAddr,
  2799. zclCCPublishSpecialDays_t *pCmd,
  2800. uint8 disableDefaultRsp, uint8 seqNum )
  2801. {
  2802. uint8 *buf;
  2803. uint8 *pBuf;
  2804. uint16 bufLen;
  2805. ZStatus_t status;
  2806. uint8 i;
  2807. bufLen = PACKET_LEN_SE_PUBLISH_SPECIAL_DAYS + ( pCmd->numTransferEntries * SE_SPECIAL_DAY_ENTRY_LEN );
  2808. buf = osal_mem_alloc( bufLen );
  2809. if ( buf == NULL )
  2810. {
  2811. return ( ZMemError );
  2812. }
  2813. pBuf = osal_buffer_uint32( buf, pCmd->issuerEventId );
  2814. pBuf = osal_buffer_uint32( pBuf, pCmd->startTime );
  2815. *pBuf++ = pCmd->calendarType;
  2816. *pBuf++ = pCmd->totalNumSpecialDays;
  2817. *pBuf++ = pCmd->commandIndex;
  2818. for ( i = 0; i < pCmd->numTransferEntries; i++ )
  2819. {
  2820. zclCCSpecialDayEntry_t *pEntry = &( pCmd->pSpecialDayEntry[i] );
  2821. pBuf = osal_buffer_uint32( pBuf, pEntry->specialDayDate );
  2822. *pBuf++ = pEntry->dayIdRef;
  2823. }
  2824. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2825. COMMAND_SE_PUBLISH_SPECIAL_DAYS, TRUE,
  2826. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  2827. seqNum, bufLen, buf );
  2828. osal_mem_free( buf );
  2829. return status;
  2830. }
  2831. /*********************************************************************
  2832. * @fn zclSE_Tou_Send_GetCalendar
  2833. *
  2834. * @brief Call to send out a Get Calendar Command
  2835. *
  2836. * @param srcEP - Sending application's endpoint
  2837. * @param dstAddr - where you want the message to go
  2838. * @param pCmd - command payload
  2839. * @param disableDefaultRsp - disable default response
  2840. * @param seqNum - ZCL sequence number
  2841. *
  2842. * @return ZStatus_t
  2843. */
  2844. ZStatus_t zclSE_Tou_Send_GetCalendar( uint8 srcEP, afAddrType_t *dstAddr,
  2845. zclCCGetCalendar_t *pCmd,
  2846. uint8 disableDefaultRsp, uint8 seqNum )
  2847. {
  2848. uint8 buf[PACKET_LEN_SE_GET_CALENDAR];
  2849. ZStatus_t status;
  2850. osal_buffer_uint32( buf, pCmd->startTime );
  2851. buf[4] = pCmd->numOfCalendars;
  2852. buf[5] = pCmd->calendarType;
  2853. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2854. COMMAND_SE_GET_CALENDAR, TRUE,
  2855. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2856. seqNum, PACKET_LEN_SE_GET_CALENDAR, buf );
  2857. return status;
  2858. }
  2859. /*********************************************************************
  2860. * @fn zclSE_Tou_Send_GetDayProfiles
  2861. *
  2862. * @brief Call to send out a Get Day Profiles Command
  2863. *
  2864. * @param srcEP - Sending application's endpoint
  2865. * @param dstAddr - where you want the message to go
  2866. * @param pCmd - command payload
  2867. * @param disableDefaultRsp - disable default response
  2868. * @param seqNum - ZCL sequence number
  2869. *
  2870. * @return ZStatus_t
  2871. */
  2872. ZStatus_t zclSE_Tou_Send_GetDayProfiles( uint8 srcEP, afAddrType_t *dstAddr,
  2873. zclCCGetDayProfiles_t *pCmd,
  2874. uint8 disableDefaultRsp, uint8 seqNum )
  2875. {
  2876. uint8 buf[PACKET_LEN_SE_GET_DAY_PROFILE];
  2877. ZStatus_t status;
  2878. osal_buffer_uint32( buf, pCmd->issuerCalendarId );
  2879. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2880. COMMAND_SE_GET_DAY_PROFILES, TRUE,
  2881. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2882. seqNum, PACKET_LEN_SE_GET_DAY_PROFILE, buf );
  2883. return status;
  2884. }
  2885. /*********************************************************************
  2886. * @fn zclSE_Tou_Send_GetWeekProfiles
  2887. *
  2888. * @brief Call to send out a Get Week Profiles Command
  2889. *
  2890. * @param srcEP - Sending application's endpoint
  2891. * @param dstAddr - where you want the message to go
  2892. * @param pCmd - command payload
  2893. * @param disableDefaultRsp - disable default response
  2894. * @param seqNum - ZCL sequence number
  2895. *
  2896. * @return ZStatus_t
  2897. */
  2898. ZStatus_t zclSE_Tou_Send_GetWeekProfiles( uint8 srcEP, afAddrType_t *dstAddr,
  2899. zclCCGetWeekProfiles_t *pCmd,
  2900. uint8 disableDefaultRsp, uint8 seqNum )
  2901. {
  2902. uint8 buf[PACKET_LEN_SE_GET_WEEK_PROFILE];
  2903. ZStatus_t status;
  2904. osal_buffer_uint32( buf, pCmd->issuerCalendarId );
  2905. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2906. COMMAND_SE_GET_WEEK_PROFILES, TRUE,
  2907. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2908. seqNum, PACKET_LEN_SE_GET_WEEK_PROFILE, buf );
  2909. return status;
  2910. }
  2911. /*********************************************************************
  2912. * @fn zclSE_Tou_Send_GetSeasons
  2913. *
  2914. * @brief Call to send out a Get Seasons Command
  2915. *
  2916. * @param srcEP - Sending application's endpoint
  2917. * @param dstAddr - where you want the message to go
  2918. * @param pCmd - command payload
  2919. * @param disableDefaultRsp - disable default response
  2920. * @param seqNum - ZCL sequence number
  2921. *
  2922. * @return ZStatus_t
  2923. */
  2924. ZStatus_t zclSE_Tou_Send_GetSeasons( uint8 srcEP, afAddrType_t *dstAddr,
  2925. zclCCGetSeasons_t *pCmd,
  2926. uint8 disableDefaultRsp, uint8 seqNum )
  2927. {
  2928. uint8 buf[PACKET_LEN_SE_GET_SEASONS];
  2929. ZStatus_t status;
  2930. osal_buffer_uint32( buf, pCmd->issuerCalendarId );
  2931. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2932. COMMAND_SE_GET_SEASONS, TRUE,
  2933. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2934. seqNum, PACKET_LEN_SE_GET_SEASONS, buf );
  2935. return status;
  2936. }
  2937. /*********************************************************************
  2938. * @fn zclSE_Tou_Send_GetSpecialDays
  2939. *
  2940. * @brief Call to send out a Get Special Days Command
  2941. *
  2942. * @param srcEP - Sending application's endpoint
  2943. * @param dstAddr - where you want the message to go
  2944. * @param pCmd - command payload
  2945. * @param disableDefaultRsp - disable default response
  2946. * @param seqNum - ZCL sequence number
  2947. *
  2948. * @return ZStatus_t
  2949. */
  2950. ZStatus_t zclSE_Tou_Send_GetSpecialDays( uint8 srcEP, afAddrType_t *dstAddr,
  2951. zclCCGetSpecialDays_t *pCmd,
  2952. uint8 disableDefaultRsp, uint8 seqNum )
  2953. {
  2954. uint8 buf[PACKET_LEN_SE_GET_SPECIAL_DAYS];
  2955. ZStatus_t status;
  2956. osal_buffer_uint32( buf, pCmd->startTime );
  2957. buf[4] = pCmd->numOfEvents;
  2958. buf[5] = pCmd->calendarType;
  2959. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_TOU_CALENDAR,
  2960. COMMAND_SE_GET_SPECIAL_DAYS, TRUE,
  2961. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2962. seqNum, PACKET_LEN_SE_GET_SPECIAL_DAYS, buf );
  2963. return status;
  2964. }
  2965. #endif // SE_UK_EXT
  2966. #endif // ZCL_TOU
  2967. #ifdef ZCL_DEVICE_MGMT
  2968. #ifdef SE_UK_EXT
  2969. /*********************************************************************
  2970. * @fn zclSE_DeviceMgmt_Send_GetChangeTenancy
  2971. *
  2972. * @brief Call to send out a Get Change of Tenancy Command
  2973. *
  2974. * @param srcEP - Sending application's endpoint
  2975. * @param dstAddr - where you want the message to go
  2976. * @param disableDefaultRsp - disable default response
  2977. * @param seqNum - ZCL sequence number
  2978. *
  2979. * @return ZStatus_t
  2980. */
  2981. ZStatus_t zclSE_DeviceMgmt_Send_GetChangeTenancy( uint8 srcEP, afAddrType_t *dstAddr,
  2982. uint8 disableDefaultRsp, uint8 seqNum )
  2983. {
  2984. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  2985. COMMAND_SE_GET_CHANGE_OF_TENANCY, TRUE,
  2986. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  2987. seqNum, 0, NULL );
  2988. }
  2989. /*********************************************************************
  2990. * @fn zclSE_DeviceMgmt_Send_GetChangeSupplier
  2991. *
  2992. * @brief Call to send out a Get Change of Supplier Command
  2993. *
  2994. * @param srcEP - Sending application's endpoint
  2995. * @param dstAddr - where you want the message to go
  2996. * @param disableDefaultRsp - disable default response
  2997. * @param seqNum - ZCL sequence number
  2998. *
  2999. * @return ZStatus_t
  3000. */
  3001. ZStatus_t zclSE_DeviceMgmt_Send_GetChangeSupplier( uint8 srcEP, afAddrType_t *dstAddr,
  3002. uint8 disableDefaultRsp, uint8 seqNum )
  3003. {
  3004. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3005. COMMAND_SE_GET_CHANGE_OF_SUPPLIER, TRUE,
  3006. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  3007. seqNum, 0, NULL );
  3008. }
  3009. /*********************************************************************
  3010. * @fn zclSE_DeviceMgmt_Send_GetChangeSupply
  3011. *
  3012. * @brief Call to send out a Get Change Supply Command
  3013. *
  3014. * @param srcEP - Sending application's endpoint
  3015. * @param dstAddr - where you want the message to go
  3016. * @param disableDefaultRsp - disable default response
  3017. * @param seqNum - ZCL sequence number
  3018. *
  3019. * @return ZStatus_t
  3020. */
  3021. ZStatus_t zclSE_DeviceMgmt_Send_GetChangeSupply( uint8 srcEP, afAddrType_t *dstAddr,
  3022. uint8 disableDefaultRsp, uint8 seqNum )
  3023. {
  3024. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3025. COMMAND_SE_GET_CHANGE_SUPPLY, TRUE,
  3026. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  3027. seqNum, 0, NULL );
  3028. }
  3029. /*********************************************************************
  3030. * @fn zclSE_DeviceMgmt_Send_SupplyStatusResponse
  3031. *
  3032. * @brief Call to send out a Supply Status Response Command
  3033. *
  3034. * @param srcEP - Sending application's endpoint
  3035. * @param dstAddr - where you want the message to go
  3036. * @param pCmd - command payload
  3037. * @param disableDefaultRsp - disable default response
  3038. * @param seqNum - ZCL sequence number
  3039. *
  3040. * @return ZStatus_t
  3041. */
  3042. ZStatus_t zclSE_DeviceMgmt_Send_SupplyStatusResponse( uint8 srcEP, afAddrType_t *dstAddr,
  3043. zclCCSupplyStatusResponse_t *pCmd,
  3044. uint8 disableDefaultRsp, uint8 seqNum )
  3045. {
  3046. uint8 *buf;
  3047. uint8 *pBuf;
  3048. ZStatus_t status;
  3049. buf = osal_mem_alloc( PACKET_LEN_SE_SUPPLY_STATUS_RESPONSE );
  3050. if ( buf == NULL )
  3051. {
  3052. return ( ZMemError );
  3053. }
  3054. pBuf = osal_buffer_uint32( buf, pCmd->supplierId );
  3055. pBuf = osal_buffer_uint32( pBuf, pCmd->issuerEventId );
  3056. pBuf = osal_buffer_uint32( pBuf, pCmd->implementationDateTime );
  3057. *pBuf = pCmd->supplyStatus;
  3058. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3059. COMMAND_SE_SUPPLY_STATUS_RESPONSE, TRUE,
  3060. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  3061. seqNum, PACKET_LEN_SE_SUPPLY_STATUS_RESPONSE, buf );
  3062. osal_mem_free( buf );
  3063. return status;
  3064. }
  3065. /*********************************************************************
  3066. * @fn zclSE_DeviceMgmt_Send_GetPassword
  3067. *
  3068. * @brief Call to send out a Get Password Command
  3069. *
  3070. * @param srcEP - Sending application's endpoint
  3071. * @param dstAddr - where you want the message to go
  3072. * @param pCmd - command payload
  3073. * @param disableDefaultRsp - disable default response
  3074. * @param seqNum - ZCL sequence number
  3075. *
  3076. * @return ZStatus_t
  3077. */
  3078. ZStatus_t zclSE_DeviceMgmt_Send_GetPassword( uint8 srcEP, afAddrType_t *dstAddr,
  3079. zclCCGetPassword_t *pCmd,
  3080. uint8 disableDefaultRsp, uint8 seqNum )
  3081. {
  3082. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3083. COMMAND_SE_GET_PASSWORD, TRUE,
  3084. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  3085. seqNum, PACKET_LEN_SE_GET_PASSWORD,
  3086. &(pCmd->passwordLevel) );
  3087. }
  3088. /*********************************************************************
  3089. * @fn zclSE_DeviceMgmt_Send_PublishChangeTenancy
  3090. *
  3091. * @brief Call to send out a Publish Change of Tenancy Command
  3092. *
  3093. * @param srcEP - Sending application's endpoint
  3094. * @param dstAddr - where you want the message to go
  3095. * @param pCmd - command payload
  3096. * @param disableDefaultRsp - disable default response
  3097. * @param seqNum - ZCL sequence number
  3098. *
  3099. * @return ZStatus_t
  3100. */
  3101. ZStatus_t zclSE_DeviceMgmt_Send_PublishChangeTenancy( uint8 srcEP, afAddrType_t *dstAddr,
  3102. zclCCPublishChangeTenancy_t *pCmd,
  3103. uint8 disableDefaultRsp, uint8 seqNum )
  3104. {
  3105. uint8 *buf;
  3106. uint8 *pBuf;
  3107. uint16 bufLen;
  3108. ZStatus_t status;
  3109. bufLen = PACKET_LEN_SE_PUBLISH_CHANGE_OF_TENANCY + pCmd->signature.strLen;
  3110. buf = osal_mem_alloc( bufLen );
  3111. if ( buf == NULL )
  3112. {
  3113. return ( ZMemError );
  3114. }
  3115. pBuf = osal_buffer_uint32( buf, pCmd->supplierId );
  3116. pBuf = osal_buffer_uint32( pBuf, pCmd->eventId );
  3117. *pBuf++ = pCmd->tariffType;
  3118. pBuf = osal_buffer_uint32( pBuf, pCmd->implementationDateTime );
  3119. pBuf = osal_buffer_uint32( pBuf, pCmd->propTenencyChangeCtrl );
  3120. *pBuf++ = pCmd->signature.strLen;
  3121. (void) osal_memcpy( pBuf, pCmd->signature.pStr, pCmd->signature.strLen );
  3122. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3123. COMMAND_SE_PUBLISH_CHANGE_OF_TENANCY, TRUE,
  3124. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  3125. seqNum, bufLen, buf );
  3126. osal_mem_free( buf );
  3127. return status;
  3128. }
  3129. /*********************************************************************
  3130. * @fn zclSE_DeviceMgmt_Send_PublishChangeSupplier
  3131. *
  3132. * @brief Call to send out a Publish Change of Supplier Command
  3133. *
  3134. * @param srcEP - Sending application's endpoint
  3135. * @param dstAddr - where you want the message to go
  3136. * @param pCmd - command payload
  3137. * @param disableDefaultRsp - disable default response
  3138. * @param seqNum - ZCL sequence number
  3139. *
  3140. * @return ZStatus_t
  3141. */
  3142. ZStatus_t zclSE_DeviceMgmt_Send_PublishChangeSupplier( uint8 srcEP, afAddrType_t *dstAddr,
  3143. zclCCPublishChangeSupplier_t *pCmd,
  3144. uint8 disableDefaultRsp, uint8 seqNum )
  3145. {
  3146. uint8 *buf;
  3147. uint8 *pBuf;
  3148. uint16 bufLen;
  3149. ZStatus_t status;
  3150. // include in length all variable length fields
  3151. bufLen = PACKET_LEN_SE_PUBLISH_CHANGE_OF_SUPPLIER +
  3152. pCmd->supplierIdName.strLen +
  3153. pCmd->signature.strLen;
  3154. buf = osal_mem_alloc( bufLen );
  3155. if ( buf == NULL )
  3156. {
  3157. return ( ZMemError );
  3158. }
  3159. pBuf = osal_buffer_uint32( buf, pCmd->supplierId );
  3160. pBuf = osal_buffer_uint32( pBuf, pCmd->eventId );
  3161. *pBuf++ = pCmd->tariffType;
  3162. pBuf = osal_buffer_uint32( pBuf, pCmd->propSupplierId );
  3163. pBuf = osal_buffer_uint32( pBuf, pCmd->suppIdImplemDateTime );
  3164. pBuf = osal_buffer_uint32( pBuf, pCmd->supplierChangeCtrl );
  3165. *pBuf++ = pCmd->supplierIdName.strLen;
  3166. pBuf = osal_memcpy( pBuf, pCmd->supplierIdName.pStr, pCmd->supplierIdName.strLen );
  3167. *pBuf++ = pCmd->signature.strLen;
  3168. (void) osal_memcpy( pBuf, pCmd->signature.pStr, pCmd->signature.strLen );
  3169. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3170. COMMAND_SE_PUBLISH_CHANGE_OF_SUPPLIER, TRUE,
  3171. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  3172. seqNum, bufLen, buf );
  3173. osal_mem_free( buf );
  3174. return status;
  3175. }
  3176. /*********************************************************************
  3177. * @fn zclSE_DeviceMgmt_Send_ChangeSupply
  3178. *
  3179. * @brief Call to send out a Change Supply Command
  3180. *
  3181. * @param srcEP - Sending application's endpoint
  3182. * @param dstAddr - where you want the message to go
  3183. * @param pCmd - command payload
  3184. * @param disableDefaultRsp - disable default response
  3185. * @param seqNum - ZCL sequence number
  3186. *
  3187. * @return ZStatus_t
  3188. */
  3189. ZStatus_t zclSE_DeviceMgmt_Send_ChangeSupply( uint8 srcEP, afAddrType_t *dstAddr,
  3190. zclCCChangeSupply_t *pCmd,
  3191. uint8 disableDefaultRsp, uint8 seqNum )
  3192. {
  3193. uint8 *buf;
  3194. uint8 *pBuf;
  3195. uint16 bufLen;
  3196. ZStatus_t status;
  3197. bufLen = PACKET_LEN_SE_CHANGE_SUPPLY + pCmd->signature.strLen;
  3198. buf = osal_mem_alloc( bufLen );
  3199. if ( buf == NULL )
  3200. {
  3201. return ( ZMemError );
  3202. }
  3203. pBuf = osal_buffer_uint32( buf, pCmd->supplierId );
  3204. pBuf = osal_buffer_uint32( pBuf, pCmd->eventId );
  3205. pBuf = osal_buffer_uint32( pBuf, pCmd->requestDateTime );
  3206. pBuf = osal_buffer_uint32( pBuf, pCmd->implementationDateTime );
  3207. *pBuf++ = pCmd->proposedSupplyStatus;
  3208. *pBuf++ = pCmd->origIdSupplyControlBits;
  3209. *pBuf++ = pCmd->signature.strLen;
  3210. (void) osal_memcpy( pBuf, pCmd->signature.pStr, pCmd->signature.strLen );
  3211. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3212. COMMAND_SE_CHANGE_SUPPLY, TRUE,
  3213. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  3214. seqNum, bufLen, buf );
  3215. osal_mem_free( buf );
  3216. return status;
  3217. }
  3218. /*********************************************************************
  3219. * @fn zclSE_DeviceMgmt_Send_ChangePassword
  3220. *
  3221. * @brief Call to send out a Change Password Command
  3222. *
  3223. * @param srcEP - Sending application's endpoint
  3224. * @param dstAddr - where you want the message to go
  3225. * @param pCmd - command payload
  3226. * @param disableDefaultRsp - disable default response
  3227. * @param seqNum - ZCL sequence number
  3228. *
  3229. * @return ZStatus_t
  3230. */
  3231. ZStatus_t zclSE_DeviceMgmt_Send_ChangePassword( uint8 srcEP, afAddrType_t *dstAddr,
  3232. zclCCChangePassword_t *pCmd,
  3233. uint8 disableDefaultRsp, uint8 seqNum )
  3234. {
  3235. uint8 *buf;
  3236. uint16 bufLen;
  3237. ZStatus_t status;
  3238. bufLen = PACKET_LEN_SE_CHANGE_PASSWORD + pCmd->password.strLen;
  3239. buf = osal_mem_alloc( bufLen );
  3240. if ( buf == NULL )
  3241. {
  3242. return ( ZMemError );
  3243. }
  3244. buf[0] = pCmd->passwordLevel;
  3245. buf[1] = pCmd->password.strLen;
  3246. (void) osal_memcpy( &(buf[2]), pCmd->password.pStr, pCmd->password.strLen );
  3247. status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3248. COMMAND_SE_CHANGE_PASSWORD, TRUE,
  3249. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  3250. seqNum, bufLen, buf );
  3251. osal_mem_free( buf );
  3252. return status;
  3253. }
  3254. /*********************************************************************
  3255. * @fn zclSE_DeviceMgmt_Send_LocalChangeSupply
  3256. *
  3257. * @brief Call to send out a Local Change Supply Command
  3258. *
  3259. * @param srcEP - Sending application's endpoint
  3260. * @param dstAddr - where you want the message to go
  3261. * @param pCmd - command payload
  3262. * @param disableDefaultRsp - disable default response
  3263. * @param seqNum - ZCL sequence number
  3264. *
  3265. * @return ZStatus_t
  3266. */
  3267. ZStatus_t zclSE_DeviceMgmt_Send_LocalChangeSupply( uint8 srcEP, afAddrType_t *dstAddr,
  3268. zclCCLocalChangeSupply_t *pCmd,
  3269. uint8 disableDefaultRsp, uint8 seqNum )
  3270. {
  3271. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3272. COMMAND_SE_LOCAL_CHANGE_SUPPLY, TRUE,
  3273. ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0,
  3274. seqNum, PACKET_LEN_SE_LOCAL_CHANGE_SUPPLY,
  3275. &(pCmd->propSupplyStatus) );
  3276. }
  3277. #endif // SE_UK_EXT
  3278. #endif // ZCL_DEVICE_MGMT
  3279. /*********************************************************************
  3280. * @fn zclSE_RegisterCmdCallbacks
  3281. *
  3282. * @brief Register an applications command callbacks
  3283. *
  3284. * @param endpoint - application's endpoint
  3285. * @param callbacks - pointer to the callback record.
  3286. *
  3287. * @return ZMemError if not able to allocate
  3288. */
  3289. ZStatus_t zclSE_RegisterCmdCallbacks( uint8 endpoint, zclSE_AppCallbacks_t *callbacks )
  3290. {
  3291. zclSECBRec_t *pNewItem;
  3292. zclSECBRec_t *pLoop;
  3293. // Register as a ZCL Plugin
  3294. if ( !zclSEPluginRegisted )
  3295. {
  3296. #ifndef SE_UK_EXT // SE 1.1
  3297. zcl_registerPlugin( ZCL_CLUSTER_ID_SE_PRICING,
  3298. ZCL_CLUSTER_ID_SE_PREPAYMENT,
  3299. zclSE_HdlIncoming );
  3300. #else
  3301. zcl_registerPlugin( ZCL_CLUSTER_ID_SE_PRICING,
  3302. ZCL_CLUSTER_ID_SE_DEVICE_MGMT,
  3303. zclSE_HdlIncoming );
  3304. #endif
  3305. zclSEPluginRegisted = TRUE;
  3306. }
  3307. // Fill in the new profile list
  3308. pNewItem = osal_mem_alloc( sizeof( zclSECBRec_t ) );
  3309. if ( pNewItem == NULL )
  3310. {
  3311. return ( ZMemError );
  3312. }
  3313. pNewItem->next = (zclSECBRec_t *)NULL;
  3314. pNewItem->endpoint = endpoint;
  3315. pNewItem->CBs = callbacks;
  3316. // Find spot in list
  3317. if ( zclSECBs == NULL )
  3318. {
  3319. zclSECBs = pNewItem;
  3320. }
  3321. else
  3322. {
  3323. // Look for end of list
  3324. pLoop = zclSECBs;
  3325. while ( pLoop->next != NULL )
  3326. {
  3327. pLoop = pLoop->next;
  3328. }
  3329. // Put new item at end of list
  3330. pLoop->next = pNewItem;
  3331. }
  3332. return ( ZSuccess );
  3333. }
  3334. #if defined( ZCL_LOAD_CONTROL ) || defined( ZCL_SIMPLE_METERING ) || \
  3335. defined( ZCL_PRICING ) || defined( ZCL_MESSAGE ) || \
  3336. defined( ZCL_PREPAYMENT ) || defined( ZCL_TUNNELING ) || \
  3337. defined( ZCL_TOU ) || defined( ZCL_DEVICE_MGMT )
  3338. /*********************************************************************
  3339. * @fn zclSE_FindCallbacks
  3340. *
  3341. * @brief Find the callbacks for an endpoint
  3342. *
  3343. * @param endpoint
  3344. *
  3345. * @return pointer to the callbacks
  3346. */
  3347. static zclSE_AppCallbacks_t *zclSE_FindCallbacks( uint8 endpoint )
  3348. {
  3349. zclSECBRec_t *pCBs;
  3350. pCBs = zclSECBs;
  3351. while ( pCBs )
  3352. {
  3353. if ( pCBs->endpoint == endpoint )
  3354. {
  3355. return ( pCBs->CBs );
  3356. }
  3357. pCBs = pCBs->next;
  3358. }
  3359. return ( (zclSE_AppCallbacks_t *)NULL );
  3360. }
  3361. #endif
  3362. /*********************************************************************
  3363. * @fn zclSE_HdlIncoming
  3364. *
  3365. * @brief Callback from ZCL to process incoming Commands specific
  3366. * to this cluster library or Profile commands for attributes
  3367. * that aren't in the attribute list
  3368. *
  3369. * @param pInMsg - pointer to the incoming message
  3370. *
  3371. * @return ZStatus_t
  3372. */
  3373. static ZStatus_t zclSE_HdlIncoming( zclIncoming_t *pInMsg )
  3374. {
  3375. ZStatus_t stat = ZSuccess;
  3376. #if defined ( INTER_PAN )
  3377. if ( StubAPS_InterPan( pInMsg->msg->srcAddr.panId, pInMsg->msg->srcAddr.endPoint ) &&
  3378. !INTER_PAN_CLUSTER(pInMsg->msg->clusterId) )
  3379. {
  3380. return ( stat ); // Cluster not supported thru Inter-PAN
  3381. }
  3382. #endif
  3383. if ( zcl_ClusterCmd( pInMsg->hdr.fc.type ) )
  3384. {
  3385. // Is this a manufacturer specific command?
  3386. if ( pInMsg->hdr.fc.manuSpecific == 0 )
  3387. {
  3388. stat = zclSE_HdlInSpecificCommands( pInMsg );
  3389. }
  3390. else
  3391. {
  3392. // We don't support any manufacturer specific command.
  3393. stat = ZFailure;
  3394. }
  3395. }
  3396. else
  3397. {
  3398. // Handle all the normal (Read, Write...) commands -- should never get here
  3399. stat = ZFailure;
  3400. }
  3401. return ( stat );
  3402. }
  3403. /*********************************************************************
  3404. * @fn zclSE_HdlInSpecificCommands
  3405. *
  3406. * @brief Function to process incoming Commands specific
  3407. * to this cluster library
  3408. * @param pInMsg - pointer to the incoming message
  3409. *
  3410. * @return ZStatus_t
  3411. */
  3412. static ZStatus_t zclSE_HdlInSpecificCommands( zclIncoming_t *pInMsg )
  3413. {
  3414. ZStatus_t stat;
  3415. zclSE_AppCallbacks_t *pCBs;
  3416. // make sure endpoint exists
  3417. #if defined( ZCL_LOAD_CONTROL ) || defined( ZCL_SIMPLE_METERING ) || \
  3418. defined( ZCL_PRICING ) || defined( ZCL_MESSAGE ) || \
  3419. defined( ZCL_PREPAYMENT ) || defined( ZCL_TUNNELING ) || \
  3420. defined( ZCL_TOU ) || defined( ZCL_DEVICE_MGMT )
  3421. pCBs = zclSE_FindCallbacks( pInMsg->msg->endPoint );
  3422. if ( pCBs == NULL )
  3423. {
  3424. return ( ZFailure );
  3425. }
  3426. #endif
  3427. switch ( pInMsg->msg->clusterId )
  3428. {
  3429. #ifdef ZCL_SIMPLE_METERING
  3430. case ZCL_CLUSTER_ID_SE_SIMPLE_METERING:
  3431. stat = zclSE_ProcessInSimpleMeteringCmds( pInMsg, pCBs );
  3432. break;
  3433. #endif
  3434. #ifdef ZCL_PRICING
  3435. case ZCL_CLUSTER_ID_SE_PRICING:
  3436. stat = zclSE_ProcessInPricingCmds( pInMsg, pCBs );
  3437. break;
  3438. #endif
  3439. #ifdef ZCL_MESSAGE
  3440. case ZCL_CLUSTER_ID_SE_MESSAGE:
  3441. stat = zclSE_ProcessInMessageCmds( pInMsg, pCBs );
  3442. break;
  3443. #endif
  3444. #ifdef ZCL_LOAD_CONTROL
  3445. case ZCL_CLUSTER_ID_SE_LOAD_CONTROL:
  3446. stat = zclSE_ProcessInLoadControlCmds( pInMsg, pCBs );
  3447. break;
  3448. #endif
  3449. #ifdef ZCL_TUNNELING
  3450. case ZCL_CLUSTER_ID_SE_SE_TUNNELING:
  3451. stat = zclSE_ProcessInTunnelingCmds( pInMsg, pCBs );
  3452. break;
  3453. #endif // ZCL_TUNNELING
  3454. #ifdef ZCL_PREPAYMENT
  3455. case ZCL_CLUSTER_ID_SE_PREPAYMENT:
  3456. stat = zclSE_ProcessInPrepaymentCmds( pInMsg, pCBs );
  3457. break;
  3458. #endif // ZCL_PREPAYMENT
  3459. #ifdef SE_UK_EXT
  3460. #ifdef ZCL_TOU
  3461. case ZCL_CLUSTER_ID_SE_TOU_CALENDAR:
  3462. stat = zclSE_ProcessInTouCmds( pInMsg, pCBs );
  3463. break;
  3464. #endif // ZCL_TOU
  3465. #ifdef ZCL_DEVICE_MGMT
  3466. case ZCL_CLUSTER_ID_SE_DEVICE_MGMT:
  3467. stat = zclSE_ProcessInDeviceMgmtCmds( pInMsg, pCBs );
  3468. break;
  3469. #endif // ZCL_DEVICE_MGMT
  3470. #endif // SE_UK_EXT
  3471. default:
  3472. stat = ZFailure;
  3473. break;
  3474. }
  3475. return ( stat );
  3476. }
  3477. #ifdef ZCL_SIMPLE_METERING
  3478. /*********************************************************************
  3479. * @fn zclSE_ProcessInSimpleMeteringCmds
  3480. *
  3481. * @brief Callback from ZCL to process incoming Commands specific
  3482. * to this cluster library on a command ID basis
  3483. *
  3484. * @param pInMsg - pointer to the incoming message
  3485. * @param pCBs - pointer to the application call back function
  3486. *
  3487. * @return ZStatus_t
  3488. */
  3489. static ZStatus_t zclSE_ProcessInSimpleMeteringCmds( zclIncoming_t *pInMsg,
  3490. zclSE_AppCallbacks_t *pCBs )
  3491. {
  3492. ZStatus_t stat;
  3493. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  3494. {
  3495. // Process Client commands, received by server
  3496. switch ( pInMsg->hdr.commandID )
  3497. {
  3498. case COMMAND_SE_GET_PROFILE_CMD:
  3499. stat = zclSE_ProcessInCmd_SimpleMeter_GetProfileCmd( pInMsg, pCBs );
  3500. break;
  3501. case COMMAND_SE_REQ_MIRROR_RSP:
  3502. stat = zclSE_ProcessInCmd_SimpleMeter_ReqMirrorRsp( pInMsg, pCBs );
  3503. break;
  3504. case COMMAND_SE_MIRROR_REM_RSP:
  3505. stat = zclSE_ProcessInCmd_SimpleMeter_MirrorRemRsp( pInMsg, pCBs );
  3506. break;
  3507. case COMMAND_SE_REQ_FAST_POLL_MODE_CMD:
  3508. stat = zclSE_ProcessInCmd_SimpleMeter_ReqFastPollModeCmd( pInMsg, pCBs );
  3509. break;
  3510. #ifdef SE_UK_EXT
  3511. case COMMAND_SE_GET_SNAPSHOT_CMD:
  3512. stat = zclSE_ProcessInCmd_SimpleMeter_GetSnapshotCmd( pInMsg, pCBs );
  3513. break;
  3514. case COMMAND_SE_TAKE_SNAPSHOT_CMD:
  3515. stat = zclSE_ProcessInCmd_SimpleMeter_TakeSnapshotCmd( pInMsg, pCBs );
  3516. break;
  3517. case COMMAND_SE_MIRROR_REPORT_ATTR_RSP:
  3518. stat = zclSE_ProcessInCmd_SimpleMeter_MirrorReportAttrRsp( pInMsg, pCBs );
  3519. break;
  3520. #endif // SE_UK_EXT
  3521. default:
  3522. stat = ZFailure;
  3523. break;
  3524. }
  3525. }
  3526. else
  3527. {
  3528. // Process Server commands, received by client
  3529. switch ( pInMsg->hdr.commandID )
  3530. {
  3531. case COMMAND_SE_GET_PROFILE_RSP:
  3532. stat = zclSE_ProcessInCmd_SimpleMeter_GetProfileRsp( pInMsg, pCBs );
  3533. break;
  3534. case COMMAND_SE_REQ_MIRROR_CMD:
  3535. stat = zclSE_ProcessInCmd_SimpleMeter_ReqMirrorCmd( pInMsg, pCBs );
  3536. break;
  3537. case COMMAND_SE_MIRROR_REM_CMD:
  3538. stat = zclSE_ProcessInCmd_SimpleMeter_MirrorRemCmd( pInMsg, pCBs );
  3539. break;
  3540. case COMMAND_SE_REQ_FAST_POLL_MODE_RSP:
  3541. stat = zclSE_ProcessInCmd_SimpleMeter_ReqFastPollModeRsp( pInMsg, pCBs );
  3542. break;
  3543. #ifdef SE_UK_EXT
  3544. case COMMAND_SE_GET_SNAPSHOT_RSP:
  3545. stat = zclSE_ProcessInCmd_SimpleMeter_GetSnapshotRsp( pInMsg, pCBs );
  3546. break;
  3547. #endif // SE_UK_EXT
  3548. default:
  3549. stat = ZFailure;
  3550. break;
  3551. }
  3552. }
  3553. return ( stat );
  3554. }
  3555. /*********************************************************************
  3556. * @fn zclSE_ProcessInCmd_SimpleMeter_GetProfileCmd
  3557. *
  3558. * @brief Process in the received Get Profile Command.
  3559. *
  3560. * @param pInMsg - pointer to the incoming message
  3561. * @param pCBs - pointer to the application call back function
  3562. *
  3563. * @return ZStatus_t - ZFailure @ Unsupported
  3564. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  3565. * not need default rsp
  3566. * ZCL_STATUS_INVALID_FIELD @ Range checking
  3567. * failure
  3568. *
  3569. */
  3570. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_GetProfileCmd( zclIncoming_t *pInMsg,
  3571. zclSE_AppCallbacks_t *pCBs )
  3572. {
  3573. if ( pCBs->pfnSimpleMeter_GetProfileCmd )
  3574. {
  3575. zclCCGetProfileCmd_t cmd;
  3576. cmd.channel = pInMsg->pData[0];
  3577. cmd.endTime = osal_build_uint32( &pInMsg->pData[1], 4 );
  3578. cmd.numOfPeriods = pInMsg->pData[5];
  3579. // Range checking
  3580. if ( cmd.channel > MAX_INTERVAL_CHANNEL_SE_SIMPLE_METERING )
  3581. {
  3582. return ZCL_STATUS_INVALID_FIELD;
  3583. }
  3584. pCBs->pfnSimpleMeter_GetProfileCmd( &cmd, &(pInMsg->msg->srcAddr),
  3585. pInMsg->hdr.transSeqNum );
  3586. return ZCL_STATUS_CMD_HAS_RSP;
  3587. }
  3588. return ZFailure;
  3589. }
  3590. /*********************************************************************
  3591. * @fn zclSE_ProcessInCmd_SimpleMeter_GetProfileRsp
  3592. *
  3593. * @brief Process in the received Get Profile Response.
  3594. *
  3595. * @param pInMsg - pointer to the incoming message
  3596. * @param pCBs - pointer to the application call back function
  3597. *
  3598. * @return ZStatus_t - ZFailure @ Unsupported
  3599. * ZSuccess @ Supported and send default rsp
  3600. * ZCL_STATUS_INVALID_FIELD @ Range checking
  3601. * failure
  3602. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  3603. */
  3604. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_GetProfileRsp( zclIncoming_t *pInMsg,
  3605. zclSE_AppCallbacks_t *pCBs )
  3606. {
  3607. if ( pCBs->pfnSimpleMeter_GetProfileRsp )
  3608. {
  3609. uint24 *pBuf24;
  3610. uint8 *pBuf8;
  3611. uint8 i;
  3612. zclCCGetProfileRsp_t cmd;
  3613. cmd.endTime = osal_build_uint32( &pInMsg->pData[0], 4 );
  3614. cmd.status = pInMsg->pData[4];
  3615. cmd.profileIntervalPeriod = pInMsg->pData[5];
  3616. cmd.numOfPeriodDelivered = pInMsg->pData[6];
  3617. // Range Checking
  3618. if ( cmd.profileIntervalPeriod > MAX_PROFILE_INTERVAL_PERIOD_SE_SIMPLE_METERING )
  3619. {
  3620. return ZCL_STATUS_INVALID_FIELD;
  3621. }
  3622. // Convert the byte stream to array of uint24
  3623. pBuf8 = &pInMsg->pData[7]; // Pointer to the start of the array of bytes
  3624. // Pointer to the start of the array of uint24
  3625. pBuf24 = (uint24*)osal_mem_alloc( cmd.numOfPeriodDelivered *
  3626. sizeof(uint24) );
  3627. if ( pBuf24 == NULL )
  3628. {
  3629. return ZCL_STATUS_SOFTWARE_FAILURE; // Memory allocation error
  3630. }
  3631. cmd.intervals = pBuf24;
  3632. for ( i = 0; i < cmd.numOfPeriodDelivered; i++ )
  3633. {
  3634. *(pBuf24++) = osal_build_uint32( pBuf8, 3 );
  3635. pBuf8 += 3;
  3636. }
  3637. pCBs->pfnSimpleMeter_GetProfileRsp( &cmd, &(pInMsg->msg->srcAddr),
  3638. pInMsg->hdr.transSeqNum );
  3639. osal_mem_free( cmd.intervals );
  3640. return ZSuccess;
  3641. }
  3642. return ZFailure;
  3643. }
  3644. /*********************************************************************
  3645. * @fn zclSE_ProcessInCmd_SimpleMeter_ReqMirrorCmd
  3646. *
  3647. * @brief Process in the received Request Mirror Command.
  3648. *
  3649. * @param pInMsg - pointer to the incoming message
  3650. * @param pCBs - pointer to the application call back function
  3651. *
  3652. * @return ZStatus_t - ZFailure @ Unsupported
  3653. * ZSuccess @ Supported and send default rsp
  3654. */
  3655. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_ReqMirrorCmd( zclIncoming_t *pInMsg,
  3656. zclSE_AppCallbacks_t *pCBs )
  3657. {
  3658. if ( pCBs->pfnSimpleMeter_ReqMirrorCmd )
  3659. {
  3660. pCBs->pfnSimpleMeter_ReqMirrorCmd( &(pInMsg->msg->srcAddr),
  3661. pInMsg->hdr.transSeqNum );
  3662. return ZSuccess;
  3663. }
  3664. return ZFailure;
  3665. }
  3666. /*********************************************************************
  3667. * @fn zclSE_ProcessInCmd_SimpleMeter_ReqMirrorRsp
  3668. *
  3669. * @brief Process in the received Request Mirror Response.
  3670. *
  3671. * @param pInMsg - pointer to the incoming message
  3672. * @param pCBs - pointer to the application call back function
  3673. *
  3674. * @return ZStatus_t - ZFailure @ Unsupported
  3675. * ZSuccess @ Supported and send default rsp
  3676. */
  3677. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_ReqMirrorRsp( zclIncoming_t *pInMsg,
  3678. zclSE_AppCallbacks_t *pCBs )
  3679. {
  3680. if ( pCBs->pfnSimpleMeter_ReqMirrorRsp )
  3681. {
  3682. zclCCReqMirrorRsp_t cmd;
  3683. cmd.endpointId = BUILD_UINT16( pInMsg->pData[0], pInMsg->pData[1] );
  3684. pCBs->pfnSimpleMeter_ReqMirrorRsp( &cmd, &(pInMsg->msg->srcAddr),
  3685. pInMsg->hdr.transSeqNum );
  3686. return ZSuccess ;
  3687. }
  3688. return ZFailure;
  3689. }
  3690. /*********************************************************************
  3691. * @fn zclSE_ProcessInCmd_SimpleMeter_MirrorRemCmd
  3692. *
  3693. * @brief Process in the received Mirror Removed Command.
  3694. *
  3695. * @param pInMsg - pointer to the incoming message
  3696. * @param pCBs - pointer to the application call back function
  3697. *
  3698. * @return ZStatus_t - ZFailure @ Unsupported
  3699. * ZSuccess @ Supported and send default rsp
  3700. */
  3701. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_MirrorRemCmd( zclIncoming_t *pInMsg,
  3702. zclSE_AppCallbacks_t *pCBs )
  3703. {
  3704. if ( pCBs->pfnSimpleMeter_MirrorRemCmd )
  3705. {
  3706. pCBs->pfnSimpleMeter_MirrorRemCmd( &(pInMsg->msg->srcAddr),
  3707. pInMsg->hdr.transSeqNum );
  3708. return ZSuccess;
  3709. }
  3710. return ZFailure;
  3711. }
  3712. /*********************************************************************
  3713. * @fn zclSE_ProcessInCmd_SimpleMeter_MirrorRemRsp
  3714. *
  3715. * @brief Process in the received Mirror Removed Response.
  3716. *
  3717. * @param pInMsg - pointer to the incoming message
  3718. * @param pCBs - pointer to the application call back function
  3719. *
  3720. * @return ZStatus_t - ZFailure @ Unsupported
  3721. * ZSuccess @ Supported and send default rsp
  3722. */
  3723. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_MirrorRemRsp( zclIncoming_t *pInMsg,
  3724. zclSE_AppCallbacks_t *pCBs )
  3725. {
  3726. if ( pCBs->pfnSimpleMeter_MirrorRemRsp )
  3727. {
  3728. zclCCMirrorRemRsp_t cmd;
  3729. cmd.endpointId = pInMsg->pData[0] | ( (uint16)pInMsg->pData[1] << 8 );
  3730. pCBs->pfnSimpleMeter_MirrorRemRsp( &cmd, &(pInMsg->msg->srcAddr),
  3731. pInMsg->hdr.transSeqNum );
  3732. return ZSuccess;
  3733. }
  3734. return ZFailure;
  3735. }
  3736. /*********************************************************************
  3737. * @fn zclSE_ProcessInCmd_SimpleMeter_ReqFastPollModeCmd
  3738. *
  3739. * @brief Process in the received Request Fast Poll Mode Command
  3740. *
  3741. * @param pInMsg - pointer to the incoming message
  3742. * @param pCBs - pointer to the application call back function
  3743. *
  3744. * @return ZStatus_t - ZFailure @ Unsupported
  3745. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  3746. * not need default rsp
  3747. */
  3748. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_ReqFastPollModeCmd( zclIncoming_t *pInMsg,
  3749. zclSE_AppCallbacks_t *pCBs )
  3750. {
  3751. if ( pCBs->pfnSimpleMeter_ReqFastPollModeCmd )
  3752. {
  3753. zclCCReqFastPollModeCmd_t cmd;
  3754. zclAttrRec_t attrRec;
  3755. uint8 fastPollUpdatePeriodAttr = 0;
  3756. // Retrieve Fast Poll Update Period Attribute Record and save value to local variable
  3757. if ( zclFindAttrRec( pInMsg->msg->endPoint, pInMsg->msg->clusterId,
  3758. ATTRID_SE_FAST_POLL_UPDATE_PERIOD, &attrRec ) )
  3759. {
  3760. zclReadAttrData( (uint8 *)&fastPollUpdatePeriodAttr, &attrRec, NULL );
  3761. }
  3762. // Value has been set by application
  3763. if (( fastPollUpdatePeriodAttr > 0 ) && (pInMsg->pData[0] < fastPollUpdatePeriodAttr))
  3764. {
  3765. // the minimum acceptable value is defined by the attribute value
  3766. cmd.fastPollUpdatePeriod = fastPollUpdatePeriodAttr;
  3767. }
  3768. else
  3769. {
  3770. // use received update period
  3771. cmd.fastPollUpdatePeriod = pInMsg->pData[0];
  3772. }
  3773. // As per SE 1.1 spec: maximum duration value will be used if received exceeds it
  3774. cmd.duration = MIN(pInMsg->pData[1], MAX_DURATION_IN_MINUTES_FAST_POLL_MODE);
  3775. pCBs->pfnSimpleMeter_ReqFastPollModeCmd(&cmd, &(pInMsg->msg->srcAddr),
  3776. pInMsg->hdr.transSeqNum );
  3777. return ZCL_STATUS_CMD_HAS_RSP;
  3778. }
  3779. return ZFailure;
  3780. }
  3781. /*********************************************************************
  3782. * @fn zclSE_ProcessInCmd_SimpleMeter_ReqFastPollModeRsp
  3783. *
  3784. * @brief Process in the received Request Fast Poll Mode Response
  3785. *
  3786. * @param pInMsg - pointer to the incoming message
  3787. * @param pCBs - pointer to the application call back function
  3788. *
  3789. * @return ZStatus_t - ZFailure @ Unsupported
  3790. * ZSuccess @ Supported and send default rsp
  3791. */
  3792. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_ReqFastPollModeRsp( zclIncoming_t *pInMsg,
  3793. zclSE_AppCallbacks_t *pCBs )
  3794. {
  3795. if ( pCBs->pfnSimpleMeter_ReqFastPollModeRsp )
  3796. {
  3797. zclCCReqFastPollModeRsp_t cmd;
  3798. cmd.appliedUpdatePeriod = pInMsg->pData[0];
  3799. cmd.fastPollModeEndTime = osal_build_uint32( &pInMsg->pData[1], 4 );
  3800. pCBs->pfnSimpleMeter_ReqFastPollModeRsp(&cmd, &(pInMsg->msg->srcAddr),
  3801. pInMsg->hdr.transSeqNum );
  3802. return ZSuccess;
  3803. }
  3804. return ZFailure;
  3805. }
  3806. #ifdef SE_UK_EXT
  3807. /*********************************************************************
  3808. * @fn zclSE_ProcessInCmd_SimpleMeter_GetSnapshotCmd
  3809. *
  3810. * @brief Process in the received Get Snapshot Command
  3811. *
  3812. * @param pInMsg - pointer to the incoming message
  3813. * @param pCBs - pointer to the application call back function
  3814. *
  3815. * @return ZStatus_t - ZFailure @ Unsupported
  3816. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  3817. * not need default rsp
  3818. */
  3819. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_GetSnapshotCmd( zclIncoming_t *pInMsg,
  3820. zclSE_AppCallbacks_t *pCBs )
  3821. {
  3822. if ( pCBs->pfnSimpleMeter_GetSnapshotCmd )
  3823. {
  3824. zclCCReqGetSnapshotCmd_t cmd;
  3825. cmd.StartTime = osal_build_uint32( &pInMsg->pData[0], 4 );
  3826. cmd.NumberOfSnapshots = pInMsg->pData[4];
  3827. cmd.SnapshotCause = BUILD_UINT16( pInMsg->pData[5], pInMsg->pData[6] );
  3828. pCBs->pfnSimpleMeter_GetSnapshotCmd(&cmd, &(pInMsg->msg->srcAddr),
  3829. pInMsg->hdr.transSeqNum );
  3830. return ZCL_STATUS_CMD_HAS_RSP;
  3831. }
  3832. return ZFailure;
  3833. }
  3834. /*********************************************************************
  3835. * @fn zclSE_ProcessInCmd_SimpleMeter_GetSnapshotRsp
  3836. *
  3837. * @brief Process in the received Get Snapshot Response
  3838. *
  3839. * @param pInMsg - pointer to the incoming message
  3840. * @param pCBs - pointer to the application call back function
  3841. *
  3842. * @return ZStatus_t - ZFailure @ Unsupported
  3843. * ZSuccess @ Supported and send default rsp
  3844. */
  3845. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_GetSnapshotRsp( zclIncoming_t *pInMsg,
  3846. zclSE_AppCallbacks_t *pCBs )
  3847. {
  3848. if ( pCBs->pfnSimpleMeter_GetSnapshotRsp )
  3849. {
  3850. zclCCReqGetSnapshotRsp_t cmd;
  3851. cmd.IssuerEventID = osal_build_uint32( &pInMsg->pData[0], 4 );
  3852. cmd.SnapshotTime = osal_build_uint32( &pInMsg->pData[4], 4 );
  3853. cmd.CommandIndex = pInMsg->pData[8];
  3854. cmd.SnapshotCause = BUILD_UINT16( pInMsg->pData[9], pInMsg->pData[10] );
  3855. cmd.SnapshotPayloadType = pInMsg->pData[11];
  3856. cmd.pSnapshotPayload = pInMsg->pData + 12;
  3857. pCBs->pfnSimpleMeter_GetSnapshotRsp(&cmd, &(pInMsg->msg->srcAddr),
  3858. pInMsg->hdr.transSeqNum );
  3859. return ZSuccess;
  3860. }
  3861. return ZFailure;
  3862. }
  3863. /*********************************************************************
  3864. * @fn zclSE_ProcessInCmd_SimpleMeter_TakeSnapshotCmd
  3865. *
  3866. * @brief Process in the received Take Snapshot Command
  3867. *
  3868. * @param pInMsg - pointer to the incoming message
  3869. * @param pCBs - pointer to the application call back function
  3870. *
  3871. * @return ZStatus_t - ZFailure @ Unsupported
  3872. * ZSuccess @ Supported and send default rsp
  3873. */
  3874. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_TakeSnapshotCmd( zclIncoming_t *pInMsg,
  3875. zclSE_AppCallbacks_t *pCBs )
  3876. {
  3877. if ( pCBs->pfnSimpleMeter_TakeSnapshotCmd )
  3878. {
  3879. pCBs->pfnSimpleMeter_TakeSnapshotCmd( &(pInMsg->msg->srcAddr),
  3880. pInMsg->hdr.transSeqNum );
  3881. return ZSuccess;
  3882. }
  3883. return ZFailure;
  3884. }
  3885. /*********************************************************************
  3886. * @fn zclSE_ProcessInCmd_SimpleMeter_MirrorReportAttrRsp
  3887. *
  3888. * @brief Process in the received Mirror Report Attribute Response
  3889. *
  3890. * @param pInMsg - pointer to the incoming message
  3891. * @param pCBs - pointer to the application call back function
  3892. *
  3893. * @return ZStatus_t - ZFailure @ Unsupported
  3894. * ZSuccess @ Supported and send default rsp
  3895. */
  3896. static ZStatus_t zclSE_ProcessInCmd_SimpleMeter_MirrorReportAttrRsp( zclIncoming_t *pInMsg,
  3897. zclSE_AppCallbacks_t *pCBs )
  3898. {
  3899. if ( pCBs->pfnSimpleMeter_MirrorReportAttrRsp )
  3900. {
  3901. zclCCReqMirrorReportAttrRsp_t cmd;
  3902. cmd.NotificationFlags = pInMsg->pData[0];
  3903. cmd.PriceNotificationFlags = BUILD_UINT16( pInMsg->pData[1], pInMsg->pData[2] );
  3904. cmd.CalendarNotificationFlags = pInMsg->pData[3];
  3905. cmd.PrePayNotificationFlags = BUILD_UINT16( pInMsg->pData[4], pInMsg->pData[5] );
  3906. cmd.DeviceMgmtNotificationFlags = pInMsg->pData[6];
  3907. pCBs->pfnSimpleMeter_MirrorReportAttrRsp(&cmd, &(pInMsg->msg->srcAddr),
  3908. pInMsg->hdr.transSeqNum );
  3909. return ZSuccess;
  3910. }
  3911. return ZFailure;
  3912. }
  3913. #endif // SE_UK_EXT
  3914. #endif // ZCL_SIMPLE_METERING
  3915. #ifdef ZCL_PRICING
  3916. /*********************************************************************
  3917. * @fn zclSE_ProcessInPricingCmds
  3918. *
  3919. * @brief Callback from ZCL to process incoming Commands specific
  3920. * to this cluster library on a command ID basis
  3921. *
  3922. * @param pInMsg - pointer to the incoming message
  3923. * @param pCBs - pointer to the application call back function
  3924. *
  3925. * @return ZStatus_t
  3926. */
  3927. static ZStatus_t zclSE_ProcessInPricingCmds( zclIncoming_t *pInMsg,
  3928. zclSE_AppCallbacks_t *pCBs )
  3929. {
  3930. ZStatus_t stat;
  3931. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  3932. {
  3933. // Process Client commands, received by server
  3934. switch ( pInMsg->hdr.commandID )
  3935. {
  3936. case COMMAND_SE_GET_CURRENT_PRICE:
  3937. stat = zclSE_ProcessInCmd_Pricing_GetCurrentPrice( pInMsg, pCBs );
  3938. break;
  3939. case COMMAND_SE_GET_SCHEDULED_PRICE:
  3940. stat = zclSE_ProcessInCmd_Pricing_GetScheduledPrice( pInMsg, pCBs );
  3941. break;
  3942. case COMMAND_SE_PRICE_ACKNOWLEDGEMENT:
  3943. stat = zclSE_ProcessInCmd_Pricing_PriceAcknowledgement ( pInMsg, pCBs );
  3944. break;
  3945. case COMMAND_SE_GET_BLOCK_PERIOD:
  3946. stat = zclSE_ProcessInCmd_Pricing_GetBlockPeriod ( pInMsg, pCBs );
  3947. break;
  3948. #ifdef SE_UK_EXT
  3949. case COMMAND_SE_GET_TARIFF_INFO:
  3950. stat = zclSE_ProcessInCmd_Pricing_GetTariffInformation ( pInMsg, pCBs );
  3951. break;
  3952. case COMMAND_SE_GET_PRICE_MATRIX:
  3953. stat = zclSE_ProcessInCmd_Pricing_GetPriceMatrix ( pInMsg, pCBs );
  3954. break;
  3955. case COMMAND_SE_GET_BLOCK_THRESHOLD:
  3956. stat = zclSE_ProcessInCmd_Pricing_GetBlockThresholds ( pInMsg, pCBs );
  3957. break;
  3958. case COMMAND_SE_GET_CONVERSION_FACTOR:
  3959. stat = zclSE_ProcessInCmd_Pricing_GetConversionFactor ( pInMsg, pCBs );
  3960. break;
  3961. case COMMAND_SE_GET_CALORIFIC_VALUE:
  3962. stat = zclSE_ProcessInCmd_Pricing_GetCalorificValue ( pInMsg, pCBs );
  3963. break;
  3964. case COMMAND_SE_GET_CO2_VALUE:
  3965. stat = zclSE_ProcessInCmd_Pricing_GetCO2Value ( pInMsg, pCBs );
  3966. break;
  3967. case COMMAND_SE_GET_BILLING_PERIOD:
  3968. stat = zclSE_ProcessInCmd_Pricing_GetBillingPeriod ( pInMsg, pCBs );
  3969. break;
  3970. case COMMAND_SE_GET_CONSOLIDATED_BILL:
  3971. stat = zclSE_ProcessInCmd_Pricing_GetConsolidatedBill ( pInMsg, pCBs );
  3972. break;
  3973. case COMMAND_SE_CPP_EVENT_RESPONSE:
  3974. stat = zclSE_ProcessInCmd_Pricing_CPPEventResponse ( pInMsg, pCBs );
  3975. break;
  3976. #endif // SE_UK_EXT
  3977. default:
  3978. stat = ZFailure;
  3979. break;
  3980. }
  3981. }
  3982. else
  3983. {
  3984. // Process Server commands, received by client
  3985. switch ( pInMsg->hdr.commandID )
  3986. {
  3987. case COMMAND_SE_PUBLISH_PRICE:
  3988. stat = zclSE_ProcessInCmd_Pricing_PublishPrice( pInMsg, pCBs );
  3989. break;
  3990. case COMMAND_SE_PUBLISH_BLOCK_PERIOD:
  3991. stat = zclSE_ProcessInCmd_Pricing_PublishBlockPeriod( pInMsg, pCBs );
  3992. break;
  3993. #ifdef SE_UK_EXT
  3994. case COMMAND_SE_PUBLISH_TARIFF_INFO:
  3995. stat = zclSE_ProcessInCmd_Pricing_PublishTariffInformation( pInMsg, pCBs );
  3996. break;
  3997. case COMMAND_SE_PUBLISH_PRICE_MATRIX:
  3998. stat = zclSE_ProcessInCmd_Pricing_PublishPriceMatrix( pInMsg, pCBs );
  3999. break;
  4000. case COMMAND_SE_PUBLISH_BLOCK_THRESHOLD:
  4001. stat = zclSE_ProcessInCmd_Pricing_PublishBlockThreshold( pInMsg, pCBs );
  4002. break;
  4003. case COMMAND_SE_PUBLISH_CONVERSION_FACTOR:
  4004. stat = zclSE_ProcessInCmd_Pricing_PublishConversionFactor( pInMsg, pCBs );
  4005. break;
  4006. case COMMAND_SE_PUBLISH_CALORIFIC_VALUE:
  4007. stat = zclSE_ProcessInCmd_Pricing_PublishCalorificValue( pInMsg, pCBs );
  4008. break;
  4009. case COMMAND_SE_PUBLISH_CO2_VALUE:
  4010. stat = zclSE_ProcessInCmd_Pricing_PublishCO2Value( pInMsg, pCBs );
  4011. break;
  4012. case COMMAND_SE_PUBLISH_CPP_EVENT:
  4013. stat = zclSE_ProcessInCmd_Pricing_PublishCPPEvent( pInMsg, pCBs );
  4014. break;
  4015. case COMMAND_SE_PUBLISH_BILLING_PERIOD:
  4016. stat = zclSE_ProcessInCmd_Pricing_PublishBillingPeriod( pInMsg, pCBs );
  4017. break;
  4018. case COMMAND_SE_PUBLISH_CONSOLIDATED_BILL:
  4019. stat = zclSE_ProcessInCmd_Pricing_PublishConsolidatedBill( pInMsg, pCBs );
  4020. break;
  4021. case COMMAND_SE_PUBLISH_CREDIT_PAYMENT_INFO:
  4022. stat = zclSE_ProcessInCmd_Pricing_PublishCreditPaymentInfo( pInMsg, pCBs );
  4023. break;
  4024. #endif // SE_UK_EXT
  4025. default:
  4026. stat = ZFailure;
  4027. break;
  4028. }
  4029. }
  4030. return ( stat );
  4031. }
  4032. /*********************************************************************
  4033. * @fn zclSE_ProcessInCmd_Pricing_GetCurrentPrice
  4034. *
  4035. * @brief Process in the received Get Current Price.
  4036. *
  4037. * @param pInMsg - pointer to the incoming message
  4038. * @param pCBs - pointer to the application call back function
  4039. *
  4040. * @return ZStatus_t - ZFailure @ Unsupported
  4041. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4042. * not need default rsp
  4043. */
  4044. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetCurrentPrice( zclIncoming_t *pInMsg,
  4045. zclSE_AppCallbacks_t *pCBs )
  4046. {
  4047. if ( pCBs->pfnPricing_GetCurrentPrice )
  4048. {
  4049. zclCCGetCurrentPrice_t cmd;
  4050. cmd.option = pInMsg->pData[0];
  4051. pCBs->pfnPricing_GetCurrentPrice( &cmd, &(pInMsg->msg->srcAddr),
  4052. pInMsg->hdr.transSeqNum );
  4053. return ZCL_STATUS_CMD_HAS_RSP;
  4054. }
  4055. return ZFailure;
  4056. }
  4057. /*********************************************************************
  4058. * @fn zclSE_ProcessInCmd_Pricing_GetScheduledPrice
  4059. *
  4060. * @brief Process in the received Get Scheduled Price.
  4061. *
  4062. * @param pInMsg - pointer to the incoming message
  4063. * @param pCBs - pointer to the application call back function
  4064. *
  4065. * @return ZStatus_t - ZFailure @ Unsupported
  4066. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4067. * not need default rsp
  4068. */
  4069. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetScheduledPrice( zclIncoming_t *pInMsg,
  4070. zclSE_AppCallbacks_t *pCBs )
  4071. {
  4072. if ( pCBs->pfnPricing_GetScheduledPrice )
  4073. {
  4074. zclCCGetScheduledPrice_t cmd;
  4075. cmd.startTime = osal_build_uint32( pInMsg->pData, 4 );
  4076. cmd.numEvents = pInMsg->pData[4];
  4077. pCBs->pfnPricing_GetScheduledPrice( &cmd, &(pInMsg->msg->srcAddr),
  4078. pInMsg->hdr.transSeqNum );
  4079. return ZCL_STATUS_CMD_HAS_RSP;
  4080. }
  4081. return ZFailure;
  4082. }
  4083. /*********************************************************************
  4084. * @fn zclSE_ProcessInCmd_Pricing_PublishPrice
  4085. *
  4086. * @brief Process in the received Publish Price.
  4087. *
  4088. * @param pInMsg - pointer to the incoming message
  4089. * @param pCBs - pointer to the application call back function
  4090. *
  4091. * @return ZStatus_t - ZFailure @ Unsupported
  4092. * ZSuccess @ Supported and need default rsp
  4093. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4094. * not need default rsp
  4095. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  4096. */
  4097. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishPrice( zclIncoming_t *pInMsg,
  4098. zclSE_AppCallbacks_t *pCBs )
  4099. {
  4100. if ( pCBs->pfnPricing_PublishPrice )
  4101. {
  4102. zclCCPublishPrice_t cmd;
  4103. // Parse the command and do range check
  4104. if ( zclSE_ParseInCmd_PublishPrice( &cmd, &(pInMsg->pData[0]),
  4105. pInMsg->pDataLen ) == ZSuccess )
  4106. {
  4107. pCBs->pfnPricing_PublishPrice( &cmd, &(pInMsg->msg->srcAddr),
  4108. pInMsg->hdr.transSeqNum );
  4109. // Free the memory allocated in zclSE_ParseInCmd_PublishPrice()
  4110. if ( cmd.rateLabel.pStr != NULL )
  4111. {
  4112. osal_mem_free( cmd.rateLabel.pStr );
  4113. }
  4114. // SE 1.1
  4115. if ((pInMsg->pDataLen - cmd.rateLabel.strLen) > PACKET_LEN_SE_PUBLISH_PRICE_SE_1_0)
  4116. {
  4117. return ZCL_STATUS_CMD_HAS_RSP;
  4118. }
  4119. else
  4120. {
  4121. // SE 1.0 backwards compatibility
  4122. return ZSuccess;
  4123. }
  4124. }
  4125. else
  4126. {
  4127. return ZCL_STATUS_SOFTWARE_FAILURE;
  4128. }
  4129. }
  4130. return ZFailure;
  4131. }
  4132. /*********************************************************************
  4133. * @fn zclSE_ProcessInCmd_Pricing_PriceAcknowledgement
  4134. *
  4135. * @brief Process in the received Price Acknowledgement
  4136. *
  4137. * @param pInMsg - pointer to the incoming message
  4138. * @param pCBs - pointer to the application call back function
  4139. *
  4140. * @return ZStatus_t - ZFailure @ Unsupported
  4141. * ZSuccess @ Supported and need default rsp
  4142. */
  4143. static ZStatus_t zclSE_ProcessInCmd_Pricing_PriceAcknowledgement( zclIncoming_t *pInMsg,
  4144. zclSE_AppCallbacks_t *pCBs )
  4145. {
  4146. if ( pCBs->pfnPricing_PriceAcknowledgement )
  4147. {
  4148. zclCCPriceAcknowledgement_t cmd;
  4149. cmd.providerId = osal_build_uint32( pInMsg->pData, 4 );
  4150. cmd.issuerEventId = osal_build_uint32( &pInMsg->pData[4], 4 );
  4151. cmd.priceAckTime = osal_build_uint32( &pInMsg->pData[8], 4 );
  4152. cmd.control = pInMsg->pData[12];
  4153. pCBs->pfnPricing_PriceAcknowledgement( &cmd, &(pInMsg->msg->srcAddr),
  4154. pInMsg->hdr.transSeqNum );
  4155. return ZSuccess;
  4156. }
  4157. return ZFailure;
  4158. }
  4159. /*********************************************************************
  4160. * @fn zclSE_ProcessInCmd_Pricing_GetBlockPeriod
  4161. *
  4162. * @brief Process in the received Get Block Period.
  4163. *
  4164. * @param pInMsg - pointer to the incoming message
  4165. * @param pCBs - pointer to the application call back function
  4166. *
  4167. * @return ZStatus_t - ZFailure @ Unsupported
  4168. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4169. * not need default rsp
  4170. */
  4171. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetBlockPeriod( zclIncoming_t *pInMsg,
  4172. zclSE_AppCallbacks_t *pCBs )
  4173. {
  4174. if ( pCBs->pfnPricing_GetBlockPeriod )
  4175. {
  4176. zclCCGetBlockPeriod_t cmd;
  4177. cmd.startTime = osal_build_uint32( pInMsg->pData, 4 );
  4178. cmd.numEvents = pInMsg->pData[4];
  4179. pCBs->pfnPricing_GetBlockPeriod( &cmd, &(pInMsg->msg->srcAddr),
  4180. pInMsg->hdr.transSeqNum );
  4181. return ZCL_STATUS_CMD_HAS_RSP;
  4182. }
  4183. return ZFailure;
  4184. }
  4185. /*********************************************************************
  4186. * @fn zclSE_ProcessInCmd_Pricing_PublishBlockPeriod
  4187. *
  4188. * @brief Process in the received Publish Block Period.
  4189. *
  4190. * @param pInMsg - pointer to the incoming message
  4191. * @param pCBs - pointer to the application call back function
  4192. *
  4193. * @return ZStatus_t - ZFailure @ Unsupported
  4194. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4195. * not need default rsp
  4196. */
  4197. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishBlockPeriod( zclIncoming_t *pInMsg,
  4198. zclSE_AppCallbacks_t *pCBs )
  4199. {
  4200. if ( pCBs->pfnPricing_PublishBlockPeriod )
  4201. {
  4202. zclCCPublishBlockPeriod_t cmd;
  4203. // Parse the command and do range check
  4204. zclSE_ParseInCmd_PublishBlockPeriod( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  4205. pCBs->pfnPricing_PublishBlockPeriod( &cmd, &(pInMsg->msg->srcAddr),
  4206. pInMsg->hdr.transSeqNum );
  4207. return ZCL_STATUS_CMD_HAS_RSP;
  4208. }
  4209. return ZFailure;
  4210. }
  4211. #ifdef SE_UK_EXT
  4212. /*********************************************************************
  4213. * @fn zclSE_ProcessInCmd_Pricing_PublishTariffInformation
  4214. *
  4215. * @brief Process in the received Publish Tarif Information.
  4216. *
  4217. * @param pInMsg - pointer to the incoming message
  4218. * @param pCBs - pointer to the application call back function
  4219. *
  4220. * @return ZStatus_t - ZFailure @ Unsupported
  4221. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4222. * not need default rsp
  4223. */
  4224. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishTariffInformation( zclIncoming_t *pInMsg,
  4225. zclSE_AppCallbacks_t *pCBs )
  4226. {
  4227. if ( pCBs->pfnPricing_PublishTariffInformation )
  4228. {
  4229. zclCCPublishTariffInformation_t cmd;
  4230. zclSE_ParseInCmd_PublishTariffInformation( &cmd, &(pInMsg->pData[0]),
  4231. pInMsg->pDataLen );
  4232. pCBs->pfnPricing_PublishTariffInformation( &cmd, &(pInMsg->msg->srcAddr),
  4233. pInMsg->hdr.transSeqNum );
  4234. return ZCL_STATUS_CMD_HAS_RSP;
  4235. }
  4236. return ZFailure;
  4237. }
  4238. /*********************************************************************
  4239. * @fn zclSE_ProcessInCmd_Pricing_PublishPriceMatrix
  4240. *
  4241. * @brief Process in the received Publish Price Matrix.
  4242. *
  4243. * @param pInMsg - pointer to the incoming message
  4244. * @param pCBs - pointer to the application call back function
  4245. *
  4246. * @return ZStatus_t - ZFailure @ Unsupported
  4247. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4248. * not need default rsp
  4249. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  4250. */
  4251. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishPriceMatrix( zclIncoming_t *pInMsg,
  4252. zclSE_AppCallbacks_t *pCBs )
  4253. {
  4254. if ( pCBs->pfnPricing_PublishPriceMatrix )
  4255. {
  4256. zclCCPublishPriceMatrix_t cmd;
  4257. if ( zclSE_ParseInCmd_PublishPriceMatrix( &cmd, &(pInMsg->pData[0]),
  4258. pInMsg->pDataLen ) == ZSuccess )
  4259. {
  4260. pCBs->pfnPricing_PublishPriceMatrix( &cmd, &(pInMsg->msg->srcAddr),
  4261. pInMsg->hdr.transSeqNum );
  4262. if ( cmd.pTierBlockPrice != NULL )
  4263. {
  4264. osal_mem_free( cmd.pTierBlockPrice );
  4265. }
  4266. return ZCL_STATUS_CMD_HAS_RSP;
  4267. }
  4268. else
  4269. {
  4270. return ZCL_STATUS_SOFTWARE_FAILURE;
  4271. }
  4272. }
  4273. return ZFailure;
  4274. }
  4275. /*********************************************************************
  4276. * @fn zclSE_ProcessInCmd_Pricing_PublishBlockThreshold
  4277. *
  4278. * @brief Process in the received Publish Block Threshold.
  4279. *
  4280. * @param pInMsg - pointer to the incoming message
  4281. * @param pCBs - pointer to the application call back function
  4282. *
  4283. * @return ZStatus_t - ZFailure @ Unsupported
  4284. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4285. * not need default rsp
  4286. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  4287. */
  4288. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishBlockThreshold( zclIncoming_t *pInMsg,
  4289. zclSE_AppCallbacks_t *pCBs )
  4290. {
  4291. if ( pCBs->pfnPricing_PublishBlockThresholds )
  4292. {
  4293. zclCCPublishBlockThresholds_t cmd;
  4294. if ( zclSE_ParseInCmd_PublishBlockThresholds( &cmd, &(pInMsg->pData[0]),
  4295. pInMsg->pDataLen ) == ZSuccess )
  4296. {
  4297. pCBs->pfnPricing_PublishBlockThresholds( &cmd, &(pInMsg->msg->srcAddr),
  4298. pInMsg->hdr.transSeqNum );
  4299. if ( cmd.pTierBlockThreshold != NULL )
  4300. {
  4301. osal_mem_free( cmd.pTierBlockThreshold );
  4302. }
  4303. return ZCL_STATUS_CMD_HAS_RSP;
  4304. }
  4305. else
  4306. {
  4307. return ZCL_STATUS_SOFTWARE_FAILURE;
  4308. }
  4309. }
  4310. return ZFailure;
  4311. }
  4312. /*********************************************************************
  4313. * @fn zclSE_ProcessInCmd_Pricing_PublishConversionFactor
  4314. *
  4315. * @brief Process in the received Publish Conversion Factor.
  4316. *
  4317. * @param pInMsg - pointer to the incoming message
  4318. * @param pCBs - pointer to the application call back function
  4319. *
  4320. * @return ZStatus_t - ZFailure @ Unsupported
  4321. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4322. * not need default rsp
  4323. */
  4324. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishConversionFactor( zclIncoming_t *pInMsg,
  4325. zclSE_AppCallbacks_t *pCBs )
  4326. {
  4327. if ( pCBs->pfnPricing_PublishConversionFactor )
  4328. {
  4329. zclCCPublishConversionFactor_t cmd;
  4330. zclSE_ParseInCmd_PublishConversionFactor( &cmd, &(pInMsg->pData[0]),
  4331. pInMsg->pDataLen );
  4332. pCBs->pfnPricing_PublishConversionFactor( &cmd, &(pInMsg->msg->srcAddr),
  4333. pInMsg->hdr.transSeqNum );
  4334. return ZCL_STATUS_CMD_HAS_RSP;
  4335. }
  4336. return ZFailure;
  4337. }
  4338. /*********************************************************************
  4339. * @fn zclSE_ProcessInCmd_Pricing_PublishCalorificValue
  4340. *
  4341. * @brief Process in the received Publish Calorific Value.
  4342. *
  4343. * @param pInMsg - pointer to the incoming message
  4344. * @param pCBs - pointer to the application call back function
  4345. *
  4346. * @return ZStatus_t - ZFailure @ Unsupported
  4347. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4348. * not need default rsp
  4349. */
  4350. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishCalorificValue( zclIncoming_t *pInMsg,
  4351. zclSE_AppCallbacks_t *pCBs )
  4352. {
  4353. if ( pCBs->pfnPricing_PublishCalorificValue )
  4354. {
  4355. zclCCPublishCalorificValue_t cmd;
  4356. zclSE_ParseInCmd_PublishCalorificValue( &cmd, &(pInMsg->pData[0]),
  4357. pInMsg->pDataLen );
  4358. pCBs->pfnPricing_PublishCalorificValue( &cmd, &(pInMsg->msg->srcAddr),
  4359. pInMsg->hdr.transSeqNum );
  4360. return ZCL_STATUS_CMD_HAS_RSP;
  4361. }
  4362. return ZFailure;
  4363. }
  4364. /*********************************************************************
  4365. * @fn zclSE_ProcessInCmd_Pricing_PublishCO2Value
  4366. *
  4367. * @brief Process in the received Publish CO2 Value.
  4368. *
  4369. * @param pInMsg - pointer to the incoming message
  4370. * @param pCBs - pointer to the application call back function
  4371. *
  4372. * @return ZStatus_t - ZFailure @ Unsupported
  4373. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4374. * not need default rsp
  4375. */
  4376. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishCO2Value( zclIncoming_t *pInMsg,
  4377. zclSE_AppCallbacks_t *pCBs )
  4378. {
  4379. if ( pCBs->pfnPricing_PublishCO2Value )
  4380. {
  4381. zclCCPublishCO2Value_t cmd;
  4382. zclSE_ParseInCmd_PublishCO2Value( &cmd, &(pInMsg->pData[0]),
  4383. pInMsg->pDataLen );
  4384. pCBs->pfnPricing_PublishCO2Value( &cmd, &(pInMsg->msg->srcAddr),
  4385. pInMsg->hdr.transSeqNum );
  4386. return ZCL_STATUS_CMD_HAS_RSP;
  4387. }
  4388. return ZFailure;
  4389. }
  4390. /*********************************************************************
  4391. * @fn zclSE_ProcessInCmd_Pricing_PublishCPPEvent
  4392. *
  4393. * @brief Process in the received Publish CPP Event.
  4394. *
  4395. * @param pInMsg - pointer to the incoming message
  4396. * @param pCBs - pointer to the application call back function
  4397. *
  4398. * @return ZStatus_t - ZFailure @ Unsupported
  4399. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4400. * not need default rsp
  4401. */
  4402. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishCPPEvent( zclIncoming_t *pInMsg,
  4403. zclSE_AppCallbacks_t *pCBs )
  4404. {
  4405. if ( pCBs->pfnPricing_PublishCPPEvent )
  4406. {
  4407. zclCCPublishCPPEvent_t cmd;
  4408. zclSE_ParseInCmd_PublishCPPEvent( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  4409. pCBs->pfnPricing_PublishCPPEvent( &cmd, &(pInMsg->msg->srcAddr),
  4410. pInMsg->hdr.transSeqNum );
  4411. return ZCL_STATUS_CMD_HAS_RSP;
  4412. }
  4413. return ZFailure;
  4414. }
  4415. /*********************************************************************
  4416. * @fn zclSE_ProcessInCmd_Pricing_PublishBillingPeriod
  4417. *
  4418. * @brief Process in the received Publish Billing Period.
  4419. *
  4420. * @param pInMsg - pointer to the incoming message
  4421. * @param pCBs - pointer to the application call back function
  4422. *
  4423. * @return ZStatus_t - ZFailure @ Unsupported
  4424. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4425. * not need default rsp
  4426. */
  4427. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishBillingPeriod( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  4428. {
  4429. if ( pCBs->pfnPricing_PublishBillingPeriod )
  4430. {
  4431. zclCCPublishBillingPeriod_t cmd;
  4432. zclSE_ParseInCmd_PublishBillingPeriod( &cmd, &(pInMsg->pData[0]),
  4433. pInMsg->pDataLen );
  4434. pCBs->pfnPricing_PublishBillingPeriod( &cmd, &(pInMsg->msg->srcAddr),
  4435. pInMsg->hdr.transSeqNum );
  4436. return ZCL_STATUS_CMD_HAS_RSP;
  4437. }
  4438. return ZFailure;
  4439. }
  4440. /*********************************************************************
  4441. * @fn zclSE_ProcessInCmd_Pricing_PublishConsolidatedBill
  4442. *
  4443. * @brief Process in the received Publish Consolidated Bill.
  4444. *
  4445. * @param pInMsg - pointer to the incoming message
  4446. * @param pCBs - pointer to the application call back function
  4447. *
  4448. * @return ZStatus_t - ZFailure @ Unsupported
  4449. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4450. * not need default rsp
  4451. */
  4452. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishConsolidatedBill( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  4453. {
  4454. if ( pCBs->pfnPricing_PublishConsolidatedBill )
  4455. {
  4456. zclCCPublishConsolidatedBill_t cmd;
  4457. zclSE_ParseInCmd_PublishConsolidatedBill( &cmd, &(pInMsg->pData[0]),
  4458. pInMsg->pDataLen );
  4459. pCBs->pfnPricing_PublishConsolidatedBill( &cmd, &(pInMsg->msg->srcAddr),
  4460. pInMsg->hdr.transSeqNum );
  4461. return ZCL_STATUS_CMD_HAS_RSP;
  4462. }
  4463. return ZFailure;
  4464. }
  4465. /*********************************************************************
  4466. * @fn zclSE_ProcessInCmd_Pricing_PublishCreditPaymentInfo
  4467. *
  4468. * @brief Process in the received Publish Credit Payment Information.
  4469. *
  4470. * @param pInMsg - pointer to the incoming message
  4471. * @param pCBs - pointer to the application call back function
  4472. *
  4473. * @return ZStatus_t - ZFailure @ Unsupported
  4474. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4475. * not need default rsp
  4476. */
  4477. static ZStatus_t zclSE_ProcessInCmd_Pricing_PublishCreditPaymentInfo( zclIncoming_t *pInMsg,
  4478. zclSE_AppCallbacks_t *pCBs )
  4479. {
  4480. if ( pCBs->pfnPricing_PublishCreditPaymentInfo )
  4481. {
  4482. zclCCPublishCreditPaymentInfo_t cmd;
  4483. zclSE_ParseInCmd_PublishCreditPaymentInfo( &cmd, &(pInMsg->pData[0]),
  4484. pInMsg->pDataLen );
  4485. pCBs->pfnPricing_PublishCreditPaymentInfo( &cmd, &(pInMsg->msg->srcAddr),
  4486. pInMsg->hdr.transSeqNum );
  4487. return ZCL_STATUS_CMD_HAS_RSP;
  4488. }
  4489. return ZFailure;
  4490. }
  4491. /*********************************************************************
  4492. * @fn zclSE_ProcessInCmd_Pricing_GetTariffInformation
  4493. *
  4494. * @brief Process in the received Get Tariff Information.
  4495. *
  4496. * @param pInMsg - pointer to the incoming message
  4497. * @param pCBs - pointer to the application call back function
  4498. *
  4499. * @return ZStatus_t - ZFailure @ Unsupported
  4500. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4501. * not need default rsp
  4502. */
  4503. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetTariffInformation( zclIncoming_t *pInMsg,
  4504. zclSE_AppCallbacks_t *pCBs )
  4505. {
  4506. if ( pCBs->pfnPricing_GetTariffInformation )
  4507. {
  4508. zclCCGetTariffInformation_t cmd;
  4509. zclSE_ParseInCmd_GetTariffInformation( &cmd, &(pInMsg->pData[0]),
  4510. pInMsg->pDataLen );
  4511. pCBs->pfnPricing_GetTariffInformation( &cmd, &(pInMsg->msg->srcAddr),
  4512. pInMsg->hdr.transSeqNum );
  4513. return ZCL_STATUS_CMD_HAS_RSP;
  4514. }
  4515. return ZFailure;
  4516. }
  4517. /*********************************************************************
  4518. * @fn zclSE_ProcessInCmd_Pricing_GetPriceMatrix
  4519. *
  4520. * @brief Process in the received Get Price Matrix.
  4521. *
  4522. * @param pInMsg - pointer to the incoming message
  4523. * @param pCBs - pointer to the application call back function
  4524. *
  4525. * @return ZStatus_t - ZFailure @ Unsupported
  4526. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4527. * not need default rsp
  4528. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  4529. */
  4530. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetPriceMatrix( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  4531. {
  4532. if ( pCBs->pfnPricing_GetPriceMatrix )
  4533. {
  4534. uint32 issuerTariffId = osal_build_uint32( pInMsg->pData, 4 );
  4535. pCBs->pfnPricing_GetPriceMatrix( issuerTariffId, &(pInMsg->msg->srcAddr),
  4536. pInMsg->hdr.transSeqNum );
  4537. return ZCL_STATUS_CMD_HAS_RSP;
  4538. }
  4539. return ZFailure;
  4540. }
  4541. /*********************************************************************
  4542. * @fn zclSE_ProcessInCmd_Pricing_GetBlockThresholds
  4543. *
  4544. * @brief Process in the received Get Block Thresholds.
  4545. *
  4546. * @param pInMsg - pointer to the incoming message
  4547. * @param pCBs - pointer to the application call back function
  4548. *
  4549. * @return ZStatus_t - ZFailure @ Unsupported
  4550. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4551. * not need default rsp
  4552. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  4553. */
  4554. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetBlockThresholds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  4555. {
  4556. if ( pCBs->pfnPricing_GetBlockThresholds )
  4557. {
  4558. uint32 issuerTariffId = osal_build_uint32( pInMsg->pData, 4 );
  4559. pCBs->pfnPricing_GetBlockThresholds( issuerTariffId, &(pInMsg->msg->srcAddr),
  4560. pInMsg->hdr.transSeqNum );
  4561. return ZCL_STATUS_CMD_HAS_RSP;
  4562. }
  4563. return ZFailure;
  4564. }
  4565. /*********************************************************************
  4566. * @fn zclSE_ProcessInCmd_Pricing_GetConversionFactor
  4567. *
  4568. * @brief Process in the received Get Conversion Factor.
  4569. *
  4570. * @param pInMsg - pointer to the incoming message
  4571. * @param pCBs - pointer to the application call back function
  4572. *
  4573. * @return ZStatus_t - ZFailure @ Unsupported
  4574. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4575. * not need default rsp
  4576. */
  4577. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetConversionFactor( zclIncoming_t *pInMsg,
  4578. zclSE_AppCallbacks_t *pCBs )
  4579. {
  4580. if ( pCBs->pfnPricing_GetConversionFactor )
  4581. {
  4582. zclCCGetConversionFactor_t cmd;
  4583. zclSE_ParseInCmd_GetConversionFactor( &cmd, &(pInMsg->pData[0]),
  4584. pInMsg->pDataLen );
  4585. pCBs->pfnPricing_GetConversionFactor( &cmd, &(pInMsg->msg->srcAddr),
  4586. pInMsg->hdr.transSeqNum );
  4587. return ZCL_STATUS_CMD_HAS_RSP;
  4588. }
  4589. return ZFailure;
  4590. }
  4591. /*********************************************************************
  4592. * @fn zclSE_ProcessInCmd_Pricing_GetCalorificValue
  4593. *
  4594. * @brief Process in the received Get Calorific Value.
  4595. *
  4596. * @param pInMsg - pointer to the incoming message
  4597. * @param pCBs - pointer to the application call back function
  4598. *
  4599. * @return ZStatus_t - ZFailure @ Unsupported
  4600. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4601. * not need default rsp
  4602. */
  4603. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetCalorificValue( zclIncoming_t *pInMsg,
  4604. zclSE_AppCallbacks_t *pCBs )
  4605. {
  4606. if ( pCBs->pfnPricing_GetCalorificValue )
  4607. {
  4608. zclCCGetCalorificValue_t cmd;
  4609. zclSE_ParseInCmd_GetCalorificValue( &cmd, &(pInMsg->pData[0]),
  4610. pInMsg->pDataLen );
  4611. pCBs->pfnPricing_GetCalorificValue( &cmd, &(pInMsg->msg->srcAddr),
  4612. pInMsg->hdr.transSeqNum );
  4613. return ZCL_STATUS_CMD_HAS_RSP;
  4614. }
  4615. return ZFailure;
  4616. }
  4617. /*********************************************************************
  4618. * @fn zclSE_ProcessInCmd_Pricing_GetCO2Value
  4619. *
  4620. * @brief Process in the received Get CO2 Value.
  4621. *
  4622. * @param pInMsg - pointer to the incoming message
  4623. * @param pCBs - pointer to the application call back function
  4624. *
  4625. * @return ZStatus_t - ZFailure @ Unsupported
  4626. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4627. * not need default rsp
  4628. */
  4629. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetCO2Value( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  4630. {
  4631. if ( pCBs->pfnPricing_GetCO2Value )
  4632. {
  4633. zclCCGetCO2Value_t cmd;
  4634. zclSE_ParseInCmd_GetCO2Value( &cmd, &(pInMsg->pData[0]),
  4635. pInMsg->pDataLen );
  4636. pCBs->pfnPricing_GetCO2Value( &cmd, &(pInMsg->msg->srcAddr),
  4637. pInMsg->hdr.transSeqNum );
  4638. return ZCL_STATUS_CMD_HAS_RSP;
  4639. }
  4640. return ZFailure;
  4641. }
  4642. /*********************************************************************
  4643. * @fn zclSE_ProcessInCmd_Pricing_GetBillingPeriod
  4644. *
  4645. * @brief Process in the received Get Billing Period.
  4646. *
  4647. * @param pInMsg - pointer to the incoming message
  4648. * @param pCBs - pointer to the application call back function
  4649. *
  4650. * @return ZStatus_t - ZFailure @ Unsupported
  4651. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4652. * not need default rsp
  4653. */
  4654. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetBillingPeriod( zclIncoming_t *pInMsg,
  4655. zclSE_AppCallbacks_t *pCBs )
  4656. {
  4657. if ( pCBs->pfnPricing_GetBillingPeriod )
  4658. {
  4659. zclCCGetBillingPeriod_t cmd;
  4660. zclSE_ParseInCmd_GetBillingPeriod( &cmd, &(pInMsg->pData[0]),
  4661. pInMsg->pDataLen );
  4662. pCBs->pfnPricing_GetBillingPeriod( &cmd, &(pInMsg->msg->srcAddr),
  4663. pInMsg->hdr.transSeqNum );
  4664. return ZCL_STATUS_CMD_HAS_RSP;
  4665. }
  4666. return ZFailure;
  4667. }
  4668. /*********************************************************************
  4669. * @fn zclSE_ProcessInCmd_Pricing_GetConsolidatedBill
  4670. *
  4671. * @brief Process in the received Get Consolidated Bill.
  4672. *
  4673. * @param pInMsg - pointer to the incoming message
  4674. * @param pCBs - pointer to the application call back function
  4675. *
  4676. * @return ZStatus_t - ZFailure @ Unsupported
  4677. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4678. * not need default rsp
  4679. */
  4680. static ZStatus_t zclSE_ProcessInCmd_Pricing_GetConsolidatedBill( zclIncoming_t *pInMsg,
  4681. zclSE_AppCallbacks_t *pCBs )
  4682. {
  4683. if ( pCBs->pfnPricing_GetConsolidatedBill )
  4684. {
  4685. zclCCGetConsolidatedBill_t cmd;
  4686. zclSE_ParseInCmd_GetConsolidatedBill( &cmd, &(pInMsg->pData[0]),
  4687. pInMsg->pDataLen );
  4688. pCBs->pfnPricing_GetConsolidatedBill( &cmd, &(pInMsg->msg->srcAddr),
  4689. pInMsg->hdr.transSeqNum );
  4690. return ZCL_STATUS_CMD_HAS_RSP;
  4691. }
  4692. return ZFailure;
  4693. }
  4694. /*********************************************************************
  4695. * @fn zclSE_ProcessInCmd_Pricing_CPPEventResponse
  4696. *
  4697. * @brief Process in the received a CPP Event Response.
  4698. *
  4699. * @param pInMsg - pointer to the incoming message
  4700. * @param pCBs - pointer to the application call back function
  4701. *
  4702. * @return ZStatus_t - ZFailure @ Unsupported
  4703. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4704. * not need default rsp
  4705. */
  4706. static ZStatus_t zclSE_ProcessInCmd_Pricing_CPPEventResponse( zclIncoming_t *pInMsg,
  4707. zclSE_AppCallbacks_t *pCBs )
  4708. {
  4709. if ( pCBs->pfnPricing_CPPEventResponse )
  4710. {
  4711. zclCCCPPEventResponse_t cmd;
  4712. zclSE_ParseInCmd_CPPEventResponse( &cmd, &(pInMsg->pData[0]),
  4713. pInMsg->pDataLen );
  4714. pCBs->pfnPricing_CPPEventResponse( &cmd, &(pInMsg->msg->srcAddr),
  4715. pInMsg->hdr.transSeqNum );
  4716. return ZCL_STATUS_CMD_HAS_RSP;
  4717. }
  4718. return ZFailure;
  4719. }
  4720. #endif // SE_UK_EXT
  4721. #endif // ZCL_PRICING
  4722. #ifdef ZCL_MESSAGE
  4723. /*********************************************************************
  4724. * @fn zclSE_ProcessInMessageCmds
  4725. *
  4726. * @brief Callback from ZCL to process incoming Commands specific
  4727. * to this cluster library on a command ID basis
  4728. *
  4729. * @param pInMsg - pointer to the incoming message
  4730. * @param pCBs - pointer to the application call back function
  4731. *
  4732. * @return ZStatus_t
  4733. */
  4734. static ZStatus_t zclSE_ProcessInMessageCmds( zclIncoming_t *pInMsg,
  4735. zclSE_AppCallbacks_t *pCBs )
  4736. {
  4737. ZStatus_t stat;
  4738. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  4739. {
  4740. // Process Client commands, received by server
  4741. switch ( pInMsg->hdr.commandID )
  4742. {
  4743. case COMMAND_SE_GET_LAST_MESSAGE:
  4744. stat = zclSE_ProcessInCmd_Message_GetLastMessage( pInMsg, pCBs );
  4745. break;
  4746. case COMMAND_SE_MESSAGE_CONFIRMATION:
  4747. stat = zclSE_ProcessInCmd_Message_MessageConfirmation( pInMsg, pCBs );
  4748. break;
  4749. default:
  4750. stat = ZFailure;
  4751. break;
  4752. }
  4753. }
  4754. else
  4755. {
  4756. // Process Server commands, received by client
  4757. switch ( pInMsg->hdr.commandID )
  4758. {
  4759. case COMMAND_SE_DISPLAY_MESSAGE:
  4760. stat = zclSE_ProcessInCmd_Message_DisplayMessage( pInMsg, pCBs );
  4761. break;
  4762. case COMMAND_SE_CANCEL_MESSAGE:
  4763. stat = zclSE_ProcessInCmd_Message_CancelMessage( pInMsg, pCBs );
  4764. break;
  4765. default:
  4766. stat = ZFailure;
  4767. break;
  4768. }
  4769. }
  4770. return ( stat );
  4771. }
  4772. /*********************************************************************
  4773. * @fn zclSE_ProcessInCmd_Message_DisplayMessage
  4774. *
  4775. * @brief Process in the received Display Message Command.
  4776. *
  4777. * @param pInMsg - pointer to the incoming message
  4778. * @param pCBs - pointer to the application call back function
  4779. *
  4780. * @return ZStatus_t - ZFailure @ Unsupported
  4781. * ZSuccess @ Supported and send default rsp
  4782. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  4783. */
  4784. static ZStatus_t zclSE_ProcessInCmd_Message_DisplayMessage( zclIncoming_t *pInMsg,
  4785. zclSE_AppCallbacks_t *pCBs )
  4786. {
  4787. if ( pCBs->pfnMessage_DisplayMessage )
  4788. {
  4789. zclCCDisplayMessage_t cmd;
  4790. if ( zclSE_ParseInCmd_DisplayMessage( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen ) == ZSuccess )
  4791. {
  4792. pCBs->pfnMessage_DisplayMessage( &cmd, &(pInMsg->msg->srcAddr),
  4793. pInMsg->hdr.transSeqNum );
  4794. // Free memory allocated in zclSE_ParseInCmd_DiplayMessage()
  4795. if ( cmd.msgString.pStr != NULL )
  4796. {
  4797. osal_mem_free( cmd.msgString.pStr );
  4798. }
  4799. return ZSuccess;
  4800. }
  4801. else
  4802. {
  4803. return ZCL_STATUS_SOFTWARE_FAILURE;
  4804. }
  4805. }
  4806. return ZFailure;
  4807. }
  4808. /*********************************************************************
  4809. * @fn zclSE_ProcessInCmd_Message_CancelMessage
  4810. *
  4811. * @brief Process in the received Cancel Message Command.
  4812. *
  4813. * @param pInMsg - pointer to the incoming message
  4814. * @param pCBs - pointer to the application call back function
  4815. *
  4816. * @return ZStatus_t - ZFailure @ Unsupported
  4817. * ZSuccess @ Supported and send default rsp
  4818. */
  4819. static ZStatus_t zclSE_ProcessInCmd_Message_CancelMessage( zclIncoming_t *pInMsg,
  4820. zclSE_AppCallbacks_t *pCBs )
  4821. {
  4822. if ( pCBs->pfnMessage_CancelMessage )
  4823. {
  4824. zclCCCancelMessage_t cmd;
  4825. zclSE_ParseInCmd_CancelMessage( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  4826. pCBs->pfnMessage_CancelMessage( &cmd, &(pInMsg->msg->srcAddr),
  4827. pInMsg->hdr.transSeqNum );
  4828. return ZSuccess;
  4829. }
  4830. return ZFailure;
  4831. }
  4832. /*********************************************************************
  4833. * @fn zclSE_ProcessInCmd_Message_GetLastMessage
  4834. *
  4835. * @brief Process in the received Get Last Message Command.
  4836. *
  4837. * @param pInMsg - pointer to the incoming message
  4838. * @param pCBs - pointer to the application call back function
  4839. *
  4840. * @return ZStatus_t - ZFailure @ Unsupported
  4841. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4842. * not need default rsp
  4843. */
  4844. static ZStatus_t zclSE_ProcessInCmd_Message_GetLastMessage( zclIncoming_t *pInMsg,
  4845. zclSE_AppCallbacks_t *pCBs )
  4846. {
  4847. if ( pCBs->pfnMessage_GetLastMessage )
  4848. {
  4849. pCBs->pfnMessage_GetLastMessage( &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  4850. return ZCL_STATUS_CMD_HAS_RSP;
  4851. }
  4852. return ZFailure;
  4853. }
  4854. /*********************************************************************
  4855. * @fn zclSE_ProcessInCmd_Message_MessageConfirmation
  4856. *
  4857. * @brief Process in the received Message Confirmation.
  4858. *
  4859. * @param pInMsg - pointer to the incoming message
  4860. * @param pCBs - pointer to the application call back function
  4861. *
  4862. * @return ZStatus_t - ZFailure @ Unsupported
  4863. * ZSuccess @ Supported and send default rsp
  4864. */
  4865. static ZStatus_t zclSE_ProcessInCmd_Message_MessageConfirmation( zclIncoming_t *pInMsg,
  4866. zclSE_AppCallbacks_t *pCBs )
  4867. {
  4868. if ( pCBs->pfnMessage_MessageConfirmation )
  4869. {
  4870. zclCCMessageConfirmation_t cmd;
  4871. zclSE_ParseInCmd_MessageConfirmation( &cmd, &(pInMsg->pData[0]),
  4872. pInMsg->pDataLen );
  4873. pCBs->pfnMessage_MessageConfirmation( &cmd, &(pInMsg->msg->srcAddr),
  4874. pInMsg->hdr.transSeqNum );
  4875. return ZSuccess;
  4876. }
  4877. return ZFailure;
  4878. }
  4879. #endif // ZCL_MESSAGE
  4880. #ifdef ZCL_LOAD_CONTROL
  4881. /*********************************************************************
  4882. * @fn zclSE_ProcessInLoadControlCmds
  4883. *
  4884. * @brief Callback from ZCL to process incoming Commands specific
  4885. * to this cluster library on a command ID basis
  4886. *
  4887. * @param pInMsg - pointer to the incoming message
  4888. * @param pCBs - pointer to the application call back function
  4889. *
  4890. * @return ZStatus_t
  4891. */
  4892. static ZStatus_t zclSE_ProcessInLoadControlCmds( zclIncoming_t *pInMsg,
  4893. zclSE_AppCallbacks_t *pCBs )
  4894. {
  4895. ZStatus_t stat;
  4896. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  4897. {
  4898. // Process Client commands, received by server
  4899. switch ( pInMsg->hdr.commandID )
  4900. {
  4901. case COMMAND_SE_REPORT_EVENT_STATUS:
  4902. stat = zclSE_ProcessInCmd_LoadControl_ReportEventStatus( pInMsg, pCBs );
  4903. break;
  4904. case COMMAND_SE_GET_SCHEDULED_EVENT:
  4905. stat = zclSE_ProcessInCmd_LoadControl_GetScheduledEvents( pInMsg, pCBs );
  4906. break;
  4907. default:
  4908. stat = ZFailure;
  4909. break;
  4910. }
  4911. }
  4912. else
  4913. {
  4914. // Process Server commands, received by client
  4915. switch ( pInMsg->hdr.commandID )
  4916. {
  4917. case COMMAND_SE_LOAD_CONTROL_EVENT:
  4918. stat = zclSE_ProcessInCmd_LoadControl_LoadControlEvent( pInMsg, pCBs );
  4919. break;
  4920. case COMMAND_SE_CANCEL_LOAD_CONTROL_EVENT:
  4921. stat = zclSE_ProcessInCmd_LoadControl_CancelLoadControlEvent( pInMsg, pCBs );
  4922. break;
  4923. case COMMAND_SE_CANCEL_ALL_LOAD_CONTROL_EVENT:
  4924. stat = zclSE_ProcessInCmd_LoadControl_CancelAllLoadControlEvents( pInMsg, pCBs );
  4925. break;
  4926. default:
  4927. stat = ZFailure;
  4928. break;
  4929. }
  4930. }
  4931. return ( stat );
  4932. }
  4933. /*********************************************************************
  4934. * @fn zclSE_ProcessInCmd_LoadControl_LoadControlEvent
  4935. *
  4936. * @brief Process in the received Load Control Event.
  4937. *
  4938. * @param pInMsg - pointer to the incoming message
  4939. * @param pCBs - pointer to the application call back function
  4940. *
  4941. * @return ZStatus_t - ZFailure @ Unsupported
  4942. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  4943. * not need default rsp
  4944. * ZCL_STATUS_INVALID_FIELD @ Invalid field value
  4945. */
  4946. static ZStatus_t zclSE_ProcessInCmd_LoadControl_LoadControlEvent( zclIncoming_t *pInMsg,
  4947. zclSE_AppCallbacks_t *pCBs )
  4948. {
  4949. uint8 status = ZSuccess;
  4950. if ( pCBs->pfnLoadControl_LoadControlEvent )
  4951. {
  4952. zclCCLoadControlEvent_t cmd;
  4953. zclSE_ParseInCmd_LoadControlEvent( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  4954. // Range checking
  4955. if ( cmd.durationInMinutes > MAX_DURATION_IN_MINUTES_SE_LOAD_CONTROL )
  4956. {
  4957. status = ZCL_STATUS_INVALID_FIELD;
  4958. }
  4959. if ( cmd.criticalityLevel > MAX_CRITICAL_LEVEL_SE_LOAD_CONTROL )
  4960. {
  4961. status = ZCL_STATUS_INVALID_FIELD;
  4962. }
  4963. if ( cmd. coolingTemperatureSetPoint != SE_OPTIONAL_FIELD_TEMPERATURE_SET_POINT &&
  4964. cmd. coolingTemperatureSetPoint > MAX_TEMPERATURE_SETPOINT_SE_LOAD_CONTROL )
  4965. {
  4966. status = ZCL_STATUS_INVALID_FIELD;
  4967. }
  4968. if ( cmd. heatingTemperatureSetPoint != SE_OPTIONAL_FIELD_TEMPERATURE_SET_POINT &&
  4969. cmd. heatingTemperatureSetPoint > MAX_TEMPERATURE_SETPOINT_SE_LOAD_CONTROL )
  4970. {
  4971. status = ZCL_STATUS_INVALID_FIELD;
  4972. }
  4973. if ( cmd.averageLoadAdjustmentPercentage != SE_OPTIONAL_FIELD_INT8 &&
  4974. (cmd.averageLoadAdjustmentPercentage < MIN_AVERAGE_LOAD_ADJUSTMENT_PERCENTAGE_SE ||
  4975. cmd.averageLoadAdjustmentPercentage > MAX_AVERAGE_LOAD_ADJUSTMENT_PERCENTAGE_SE ) )
  4976. {
  4977. status = ZCL_STATUS_INVALID_FIELD;
  4978. }
  4979. if ( cmd. dutyCycle != SE_OPTIONAL_FIELD_UINT8 &&
  4980. cmd. dutyCycle > MAX_DUTY_CYCLE_SE_LOAD_CONTROL )
  4981. {
  4982. status = ZCL_STATUS_INVALID_FIELD;
  4983. }
  4984. // If any of the four fields is optional, set them all to optional
  4985. if ( cmd.coolingTemperatureOffset == SE_OPTIONAL_FIELD_UINT8 ||
  4986. cmd.heatingTemperatureOffset == SE_OPTIONAL_FIELD_UINT8 ||
  4987. cmd.coolingTemperatureSetPoint == SE_OPTIONAL_FIELD_UINT16 ||
  4988. cmd.heatingTemperatureSetPoint == SE_OPTIONAL_FIELD_UINT16 )
  4989. {
  4990. cmd.coolingTemperatureOffset = SE_OPTIONAL_FIELD_UINT8;
  4991. cmd.heatingTemperatureOffset = SE_OPTIONAL_FIELD_UINT8;
  4992. cmd.coolingTemperatureSetPoint = SE_OPTIONAL_FIELD_UINT16;
  4993. cmd.heatingTemperatureSetPoint = SE_OPTIONAL_FIELD_UINT16;
  4994. }
  4995. pCBs->pfnLoadControl_LoadControlEvent( &cmd, &(pInMsg->msg->srcAddr), status, pInMsg->hdr.transSeqNum );
  4996. // The Load Control Event command has response, therefore,
  4997. // inform zclto not to send default response.
  4998. return ZCL_STATUS_CMD_HAS_RSP;
  4999. }
  5000. return ZFailure; // Not supported
  5001. }
  5002. /*********************************************************************
  5003. * @fn zclSE_ProcessInCmd_LoadControl_CancelLoadControlEvent
  5004. *
  5005. * @brief Process in the received Cancel Load Control Event.
  5006. *
  5007. * @param pInMsg - pointer to the incoming message
  5008. * @param pCBs - pointer to the application call back function
  5009. *
  5010. * @return ZStatus_t - ZFailure @ Unsupported
  5011. * ZSuccess @ Supported and send default rsp
  5012. */
  5013. static ZStatus_t zclSE_ProcessInCmd_LoadControl_CancelLoadControlEvent( zclIncoming_t *pInMsg,
  5014. zclSE_AppCallbacks_t *pCBs )
  5015. {
  5016. if ( pCBs->pfnLoadControl_CancelLoadControlEvent )
  5017. {
  5018. zclCCCancelLoadControlEvent_t cmd;
  5019. zclSE_ParseInCmd_CancelLoadControlEvent( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  5020. pCBs->pfnLoadControl_CancelLoadControlEvent( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  5021. return ZSuccess;
  5022. }
  5023. return ZFailure;
  5024. }
  5025. /*********************************************************************
  5026. * @fn zclSE_ProcessInCmd_LoadControl_CancelAllLoadControlEvent
  5027. *
  5028. * @brief Process in the received Cancel All Load Control Event.
  5029. *
  5030. * @param pInMsg - pointer to the incoming message
  5031. * @param pCBs - pointer to the application call back function
  5032. *
  5033. * @return ZStatus_t - ZFailure @ Unsupported
  5034. * ZSuccess @ Supported and send default rsp
  5035. */
  5036. static ZStatus_t zclSE_ProcessInCmd_LoadControl_CancelAllLoadControlEvents( zclIncoming_t *pInMsg,
  5037. zclSE_AppCallbacks_t *pCBs )
  5038. {
  5039. if ( pCBs->pfnLoadControl_CancelAllLoadControlEvents )
  5040. {
  5041. zclCCCancelAllLoadControlEvents_t cmd;
  5042. cmd.cancelControl = pInMsg->pData[0];
  5043. pCBs->pfnLoadControl_CancelAllLoadControlEvents( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  5044. return ZSuccess;
  5045. }
  5046. return ZFailure;
  5047. }
  5048. /*********************************************************************
  5049. * @fn zclSE_ProcessInCmd_LoadControl_ReportEventStatus
  5050. *
  5051. * @brief Process in the received Load Control Event.
  5052. *
  5053. * @param pInMsg - pointer to the incoming message
  5054. * @param pCBs - pointer to the application call back function
  5055. *
  5056. * @return ZStatus_t - ZFailure @ Unsupported
  5057. * ZSuccess @ Supported and send default rsp
  5058. * ZCL_STATUS_INVALID_FIELD @ Range checking
  5059. * failure
  5060. */
  5061. static ZStatus_t zclSE_ProcessInCmd_LoadControl_ReportEventStatus( zclIncoming_t *pInMsg,
  5062. zclSE_AppCallbacks_t *pCBs )
  5063. {
  5064. if ( pCBs->pfnLoadControl_ReportEventStatus )
  5065. {
  5066. zclCCReportEventStatus_t cmd;
  5067. zclSE_ParseInCmd_ReportEventStatus( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  5068. // Range Checking
  5069. if ( cmd.eventStatus != EVENT_STATUS_LOAD_CONTROL_EVENT_REJECTED &&
  5070. (cmd.eventStatus == 0 ||
  5071. cmd.eventStatus > EVENT_STATUS_LOAD_CONTROL_EVENT_SUPERSEDED ) )
  5072. {
  5073. return ZCL_STATUS_INVALID_FIELD;
  5074. }
  5075. if ( cmd.criticalityLevelApplied > MAX_CRITICAL_LEVEL_SE_LOAD_CONTROL )
  5076. {
  5077. return ZCL_STATUS_INVALID_FIELD;
  5078. }
  5079. if ( cmd.coolingTemperatureSetPointApplied != SE_OPTIONAL_FIELD_TEMPERATURE_SET_POINT &&
  5080. cmd.coolingTemperatureSetPointApplied > MAX_TEMPERATURE_SETPOINT_SE_LOAD_CONTROL )
  5081. {
  5082. return ZCL_STATUS_INVALID_FIELD;
  5083. }
  5084. if ( cmd.heatingTemperatureSetPointApplied != SE_OPTIONAL_FIELD_TEMPERATURE_SET_POINT &&
  5085. cmd.heatingTemperatureSetPointApplied > MAX_TEMPERATURE_SETPOINT_SE_LOAD_CONTROL )
  5086. {
  5087. return ZCL_STATUS_INVALID_FIELD;
  5088. }
  5089. if ( cmd.averageLoadAdjustment != SE_OPTIONAL_FIELD_INT8 &&
  5090. (cmd.averageLoadAdjustment < MIN_AVERAGE_LOAD_ADJUSTMENT_PERCENTAGE_SE ||
  5091. cmd.averageLoadAdjustment > MAX_AVERAGE_LOAD_ADJUSTMENT_PERCENTAGE_SE ) )
  5092. {
  5093. return ZCL_STATUS_INVALID_FIELD;
  5094. }
  5095. if ( cmd.dutyCycleApplied != SE_OPTIONAL_FIELD_UINT8 &&
  5096. cmd.dutyCycleApplied > MAX_DUTY_CYCLE_SE_LOAD_CONTROL )
  5097. {
  5098. return ZCL_STATUS_INVALID_FIELD;
  5099. }
  5100. pCBs->pfnLoadControl_ReportEventStatus( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  5101. return ZSuccess;
  5102. }
  5103. return ZFailure;
  5104. }
  5105. /*********************************************************************
  5106. * @fn zclSE_ProcessInCmd_LoadControl_GetScheduledEvents
  5107. *
  5108. * @brief Process in the received Get Scheduled Event.
  5109. *
  5110. * @param pInMsg - pointer to the incoming message
  5111. * @param pCBs - pointer to the application call back function
  5112. *
  5113. * @return ZStatus_t - ZFailure @ Unsupported
  5114. * ZSuccess @ Supported and send default rsp
  5115. */
  5116. static ZStatus_t zclSE_ProcessInCmd_LoadControl_GetScheduledEvents( zclIncoming_t *pInMsg,
  5117. zclSE_AppCallbacks_t *pCBs )
  5118. {
  5119. if ( pCBs->pfnLoadControl_GetScheduledEvents )
  5120. {
  5121. zclCCGetScheduledEvent_t cmd;
  5122. cmd.startTime = osal_build_uint32( pInMsg->pData, 4);
  5123. cmd.numEvents = pInMsg->pData[4];
  5124. pCBs->pfnLoadControl_GetScheduledEvents( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  5125. return ZSuccess;
  5126. }
  5127. return ZFailure;
  5128. }
  5129. #endif // ZCL_LOAD_CONTROL
  5130. #ifdef ZCL_PREPAYMENT
  5131. /*********************************************************************
  5132. * @fn zclSE_ProcessInPrepaymentCmds
  5133. *
  5134. * @brief Callback from ZCL to process incoming Commands specific
  5135. * to this cluster library on a command ID basis
  5136. *
  5137. * @param pInMsg - pointer to the incoming message
  5138. * @param pCBs - pointer to the application call back function
  5139. *
  5140. * @return ZStatus_t
  5141. */
  5142. static ZStatus_t zclSE_ProcessInPrepaymentCmds( zclIncoming_t *pInMsg,
  5143. zclSE_AppCallbacks_t *pCBs )
  5144. {
  5145. ZStatus_t stat;
  5146. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  5147. {
  5148. // Process Client commands, received by server
  5149. switch ( pInMsg->hdr.commandID )
  5150. {
  5151. case COMMAND_SE_SEL_AVAIL_EMERGENCY_CREDIT:
  5152. stat = zclSE_ProcessInCmd_Prepayment_SelAvailEmergencyCredit( pInMsg, pCBs );
  5153. break;
  5154. #ifndef SE_UK_EXT // this is SE 1.1 command definition
  5155. case COMMAND_SE_CHANGE_SUPPLY:
  5156. stat = zclSE_ProcessInCmd_Prepayment_ChangeSupply( pInMsg, pCBs );
  5157. break;
  5158. #else
  5159. case COMMAND_SE_CHANGE_DEBT:
  5160. stat = zclSE_ProcessInCmd_Prepayment_ChangeDebt( pInMsg, pCBs );
  5161. break;
  5162. case COMMAND_SE_EMERGENCY_CREDIT_SETUP:
  5163. stat = zclSE_ProcessInCmd_Prepayment_EmergencyCreditSetup( pInMsg, pCBs );
  5164. break;
  5165. case COMMAND_SE_CONSUMER_TOPUP:
  5166. stat = zclSE_ProcessInCmd_Prepayment_ConsumerTopup( pInMsg, pCBs );
  5167. break;
  5168. case COMMAND_SE_CREDIT_ADJUSTMENT:
  5169. stat = zclSE_ProcessInCmd_Prepayment_CreditAdjustment( pInMsg, pCBs );
  5170. break;
  5171. case COMMAND_SE_CHANGE_PAYMENT_MODE:
  5172. stat = zclSE_ProcessInCmd_Prepayment_ChangePaymentMode( pInMsg, pCBs );
  5173. break;
  5174. case COMMAND_SE_GET_PREPAY_SNAPSHOT:
  5175. stat = zclSE_ProcessInCmd_Prepayment_GetPrepaySnapshot( pInMsg, pCBs );
  5176. break;
  5177. case COMMAND_SE_GET_TOPUP_LOG:
  5178. stat = zclSE_ProcessInCmd_Prepayment_GetTopupLog( pInMsg, pCBs );
  5179. break;
  5180. case COMMAND_SE_SET_LOW_CREDIT_WARNING_LEVEL:
  5181. stat = zclSE_ProcessInCmd_Prepayment_SetLowCreditWarningLevel( pInMsg, pCBs );
  5182. break;
  5183. case COMMAND_SE_GET_DEBT_REPAYMENT_LOG:
  5184. stat = zclSE_ProcessInCmd_Prepayment_GetDebtRepaymentLog( pInMsg, pCBs );
  5185. break;
  5186. #endif // SE_UK_EXT
  5187. default:
  5188. stat = ZFailure;
  5189. break;
  5190. }
  5191. }
  5192. else
  5193. {
  5194. // Process Server commands, received by client
  5195. switch ( pInMsg->hdr.commandID )
  5196. {
  5197. #ifndef SE_UK_EXT // this is SE 1.1 command definition
  5198. case COMMAND_SE_SUPPLY_STATUS_RESPONSE:
  5199. stat = zclSE_ProcessInCmd_Prepayment_SupplyStatusResponse( pInMsg, pCBs );
  5200. break;
  5201. #else // SE_UK_EXT
  5202. case COMMAND_SE_GET_PREPAY_SNAPSHOT_RESPONSE:
  5203. stat = zclSE_ProcessInCmd_Prepayment_GetPrepaySnapshotResponse( pInMsg, pCBs );
  5204. break;
  5205. case COMMAND_SE_CHANGE_PAYMENT_MODE_RESPONSE:
  5206. stat = zclSE_ProcessInCmd_Prepayment_ChangePaymentModeResponse( pInMsg, pCBs );
  5207. break;
  5208. case COMMAND_SE_CONSUMER_TOPUP_RESPONSE:
  5209. stat = zclSE_ProcessInCmd_Prepayment_ConsumerTopupResponse( pInMsg, pCBs );
  5210. break;
  5211. case COMMAND_SE_GET_COMMANDS:
  5212. stat = zclSE_ProcessInCmd_Prepayment_GetCommands( pInMsg, pCBs );
  5213. break;
  5214. case COMMAND_SE_PUBLISH_TOPUP_LOG:
  5215. stat = zclSE_ProcessInCmd_Prepayment_PublishTopupLog( pInMsg, pCBs );
  5216. break;
  5217. case COMMAND_SE_PUBLISH_DEBT_LOG:
  5218. stat = zclSE_ProcessInCmd_Prepayment_PublishDebtLog( pInMsg, pCBs );
  5219. break;
  5220. #endif // SE_UK_EXT
  5221. default:
  5222. stat = ZFailure;
  5223. break;
  5224. }
  5225. }
  5226. return ( stat );
  5227. }
  5228. /*********************************************************************
  5229. * @fn zclSE_ProcessInCmd_Prepayment_SelAvailEmergencyCredit
  5230. *
  5231. * @brief Process in the received Select Available Emergency Credit
  5232. *
  5233. * @param pInMsg - pointer to the incoming message
  5234. * @param pCBs - pointer to the application call back function
  5235. *
  5236. * @return ZStatus_t - ZFailure @ Unsupported
  5237. * ZSuccess @ Supported and send default rsp
  5238. */
  5239. static ZStatus_t zclSE_ProcessInCmd_Prepayment_SelAvailEmergencyCredit( zclIncoming_t *pInMsg,
  5240. zclSE_AppCallbacks_t *pCBs )
  5241. {
  5242. if ( pCBs->pfnPrepayment_SelAvailEmergencyCredit )
  5243. {
  5244. zclCCSelAvailEmergencyCredit_t cmd;
  5245. zclSE_ParseInCmd_SelAvailEmergencyCredit( &cmd, &(pInMsg->pData[0]),
  5246. pInMsg->pDataLen );
  5247. // Callback to process message
  5248. pCBs->pfnPrepayment_SelAvailEmergencyCredit( &cmd, &(pInMsg->msg->srcAddr),
  5249. pInMsg->hdr.transSeqNum );
  5250. return ZSuccess;
  5251. }
  5252. return ZFailure;
  5253. }
  5254. #ifndef SE_UK_EXT
  5255. /*********************************************************************
  5256. * @fn zclSE_ProcessInCmd_Prepayment_ChangeSupply
  5257. *
  5258. * @brief Process in the received Change Supply
  5259. *
  5260. * @param pInMsg - pointer to the incoming message
  5261. * @param pCBs - pointer to the application call back function
  5262. *
  5263. * @return ZStatus_t - ZFailure @ Unsupported
  5264. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  5265. * not need default rsp
  5266. */
  5267. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ChangeSupply( zclIncoming_t *pInMsg,
  5268. zclSE_AppCallbacks_t *pCBs )
  5269. {
  5270. if ( pCBs->pfnPrepayment_ChangeSupply )
  5271. {
  5272. zclCCChangeSupply_t cmd;
  5273. zclSE_ParseInCmd_ChangeSupply( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  5274. // Callback to process message
  5275. pCBs->pfnPrepayment_ChangeSupply( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  5276. return ZCL_STATUS_CMD_HAS_RSP;
  5277. }
  5278. return ZFailure;
  5279. }
  5280. /*********************************************************************
  5281. * @fn zclSE_ProcessInCmd_Prepayment_SupplyStatusResponse
  5282. *
  5283. * @brief Process in the received Supply Status Response
  5284. *
  5285. * @param pInMsg - pointer to the incoming message
  5286. * @param pCBs - pointer to the application call back function
  5287. *
  5288. * @return ZStatus_t - ZFailure @ Unsupported
  5289. * ZSuccess @ Supported and send default rsp
  5290. */
  5291. static ZStatus_t zclSE_ProcessInCmd_Prepayment_SupplyStatusResponse( zclIncoming_t *pInMsg,
  5292. zclSE_AppCallbacks_t *pCBs )
  5293. {
  5294. if ( pCBs->pfnPrepayment_SupplyStatusResponse )
  5295. {
  5296. zclCCSupplyStatusResponse_t cmd;
  5297. cmd.providerId = osal_build_uint32( pInMsg->pData, 4);
  5298. cmd.implementationDateTime = osal_build_uint32( &pInMsg->pData[4], 4);
  5299. cmd.supplyStatus = pInMsg->pData[8];
  5300. pCBs->pfnPrepayment_SupplyStatusResponse( &cmd, &(pInMsg->msg->srcAddr),
  5301. pInMsg->hdr.transSeqNum );
  5302. return ZSuccess;
  5303. }
  5304. return ZFailure;
  5305. }
  5306. #else // SE_UK_EXT
  5307. /*********************************************************************
  5308. * @fn zclSE_ProcessInCmd_Prepayment_ChangeDebt
  5309. *
  5310. * @brief Process in the received Change Debt
  5311. *
  5312. * @param pInMsg - pointer to the incoming message
  5313. * @param pCBs - pointer to the application call back function
  5314. *
  5315. * @return ZStatus_t - ZFailure @ Unsupported
  5316. * ZSuccess @ Supported and send default rsp
  5317. */
  5318. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ChangeDebt( zclIncoming_t *pInMsg,
  5319. zclSE_AppCallbacks_t *pCBs )
  5320. {
  5321. if ( pCBs->pfnPrepayment_ChangeDebt )
  5322. {
  5323. zclCCChangeDebt_t cmd;
  5324. zclSE_ParseInCmd_ChangeDebt( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  5325. pCBs->pfnPrepayment_ChangeDebt( &cmd, &(pInMsg->msg->srcAddr),
  5326. pInMsg->hdr.transSeqNum );
  5327. return ZSuccess;
  5328. }
  5329. return ZFailure;
  5330. }
  5331. /*********************************************************************
  5332. * @fn zclSE_ProcessInCmd_Prepayment_EmergencyCreditSetup
  5333. *
  5334. * @brief Process in the received Emergency Credit Setup
  5335. *
  5336. * @param pInMsg - pointer to the incoming message
  5337. * @param pCBs - pointer to the application call back function
  5338. *
  5339. * @return ZStatus_t - ZFailure @ Unsupported
  5340. * ZSuccess @ Supported and send default rsp
  5341. */
  5342. static ZStatus_t zclSE_ProcessInCmd_Prepayment_EmergencyCreditSetup( zclIncoming_t *pInMsg,
  5343. zclSE_AppCallbacks_t *pCBs )
  5344. {
  5345. if ( pCBs->pfnPrepayment_EmergencyCreditSetup )
  5346. {
  5347. zclCCEmergencyCreditSetup_t cmd;
  5348. zclSE_ParseInCmd_EmergencyCreditSetup( &cmd, &(pInMsg->pData[0]),
  5349. pInMsg->pDataLen );
  5350. pCBs->pfnPrepayment_EmergencyCreditSetup( &cmd, &(pInMsg->msg->srcAddr),
  5351. pInMsg->hdr.transSeqNum );
  5352. return ZSuccess;
  5353. }
  5354. return ZFailure;
  5355. }
  5356. /*********************************************************************
  5357. * @fn zclSE_ProcessInCmd_Prepayment_ConsumerTopup
  5358. *
  5359. * @brief Process in the received Consumer Topup
  5360. *
  5361. * @param pInMsg - pointer to the incoming message
  5362. * @param pCBs - pointer to the application call back function
  5363. *
  5364. * @return ZStatus_t - ZFailure @ Unsupported
  5365. * ZSuccess @ Supported and send default rsp
  5366. */
  5367. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ConsumerTopup( zclIncoming_t *pInMsg,
  5368. zclSE_AppCallbacks_t *pCBs )
  5369. {
  5370. if ( pCBs->pfnPrepayment_ConsumerTopup )
  5371. {
  5372. zclCCConsumerTopup_t cmd;
  5373. zclSE_ParseInCmd_ConsumerTopup( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  5374. pCBs->pfnPrepayment_ConsumerTopup( &cmd, &(pInMsg->msg->srcAddr),
  5375. pInMsg->hdr.transSeqNum );
  5376. return ZSuccess;
  5377. }
  5378. return ZFailure;
  5379. }
  5380. /*********************************************************************
  5381. * @fn zclSE_ProcessInCmd_Prepayment_CreditAdjustment
  5382. *
  5383. * @brief Process in the received Credit Adjustment
  5384. *
  5385. * @param pInMsg - pointer to the incoming message
  5386. * @param pCBs - pointer to the application call back function
  5387. *
  5388. * @return ZStatus_t - ZFailure @ Unsupported
  5389. * ZSuccess @ Supported and send default rsp
  5390. */
  5391. static ZStatus_t zclSE_ProcessInCmd_Prepayment_CreditAdjustment( zclIncoming_t *pInMsg,
  5392. zclSE_AppCallbacks_t *pCBs )
  5393. {
  5394. if ( pCBs->pfnPrepayment_CreditAdjustment )
  5395. {
  5396. zclCCCreditAdjustment_t cmd;
  5397. zclSE_ParseInCmd_CreditAdjustment( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  5398. pCBs->pfnPrepayment_CreditAdjustment( &cmd, &(pInMsg->msg->srcAddr),
  5399. pInMsg->hdr.transSeqNum );
  5400. return ZSuccess;
  5401. }
  5402. return ZFailure;
  5403. }
  5404. /*********************************************************************
  5405. * @fn zclSE_ProcessInCmd_Prepayment_ChangePaymentMode
  5406. *
  5407. * @brief Process in the received Change Payment Mode
  5408. *
  5409. * @param pInMsg - pointer to the incoming message
  5410. * @param pCBs - pointer to the application call back function
  5411. *
  5412. * @return ZStatus_t - ZFailure @ Unsupported
  5413. * ZSuccess @ Supported and send default rsp
  5414. */
  5415. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ChangePaymentMode( zclIncoming_t *pInMsg,
  5416. zclSE_AppCallbacks_t *pCBs )
  5417. {
  5418. if ( pCBs->pfnPrepayment_ChangePaymentMode )
  5419. {
  5420. zclCCChangePaymentMode_t cmd;
  5421. zclSE_ParseInCmd_ChangePaymentMode( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  5422. pCBs->pfnPrepayment_ChangePaymentMode( &cmd, &(pInMsg->msg->srcAddr),
  5423. pInMsg->hdr.transSeqNum );
  5424. return ZSuccess;
  5425. }
  5426. return ZFailure;
  5427. }
  5428. /*********************************************************************
  5429. * @fn zclSE_ProcessInCmd_Prepayment_GetPrepaySnapshot
  5430. *
  5431. * @brief Process in the received Get Prepay Snapshot
  5432. *
  5433. * @param pInMsg - pointer to the incoming message
  5434. * @param pCBs - pointer to the application call back function
  5435. *
  5436. * @return ZStatus_t - ZFailure @ Unsupported
  5437. * ZSuccess @ Supported and send default rsp
  5438. */
  5439. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetPrepaySnapshot( zclIncoming_t *pInMsg,
  5440. zclSE_AppCallbacks_t *pCBs )
  5441. {
  5442. if ( pCBs->pfnPrepayment_GetPrepaySnapshot )
  5443. {
  5444. zclCCGetPrepaySnapshot_t cmd;
  5445. zclSE_ParseInCmd_GetPrepaySnapshot( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  5446. pCBs->pfnPrepayment_GetPrepaySnapshot( &cmd, &(pInMsg->msg->srcAddr),
  5447. pInMsg->hdr.transSeqNum );
  5448. return ZSuccess;
  5449. }
  5450. return ZFailure;
  5451. }
  5452. /*********************************************************************
  5453. * @fn zclSE_ProcessInCmd_Prepayment_GetTopupLog
  5454. *
  5455. * @brief Process in the received Get Topup Log
  5456. *
  5457. * @param pInMsg - pointer to the incoming message
  5458. * @param pCBs - pointer to the application call back function
  5459. *
  5460. * @return ZStatus_t - ZFailure @ Unsupported
  5461. * ZSuccess @ Supported and send default rsp
  5462. */
  5463. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetTopupLog( zclIncoming_t *pInMsg,
  5464. zclSE_AppCallbacks_t *pCBs )
  5465. {
  5466. if ( pCBs->pfnPrepayment_GetTopupLog )
  5467. {
  5468. pCBs->pfnPrepayment_GetTopupLog( pInMsg->pData[0], &(pInMsg->msg->srcAddr),
  5469. pInMsg->hdr.transSeqNum );
  5470. return ZSuccess;
  5471. }
  5472. return ZFailure;
  5473. }
  5474. /*********************************************************************
  5475. * @fn zclSE_ProcessInCmd_Prepayment_SetLowCreditWarningLevel
  5476. *
  5477. * @brief Process in the received Set Low Credit Warning Level
  5478. *
  5479. * @param pInMsg - pointer to the incoming message
  5480. * @param pCBs - pointer to the application call back function
  5481. *
  5482. * @return ZStatus_t - ZFailure @ Unsupported
  5483. * ZSuccess @ Supported and send default rsp
  5484. */
  5485. static ZStatus_t zclSE_ProcessInCmd_Prepayment_SetLowCreditWarningLevel( zclIncoming_t *pInMsg,
  5486. zclSE_AppCallbacks_t *pCBs )
  5487. {
  5488. if ( pCBs->pfnPrepayment_SetLowCreditWarningLevel )
  5489. {
  5490. pCBs->pfnPrepayment_SetLowCreditWarningLevel( pInMsg->pData[0],
  5491. &(pInMsg->msg->srcAddr),
  5492. pInMsg->hdr.transSeqNum );
  5493. return ZSuccess;
  5494. }
  5495. return ZFailure;
  5496. }
  5497. /*********************************************************************
  5498. * @fn zclSE_ProcessInCmd_Prepayment_GetDebtRepaymentLog
  5499. *
  5500. * @brief Process in the received Get Debt Repayment Log
  5501. *
  5502. * @param pInMsg - pointer to the incoming message
  5503. * @param pCBs - pointer to the application call back function
  5504. *
  5505. * @return ZStatus_t - ZFailure @ Unsupported
  5506. * ZSuccess @ Supported and send default rsp
  5507. */
  5508. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetDebtRepaymentLog( zclIncoming_t *pInMsg,
  5509. zclSE_AppCallbacks_t *pCBs )
  5510. {
  5511. if ( pCBs->pfnPrepayment_GetDebtRepaymentLog )
  5512. {
  5513. zclCCGetDebtRepaymentLog_t cmd;
  5514. zclSE_ParseInCmd_GetDebtRepaymentLog( &cmd, &(pInMsg->pData[0]),
  5515. pInMsg->pDataLen );
  5516. pCBs->pfnPrepayment_GetDebtRepaymentLog( &cmd, &(pInMsg->msg->srcAddr),
  5517. pInMsg->hdr.transSeqNum );
  5518. return ZSuccess;
  5519. }
  5520. return ZFailure;
  5521. }
  5522. /*********************************************************************
  5523. * @fn zclSE_ProcessInCmd_Prepayment_GetPrepaySnapshotResponse
  5524. *
  5525. * @brief Process in the received Get Prepay Snapshot Response
  5526. *
  5527. * @param pInMsg - pointer to the incoming message
  5528. * @param pCBs - pointer to the application call back function
  5529. *
  5530. * @return ZStatus_t - ZFailure @ Unsupported
  5531. * ZSuccess @ Supported and send default rsp
  5532. */
  5533. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetPrepaySnapshotResponse( zclIncoming_t *pInMsg,
  5534. zclSE_AppCallbacks_t *pCBs )
  5535. {
  5536. if ( pCBs->pfnPrepayment_GetPrepaySnapshotResponse )
  5537. {
  5538. zclCCGetPrepaySnapshotResponse_t cmd;
  5539. zclSE_ParseInCmd_GetPrepaySnapshotResponse( &cmd, &(pInMsg->pData[0]),
  5540. pInMsg->pDataLen );
  5541. pCBs->pfnPrepayment_GetPrepaySnapshotResponse( &cmd, &(pInMsg->msg->srcAddr),
  5542. pInMsg->hdr.transSeqNum );
  5543. return ZSuccess;
  5544. }
  5545. return ZFailure;
  5546. }
  5547. /*********************************************************************
  5548. * @fn zclSE_ProcessInCmd_Prepayment_ChangePaymentModeResponse
  5549. *
  5550. * @brief Process in the received Change Payment Mode Response
  5551. *
  5552. * @param pInMsg - pointer to the incoming message
  5553. * @param pCBs - pointer to the application call back function
  5554. *
  5555. * @return ZStatus_t - ZFailure @ Unsupported
  5556. * ZSuccess @ Supported and send default rsp
  5557. */
  5558. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ChangePaymentModeResponse( zclIncoming_t *pInMsg,
  5559. zclSE_AppCallbacks_t *pCBs )
  5560. {
  5561. if ( pCBs->pfnPrepayment_ChangePaymentModeResponse )
  5562. {
  5563. zclCCChangePaymentModeResponse_t cmd;
  5564. zclSE_ParseInCmd_ChangePaymentModeResponse( &cmd, &(pInMsg->pData[0]),
  5565. pInMsg->pDataLen );
  5566. pCBs->pfnPrepayment_ChangePaymentModeResponse( &cmd, &(pInMsg->msg->srcAddr),
  5567. pInMsg->hdr.transSeqNum );
  5568. return ZSuccess;
  5569. }
  5570. return ZFailure;
  5571. }
  5572. /*********************************************************************
  5573. * @fn zclSE_ProcessInCmd_Prepayment_ConsumerTopupResponse
  5574. *
  5575. * @brief Process in the received Consumer Topup Response
  5576. *
  5577. * @param pInMsg - pointer to the incoming message
  5578. * @param pCBs - pointer to the application call back function
  5579. *
  5580. * @return ZStatus_t - ZFailure @ Unsupported
  5581. * ZSuccess @ Supported and send default rsp
  5582. */
  5583. static ZStatus_t zclSE_ProcessInCmd_Prepayment_ConsumerTopupResponse( zclIncoming_t *pInMsg,
  5584. zclSE_AppCallbacks_t *pCBs )
  5585. {
  5586. if ( pCBs->pfnPrepayment_ConsumerTopupResponse )
  5587. {
  5588. zclCCConsumerTopupResponse_t cmd;
  5589. zclSE_ParseInCmd_ConsumerTopupResponse( &cmd, &(pInMsg->pData[0]),
  5590. pInMsg->pDataLen );
  5591. pCBs->pfnPrepayment_ConsumerTopupResponse( &cmd, &(pInMsg->msg->srcAddr),
  5592. pInMsg->hdr.transSeqNum );
  5593. return ZSuccess;
  5594. }
  5595. return ZFailure;
  5596. }
  5597. /*********************************************************************
  5598. * @fn zclSE_ProcessInCmd_Prepayment_GetCommands
  5599. *
  5600. * @brief Process in the received Get Commands
  5601. *
  5602. * @param pInMsg - pointer to the incoming message
  5603. * @param pCBs - pointer to the application call back function
  5604. *
  5605. * @return ZStatus_t - ZFailure @ Unsupported
  5606. * ZSuccess @ Supported and send default rsp
  5607. */
  5608. static ZStatus_t zclSE_ProcessInCmd_Prepayment_GetCommands( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  5609. {
  5610. if ( pCBs->pfnPrepayment_GetCommands )
  5611. {
  5612. pCBs->pfnPrepayment_GetCommands( pInMsg->pData[0], &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  5613. return ZSuccess;
  5614. }
  5615. return ZFailure;
  5616. }
  5617. /*********************************************************************
  5618. * @fn zclSE_ProcessInCmd_Prepayment_PublishTopupLog
  5619. *
  5620. * @brief Process in the received Publish Topup Log
  5621. *
  5622. * @param pInMsg - pointer to the incoming message
  5623. * @param pCBs - pointer to the application call back function
  5624. *
  5625. * @return ZStatus_t - ZFailure @ Unsupported
  5626. * ZSuccess @ Supported and send default rsp
  5627. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  5628. */
  5629. static ZStatus_t zclSE_ProcessInCmd_Prepayment_PublishTopupLog( zclIncoming_t *pInMsg,
  5630. zclSE_AppCallbacks_t *pCBs )
  5631. {
  5632. if ( pCBs->pfnPrepayment_PublishTopupLog )
  5633. {
  5634. zclCCPublishTopupLog_t cmd;
  5635. if ( zclSE_ParseInCmd_PublishTopupLog( &cmd, &(pInMsg->pData[0]),
  5636. pInMsg->pDataLen ) == ZSuccess )
  5637. {
  5638. pCBs->pfnPrepayment_PublishTopupLog( &cmd, &(pInMsg->msg->srcAddr),
  5639. pInMsg->hdr.transSeqNum );
  5640. // Free memory
  5641. if ( cmd.pPayload != NULL )
  5642. {
  5643. osal_mem_free( cmd.pPayload );
  5644. }
  5645. return ZSuccess;
  5646. }
  5647. else
  5648. {
  5649. return ZCL_STATUS_SOFTWARE_FAILURE;
  5650. }
  5651. }
  5652. return ZFailure;
  5653. }
  5654. /*********************************************************************
  5655. * @fn zclSE_ProcessInCmd_Prepayment_PublishDebtLog
  5656. *
  5657. * @brief Process in the received Publish Debt Log
  5658. *
  5659. * @param pInMsg - pointer to the incoming message
  5660. * @param pCBs - pointer to the application call back function
  5661. *
  5662. * @return ZStatus_t - ZFailure @ Unsupported
  5663. * ZSuccess @ Supported and send default rsp
  5664. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  5665. */
  5666. static ZStatus_t zclSE_ProcessInCmd_Prepayment_PublishDebtLog( zclIncoming_t *pInMsg,
  5667. zclSE_AppCallbacks_t *pCBs )
  5668. {
  5669. if ( pCBs->pfnPrepayment_PublishDebtLog )
  5670. {
  5671. zclCCPublishDebtLog_t cmd;
  5672. if ( zclSE_ParseInCmd_PublishDebtLog( &cmd, &(pInMsg->pData[0]),
  5673. pInMsg->pDataLen ) == ZSuccess )
  5674. {
  5675. pCBs->pfnPrepayment_PublishDebtLog( &cmd, &(pInMsg->msg->srcAddr),
  5676. pInMsg->hdr.transSeqNum );
  5677. // Free memory
  5678. if ( cmd.pPayload != NULL )
  5679. {
  5680. osal_mem_free( cmd.pPayload );
  5681. }
  5682. return ZSuccess;
  5683. }
  5684. else
  5685. {
  5686. return ZCL_STATUS_SOFTWARE_FAILURE;
  5687. }
  5688. }
  5689. return ZFailure;
  5690. }
  5691. #endif // SE_UK_EXT
  5692. #endif // ZCL_PREPAYMENT
  5693. #ifdef ZCL_TUNNELING
  5694. /*********************************************************************
  5695. * @fn zclSE_ProcessInTunnelingCmds
  5696. *
  5697. * @brief Callback from ZCL to process incoming Commands specific
  5698. * to this cluster library on a command ID basis
  5699. *
  5700. * @param pInMsg - pointer to the incoming message
  5701. * @param pCBs - pointer to the application call back function
  5702. *
  5703. * @return ZStatus_t
  5704. */
  5705. static ZStatus_t zclSE_ProcessInTunnelingCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  5706. {
  5707. ZStatus_t stat;
  5708. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  5709. {
  5710. // Process Client commands, received by Server
  5711. switch ( pInMsg->hdr.commandID )
  5712. {
  5713. case COMMAND_SE_REQUEST_TUNNEL:
  5714. stat = zclSE_ProcessInCmd_Tunneling_RequestTunnel( pInMsg, pCBs );
  5715. break;
  5716. case COMMAND_SE_CLOSE_TUNNEL:
  5717. stat = zclSE_ProcessInCmd_Tunneling_CloseTunnel( pInMsg, pCBs );
  5718. break;
  5719. case COMMAND_SE_DATA_CLIENT_SERVER_DIR:
  5720. stat = zclSE_ProcessInCmd_Tunneling_TransferData( pInMsg, pCBs );
  5721. break;
  5722. case COMMAND_SE_DATA_ERROR_CLIENT_SERVER_DIR:
  5723. stat = zclSE_ProcessInCmd_Tunneling_TransferDataError( pInMsg, pCBs );
  5724. break;
  5725. case COMMAND_SE_ACK_CLIENT_SERVER_DIR:
  5726. stat = zclSE_ProcessInCmd_Tunneling_AckTransferData( pInMsg, pCBs );
  5727. break;
  5728. case COMMAND_SE_READY_DATA_CLIENT_SERVER_DIR:
  5729. stat = zclSE_ProcessInCmd_Tunneling_ReadyData( pInMsg, pCBs );
  5730. break;
  5731. #ifdef SE_UK_EXT
  5732. case COMMAND_SE_GET_SUPP_TUNNEL_PROTOCOLS:
  5733. stat = zclSE_ProcessInCmd_Tunneling_GetSuppTunnelProt( pInMsg, pCBs );
  5734. break;
  5735. #endif //SE_UK_EXT
  5736. default:
  5737. stat = ZFailure;
  5738. break;
  5739. }
  5740. }
  5741. else
  5742. {
  5743. // Process Server commands, received by Client
  5744. switch ( pInMsg->hdr.commandID )
  5745. {
  5746. case COMMAND_SE_REQUEST_TUNNEL_RESPONSE:
  5747. stat = zclSE_ProcessInCmd_Tunneling_ReqTunnelRsp( pInMsg, pCBs );
  5748. break;
  5749. case COMMAND_SE_DATA_SERVER_CLIENT_DIR:
  5750. stat = zclSE_ProcessInCmd_Tunneling_TransferData( pInMsg, pCBs );
  5751. break;
  5752. case COMMAND_SE_DATA_ERROR_SERVER_CLIENT_DIR:
  5753. stat = zclSE_ProcessInCmd_Tunneling_TransferDataError( pInMsg, pCBs );
  5754. break;
  5755. case COMMAND_SE_ACK_SERVER_CLIENT_DIR:
  5756. stat = zclSE_ProcessInCmd_Tunneling_AckTransferData( pInMsg, pCBs );
  5757. break;
  5758. case COMMAND_SE_READY_DATA_SERVER_CLIENT_DIR:
  5759. stat = zclSE_ProcessInCmd_Tunneling_ReadyData( pInMsg, pCBs );
  5760. break;
  5761. #ifdef SE_UK_EXT
  5762. case COMMAND_SE_SUPP_TUNNEL_PROTOCOLS_RSP:
  5763. stat = zclSE_ProcessInCmd_Tunneling_SuppTunnelProtRsp( pInMsg, pCBs );
  5764. break;
  5765. case COMMAND_SE_TUNNEL_CLOSURE_NOTIFICATION:
  5766. stat = zclSE_ProcessInCmd_Tunneling_TunnelClosureNotification( pInMsg, pCBs );
  5767. break;
  5768. #endif // SE_UK_EXT
  5769. default:
  5770. stat = ZFailure;
  5771. break;
  5772. }
  5773. }
  5774. return ( stat );
  5775. }
  5776. /*********************************************************************
  5777. * @fn zclSE_ProcessInCmd_Tunneling_RequestTunnel
  5778. *
  5779. * @brief process in the received tunnel request
  5780. *
  5781. * @param pInMsg - pointer to the incoming message
  5782. * @param pCBs - pointer to the application call back function
  5783. *
  5784. * @return ZStatus_t - ZFailure @ Unsupported
  5785. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  5786. * not need default rsp
  5787. */
  5788. static ZStatus_t zclSE_ProcessInCmd_Tunneling_RequestTunnel( zclIncoming_t *pInMsg,
  5789. zclSE_AppCallbacks_t *pCBs )
  5790. {
  5791. if ( pCBs->pfnTunneling_RequestTunnel )
  5792. {
  5793. zclCCRequestTunnel_t cmd;
  5794. cmd.protocolId = pInMsg->pData[0];
  5795. cmd.manufacturerCode = BUILD_UINT16( pInMsg->pData[1], pInMsg->pData[2] );
  5796. cmd.flowControlSupport = pInMsg->pData[3];
  5797. cmd.maxInTransferSize = BUILD_UINT16( pInMsg->pData[4], pInMsg->pData[5] );
  5798. pCBs->pfnTunneling_RequestTunnel( &cmd, &(pInMsg->msg->srcAddr),
  5799. pInMsg->hdr.transSeqNum );
  5800. return ZCL_STATUS_CMD_HAS_RSP;
  5801. }
  5802. return ZFailure;
  5803. }
  5804. /*********************************************************************
  5805. * @fn zclSE_ProcessInCmd_Tunneling_ReqTunnelRsp
  5806. *
  5807. * @brief process in the received tunnel response
  5808. *
  5809. * @param pInMsg - pointer to the incoming message
  5810. * @param pCBs - pointer to the application call back function
  5811. *
  5812. * @return ZStatus_t - ZFailure @ Unsupported
  5813. * ZSuccess @ Supported and send default rsp
  5814. */
  5815. static ZStatus_t zclSE_ProcessInCmd_Tunneling_ReqTunnelRsp( zclIncoming_t *pInMsg,
  5816. zclSE_AppCallbacks_t *pCBs )
  5817. {
  5818. if ( pCBs->pfnTunneling_ReqTunnelRsp )
  5819. {
  5820. zclCCReqTunnelRsp_t cmd;
  5821. cmd.tunnelId = BUILD_UINT16( pInMsg->pData[0], pInMsg->pData[1] );
  5822. cmd.tunnelStatus = pInMsg->pData[2];
  5823. cmd.maxInTransferSize = BUILD_UINT16( pInMsg->pData[3], pInMsg->pData[4] );
  5824. pCBs->pfnTunneling_ReqTunnelRsp( &cmd, &(pInMsg->msg->srcAddr),
  5825. pInMsg->hdr.transSeqNum );
  5826. return ZSuccess;
  5827. }
  5828. return ZFailure;
  5829. }
  5830. /*********************************************************************
  5831. * @fn zclSE_ProcessInCmd_Tunneling_CloseTunnel
  5832. *
  5833. * @brief process in the received tunnel close
  5834. *
  5835. * @param pInMsg - pointer to the incoming message
  5836. * @param pCBs - pointer to the application call back function
  5837. *
  5838. * @return ZStatus_t - ZFailure @ Unsupported
  5839. * ZSuccess @ Supported and send default rsp
  5840. */
  5841. static ZStatus_t zclSE_ProcessInCmd_Tunneling_CloseTunnel( zclIncoming_t *pInMsg,
  5842. zclSE_AppCallbacks_t *pCBs )
  5843. {
  5844. if ( pCBs->pfnTunneling_CloseTunnel )
  5845. {
  5846. zclCCCloseTunnel_t cmd;
  5847. cmd.tunnelId = BUILD_UINT16( pInMsg->pData[0], pInMsg->pData[1] );
  5848. pCBs->pfnTunneling_CloseTunnel( &cmd, &(pInMsg->msg->srcAddr),
  5849. pInMsg->hdr.transSeqNum );
  5850. return ZSuccess;
  5851. }
  5852. return ZFailure;
  5853. }
  5854. /*********************************************************************
  5855. * @fn zclSE_ProcessInCmd_Tunneling_TransferData
  5856. *
  5857. * @brief process in the received tunnel transfer data
  5858. *
  5859. * @param pInMsg - pointer to the incoming message
  5860. * @param pCBs - pointer to the application call back function
  5861. *
  5862. * @return ZStatus_t - ZFailure @ Unsupported
  5863. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  5864. * not need default rsp
  5865. */
  5866. static ZStatus_t zclSE_ProcessInCmd_Tunneling_TransferData( zclIncoming_t *pInMsg,
  5867. zclSE_AppCallbacks_t *pCBs )
  5868. {
  5869. if ( pCBs->pfnTunneling_TransferData )
  5870. {
  5871. zclCCTransferData_t cmd;
  5872. uint16 dataLen = pInMsg->pDataLen - PACKET_LEN_SE_TUNNELING_TRANSFER_DATA;
  5873. zclSE_ParseInCmd_TransferData( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  5874. pCBs->pfnTunneling_TransferData( &cmd, &(pInMsg->msg->srcAddr),
  5875. pInMsg->hdr.commandID, dataLen,
  5876. pInMsg->hdr.transSeqNum );
  5877. return ZCL_STATUS_CMD_HAS_RSP;
  5878. }
  5879. return ZFailure;
  5880. }
  5881. /*********************************************************************
  5882. * @fn zclSE_ProcessInCmd_Tunneling_TransferDataError
  5883. *
  5884. * @brief process in the transfer data error
  5885. *
  5886. * @param pInMsg - pointer to the incoming message
  5887. * @param pCBs - pointer to the application call back function
  5888. *
  5889. * @return ZStatus_t - ZFailure @ Unsupported
  5890. * ZSuccess @ Supported and send default rsp
  5891. */
  5892. static ZStatus_t zclSE_ProcessInCmd_Tunneling_TransferDataError( zclIncoming_t *pInMsg,
  5893. zclSE_AppCallbacks_t *pCBs )
  5894. {
  5895. if ( pCBs->pfnTunneling_TransferDataError )
  5896. {
  5897. zclCCTransferDataError_t cmd;
  5898. cmd.tunnelId = BUILD_UINT16( pInMsg->pData[0], pInMsg->pData[1] );
  5899. cmd.transferDataStatus = pInMsg->pData[2];
  5900. pCBs->pfnTunneling_TransferDataError( &cmd, &(pInMsg->msg->srcAddr),
  5901. pInMsg->hdr.transSeqNum );
  5902. return ZSuccess;
  5903. }
  5904. return ZFailure;
  5905. }
  5906. /*********************************************************************
  5907. * @fn zclSE_ProcessInCmd_Tunneling_AckTransferData
  5908. *
  5909. * @brief Process in the received Ack Transfer Data
  5910. *
  5911. * @param pInMsg - pointer to the incoming message
  5912. * @param pCBs - pointer to the application call back function
  5913. *
  5914. * @return ZStatus_t - ZFailure @ Unsupported
  5915. * ZSuccess @ Supported and send default rsp
  5916. */
  5917. static ZStatus_t zclSE_ProcessInCmd_Tunneling_AckTransferData( zclIncoming_t *pInMsg,
  5918. zclSE_AppCallbacks_t *pCBs )
  5919. {
  5920. if ( pCBs->pfnTunneling_AckTransferData )
  5921. {
  5922. zclCCAckTransferData_t cmd;
  5923. cmd.tunnelId = BUILD_UINT16( pInMsg->pData[0], pInMsg->pData[1] );
  5924. cmd.numberOfBytesLeft = BUILD_UINT16( pInMsg->pData[2], pInMsg->pData[3] );
  5925. pCBs->pfnTunneling_AckTransferData( &cmd, &(pInMsg->msg->srcAddr),
  5926. pInMsg->hdr.commandID,
  5927. pInMsg->hdr.transSeqNum );
  5928. return ZSuccess;
  5929. }
  5930. return ZFailure;
  5931. }
  5932. /*********************************************************************
  5933. * @fn zclSE_ProcessInCmd_Tunneling_ReadyData
  5934. *
  5935. * @brief Process in the received Ready Data
  5936. *
  5937. * @param pInMsg - pointer to the incoming message
  5938. * @param pCBs - pointer to the application call back function
  5939. *
  5940. * @return ZStatus_t - ZFailure @ Unsupported
  5941. * ZSuccess @ Supported and send default rsp
  5942. */
  5943. static ZStatus_t zclSE_ProcessInCmd_Tunneling_ReadyData( zclIncoming_t *pInMsg,
  5944. zclSE_AppCallbacks_t *pCBs )
  5945. {
  5946. if ( pCBs->pfnTunneling_ReadyData )
  5947. {
  5948. zclCCReadyData_t cmd;
  5949. cmd.tunnelId = BUILD_UINT16( pInMsg->pData[0], pInMsg->pData[1] );
  5950. cmd.numberOfOctetsLeft = BUILD_UINT16( pInMsg->pData[2], pInMsg->pData[3] );
  5951. pCBs->pfnTunneling_ReadyData( &cmd, &(pInMsg->msg->srcAddr),
  5952. pInMsg->hdr.commandID,
  5953. pInMsg->hdr.transSeqNum );
  5954. return ZSuccess;
  5955. }
  5956. return ZFailure;
  5957. }
  5958. #ifdef SE_UK_EXT
  5959. /*********************************************************************
  5960. * @fn zclSE_ProcessInCmd_Tunneling_GetSuppTunnelProt
  5961. *
  5962. * @brief Process in the received Get Supported Tunnel Protocols
  5963. *
  5964. * @param pInMsg - pointer to the incoming message
  5965. * @param pCBs - pointer to the application call back function
  5966. *
  5967. * @return ZStatus_t - ZFailure @ Unsupported
  5968. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  5969. * not need default rsp
  5970. */
  5971. static ZStatus_t zclSE_ProcessInCmd_Tunneling_GetSuppTunnelProt( zclIncoming_t *pInMsg,
  5972. zclSE_AppCallbacks_t *pCBs )
  5973. {
  5974. if ( pCBs->pfnTunneling_GetSuppTunnelProt )
  5975. {
  5976. zclCCGetSuppTunnProt_t cmd;
  5977. cmd.protocolOffset = pInMsg->pData[0];
  5978. pCBs->pfnTunneling_GetSuppTunnelProt( &cmd, &(pInMsg->msg->srcAddr),
  5979. pInMsg->hdr.transSeqNum );
  5980. return ZCL_STATUS_CMD_HAS_RSP;
  5981. }
  5982. return ZFailure;
  5983. }
  5984. /*********************************************************************
  5985. * @fn zclSE_ProcessInCmd_Tunneling_SuppTunnelProtRsp
  5986. *
  5987. * @brief Process in the received Supported Tunnel Protocols Response
  5988. *
  5989. * @param pInMsg - pointer to the incoming message
  5990. * @param pCBs - pointer to the application call back function
  5991. *
  5992. * @return ZStatus_t - ZFailure @ Unsupported
  5993. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  5994. * not need default rsp
  5995. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  5996. */
  5997. static ZStatus_t zclSE_ProcessInCmd_Tunneling_SuppTunnelProtRsp( zclIncoming_t *pInMsg,
  5998. zclSE_AppCallbacks_t *pCBs )
  5999. {
  6000. if ( pCBs->pfnTunneling_SuppTunnelProtRsp )
  6001. {
  6002. zclCCSuppTunnProtRsp_t *pCmd;
  6003. uint8 i;
  6004. uint8 *buf;
  6005. pCmd = ( zclCCSuppTunnProtRsp_t * )osal_mem_alloc( sizeof( zclCCSuppTunnProtRsp_t ) +
  6006. (sizeof( zclCCProtocolPayload_t ) * pInMsg->pData[1]) );
  6007. if ( pCmd != NULL )
  6008. {
  6009. buf = &(pInMsg->pData[0]);
  6010. pCmd->protocolListComp = *buf++;
  6011. pCmd->protocolCount = *buf++;
  6012. for ( i = 0; i < pCmd->protocolCount; i++ )
  6013. {
  6014. pCmd->protocol[i].manufacturerCode = BUILD_UINT16( buf[0], buf[1] );
  6015. buf += 2;
  6016. pCmd->protocol[i].protocolId = *buf++;
  6017. }
  6018. pCBs->pfnTunneling_SuppTunnelProtRsp( pCmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  6019. osal_mem_free( pCmd );
  6020. return ZCL_STATUS_CMD_HAS_RSP;
  6021. }
  6022. else
  6023. {
  6024. return ZCL_STATUS_SOFTWARE_FAILURE;
  6025. }
  6026. }
  6027. return ZFailure;
  6028. }
  6029. /*********************************************************************
  6030. * @fn zclSE_ProcessInCmd_Tunneling_TunnelClosureNotification
  6031. *
  6032. * @brief Process in the received Tunnel Closure Notification
  6033. *
  6034. * @param pInMsg - pointer to the incoming message
  6035. * @param pCBs - pointer to the application call back function
  6036. *
  6037. * @return ZStatus_t - ZFailure @ Unsupported
  6038. * ZSuccess @ Supported and send default rsp
  6039. */
  6040. static ZStatus_t zclSE_ProcessInCmd_Tunneling_TunnelClosureNotification( zclIncoming_t *pInMsg,
  6041. zclSE_AppCallbacks_t *pCBs )
  6042. {
  6043. if ( pCBs->pfnTunneling_TunnelClosureNotification )
  6044. {
  6045. zclCCTunnelClosureNotification_t cmd;
  6046. cmd.tunnelId = BUILD_UINT16( pInMsg->pData[0], pInMsg->pData[1] );
  6047. pCBs->pfnTunneling_TunnelClosureNotification( &cmd, &(pInMsg->msg->srcAddr),
  6048. pInMsg->hdr.transSeqNum );
  6049. return ZSuccess;
  6050. }
  6051. return ZFailure;
  6052. }
  6053. #endif // SE_UK_EXT
  6054. #endif // ZCL_TUNNELING
  6055. #ifdef ZCL_TOU
  6056. #ifdef SE_UK_EXT
  6057. /*********************************************************************
  6058. * @fn zclSE_ProcessInTouCmds
  6059. *
  6060. * @brief Callback from ZCL to process incoming Commands specific
  6061. * to this cluster library on a command ID basis
  6062. *
  6063. * @param pInMsg - pointer to the incoming message
  6064. * @param pCBs - pointer to the application call back function
  6065. *
  6066. * @return ZStatus_t
  6067. */
  6068. static ZStatus_t zclSE_ProcessInTouCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  6069. {
  6070. ZStatus_t stat;
  6071. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  6072. {
  6073. // Process Client commands, received by Server
  6074. switch ( pInMsg->hdr.commandID )
  6075. {
  6076. case COMMAND_SE_GET_CALENDAR:
  6077. stat = zclSE_ProcessInCmd_Tou_GetCalendar( pInMsg, pCBs );
  6078. break;
  6079. case COMMAND_SE_GET_DAY_PROFILES:
  6080. stat = zclSE_ProcessInCmd_Tou_GetDayProfiles( pInMsg, pCBs );
  6081. break;
  6082. case COMMAND_SE_GET_WEEK_PROFILES:
  6083. stat = zclSE_ProcessInCmd_Tou_GetWeekProfiles( pInMsg, pCBs );
  6084. break;
  6085. case COMMAND_SE_GET_SEASONS:
  6086. stat = zclSE_ProcessInCmd_Tou_GetSeasons( pInMsg, pCBs );
  6087. break;
  6088. case COMMAND_SE_GET_SPECIAL_DAYS:
  6089. stat = zclSE_ProcessInCmd_Tou_GetSpecialDays( pInMsg, pCBs );
  6090. break;
  6091. default:
  6092. stat = ZFailure;
  6093. break;
  6094. }
  6095. }
  6096. else
  6097. {
  6098. // Process Server commands, received by Client
  6099. switch ( pInMsg->hdr.commandID )
  6100. {
  6101. case COMMAND_SE_PUBLISH_CALENDAR:
  6102. stat = zclSE_ProcessInCmd_Tou_PublishCalendar( pInMsg, pCBs );
  6103. break;
  6104. case COMMAND_SE_PUBLISH_DAY_PROFILE:
  6105. stat = zclSE_ProcessInCmd_Tou_PublishDayProfile( pInMsg, pCBs );
  6106. break;
  6107. case COMMAND_SE_PUBLISH_WEEK_PROFILE:
  6108. stat = zclSE_ProcessInCmd_Tou_PublishWeekProfile( pInMsg, pCBs );
  6109. break;
  6110. case COMMAND_SE_PUBLISH_SEASONS:
  6111. stat = zclSE_ProcessInCmd_Tou_PublishSeasons( pInMsg, pCBs );
  6112. break;
  6113. case COMMAND_SE_PUBLISH_SPECIAL_DAYS:
  6114. stat = zclSE_ProcessInCmd_Tou_PublishSpecialDays( pInMsg, pCBs );
  6115. break;
  6116. default:
  6117. stat = ZFailure;
  6118. break;
  6119. }
  6120. }
  6121. return ( stat );
  6122. }
  6123. /*********************************************************************
  6124. * @fn zclSE_ProcessInCmd_Tou_PublishCalendar
  6125. *
  6126. * @brief process in the received Publish Calendar
  6127. *
  6128. * @param pInMsg - pointer to the incoming message
  6129. * @param pCBs - pointer to the application call back function
  6130. *
  6131. * @return ZStatus_t - ZFailure @ Unsupported
  6132. * ZSuccess @ Supported and need default rsp
  6133. */
  6134. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishCalendar( zclIncoming_t *pInMsg,
  6135. zclSE_AppCallbacks_t *pCBs )
  6136. {
  6137. if ( pCBs->pfnTou_PublishCalendar )
  6138. {
  6139. zclCCPublishCalendar_t cmd;
  6140. zclSE_ParseInCmd_PublishCalendar( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  6141. pCBs->pfnTou_PublishCalendar( &cmd, &(pInMsg->msg->srcAddr),
  6142. pInMsg->hdr.transSeqNum );
  6143. return ZSuccess;
  6144. }
  6145. return ZFailure;
  6146. }
  6147. /*********************************************************************
  6148. * @fn zclSE_ProcessInCmd_Tou_PublishDayProfile
  6149. *
  6150. * @brief process in the received Publish Day Profile
  6151. *
  6152. * @param pInMsg - pointer to the incoming message
  6153. * @param pCBs - pointer to the application call back function
  6154. *
  6155. * @return ZStatus_t - ZFailure @ Unsupported
  6156. * ZSuccess @ Supported and need default rsp
  6157. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  6158. */
  6159. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishDayProfile( zclIncoming_t *pInMsg,
  6160. zclSE_AppCallbacks_t *pCBs )
  6161. {
  6162. if ( pCBs->pfnTou_PublishDayProfile )
  6163. {
  6164. zclCCPublishDayProfile_t cmd;
  6165. if ( zclSE_ParseInCmd_PublishDayProfile( &cmd, &(pInMsg->pData[0]),
  6166. pInMsg->pDataLen ) == ZSuccess )
  6167. {
  6168. pCBs->pfnTou_PublishDayProfile( &cmd, &(pInMsg->msg->srcAddr),
  6169. pInMsg->hdr.transSeqNum );
  6170. // Free the memory allocated in zclSE_ParseInCmd_PublishDayProfile()
  6171. if ( cmd.pScheduleEntries != NULL )
  6172. {
  6173. osal_mem_free( cmd.pScheduleEntries );
  6174. }
  6175. return ZSuccess;
  6176. }
  6177. else
  6178. {
  6179. return ZCL_STATUS_SOFTWARE_FAILURE;
  6180. }
  6181. }
  6182. return ZFailure;
  6183. }
  6184. /*********************************************************************
  6185. * @fn zclSE_ProcessInCmd_Tou_PublishWeekProfile
  6186. *
  6187. * @brief process in the received Publish Week Profile
  6188. *
  6189. * @param pInMsg - pointer to the incoming message
  6190. * @param pCBs - pointer to the application call back function
  6191. *
  6192. * @return ZStatus_t - ZFailure @ Unsupported
  6193. * ZSuccess @ Supported and need default rsp
  6194. */
  6195. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishWeekProfile( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  6196. {
  6197. if ( pCBs->pfnTou_PublishWeekProfile )
  6198. {
  6199. zclCCPublishWeekProfile_t cmd;
  6200. // Parse the command buffer
  6201. cmd.issuerCalendarId = osal_build_uint32( pInMsg->pData, 4 );
  6202. cmd.weekId = pInMsg->pData[4];
  6203. cmd.dayIdRefMonday = pInMsg->pData[5];
  6204. cmd.dayIdRefTuestday = pInMsg->pData[6];
  6205. cmd.dayIdRefWednesday = pInMsg->pData[7];
  6206. cmd.dayIdRefThursday = pInMsg->pData[8];
  6207. cmd.dayIdRefFriday = pInMsg->pData[9];
  6208. cmd.dayIdRefSaturday = pInMsg->pData[10];
  6209. cmd.dayIdRefSunday = pInMsg->pData[11];
  6210. pCBs->pfnTou_PublishWeekProfile( &cmd, &(pInMsg->msg->srcAddr),
  6211. pInMsg->hdr.transSeqNum );
  6212. return ZSuccess;
  6213. }
  6214. return ZFailure;
  6215. }
  6216. /*********************************************************************
  6217. * @fn zclSE_ProcessInCmd_Tou_PublishSeasons
  6218. *
  6219. * @brief process in the received Publish Seasons
  6220. *
  6221. * @param pInMsg - pointer to the incoming message
  6222. * @param pCBs - pointer to the application call back function
  6223. *
  6224. * @return ZStatus_t - ZFailure @ Unsupported
  6225. * ZSuccess @ Supported and need default rsp
  6226. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  6227. */
  6228. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishSeasons( zclIncoming_t *pInMsg,
  6229. zclSE_AppCallbacks_t *pCBs )
  6230. {
  6231. if ( pCBs->pfnTou_PublishSeasons )
  6232. {
  6233. zclCCPublishSeasons_t cmd;
  6234. // Parse the command
  6235. if ( zclSE_ParseInCmd_PublishSeasons( &cmd, &(pInMsg->pData[0]),
  6236. pInMsg->pDataLen ) == ZSuccess )
  6237. {
  6238. pCBs->pfnTou_PublishSeasons( &cmd, &(pInMsg->msg->srcAddr),
  6239. pInMsg->hdr.transSeqNum );
  6240. // Free the memory allocated in zclSE_ParseInCmd_PublishSeasons()
  6241. if ( cmd.pSeasonEntry != NULL )
  6242. {
  6243. osal_mem_free( cmd.pSeasonEntry );
  6244. }
  6245. return ZSuccess;
  6246. }
  6247. else
  6248. {
  6249. return ZCL_STATUS_SOFTWARE_FAILURE;
  6250. }
  6251. }
  6252. return ZFailure;
  6253. }
  6254. /*********************************************************************
  6255. * @fn zclSE_ProcessInCmd_Tou_PublishSpecialDays
  6256. *
  6257. * @brief process in the received Publish Special Days
  6258. *
  6259. * @param pInMsg - pointer to the incoming message
  6260. * @param pCBs - pointer to the application call back function
  6261. *
  6262. * @return ZStatus_t - ZFailure @ Unsupported
  6263. * ZSuccess @ Supported and need default rsp
  6264. * ZCL_STATUS_SOFTWARE_FAILURE @ ZStack memory allocation failure
  6265. */
  6266. static ZStatus_t zclSE_ProcessInCmd_Tou_PublishSpecialDays( zclIncoming_t *pInMsg,
  6267. zclSE_AppCallbacks_t *pCBs )
  6268. {
  6269. if ( pCBs->pfnTou_PublishSpecialDays )
  6270. {
  6271. zclCCPublishSpecialDays_t cmd;
  6272. // Parse the command
  6273. if ( zclSE_ParseInCmd_PublishSpecialDays( &cmd, &(pInMsg->pData[0]),
  6274. pInMsg->pDataLen ) == ZSuccess )
  6275. {
  6276. pCBs->pfnTou_PublishSpecialDays( &cmd, &(pInMsg->msg->srcAddr),
  6277. pInMsg->hdr.transSeqNum );
  6278. // Free the memory allocated in zclSE_ParseInCmd_PublishSpecialDays()
  6279. if ( cmd.pSpecialDayEntry != NULL )
  6280. {
  6281. osal_mem_free( cmd.pSpecialDayEntry );
  6282. }
  6283. return ZSuccess;
  6284. }
  6285. else
  6286. {
  6287. return ZCL_STATUS_SOFTWARE_FAILURE;
  6288. }
  6289. }
  6290. return ZFailure;
  6291. }
  6292. /*********************************************************************
  6293. * @fn zclSE_ProcessInCmd_Tou_GetCalendar
  6294. *
  6295. * @brief process in the received Get Calendar
  6296. *
  6297. * @param pInMsg - pointer to the incoming message
  6298. * @param pCBs - pointer to the application call back function
  6299. *
  6300. * @return ZStatus_t - ZFailure @ Unsupported
  6301. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6302. * not need default rsp
  6303. */
  6304. static ZStatus_t zclSE_ProcessInCmd_Tou_GetCalendar( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  6305. {
  6306. if ( pCBs->pfnTou_GetCalendar )
  6307. {
  6308. zclCCGetCalendar_t cmd;
  6309. // Parse the command buffer
  6310. cmd.startTime = osal_build_uint32( pInMsg->pData, 4 );
  6311. cmd.numOfCalendars = pInMsg->pData[4];
  6312. cmd.calendarType = pInMsg->pData[5];
  6313. pCBs->pfnTou_GetCalendar( &cmd, &(pInMsg->msg->srcAddr),
  6314. pInMsg->hdr.transSeqNum );
  6315. return ZCL_STATUS_CMD_HAS_RSP;
  6316. }
  6317. return ZFailure;
  6318. }
  6319. /*********************************************************************
  6320. * @fn zclSE_ProcessInCmd_Tou_GetDayProfiles
  6321. *
  6322. * @brief process in the received Get Day Profiles
  6323. *
  6324. * @param pInMsg - pointer to the incoming message
  6325. * @param pCBs - pointer to the application call back function
  6326. *
  6327. * @return ZStatus_t - ZFailure @ Unsupported
  6328. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6329. * not need default rsp
  6330. */
  6331. static ZStatus_t zclSE_ProcessInCmd_Tou_GetDayProfiles( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  6332. {
  6333. if ( pCBs->pfnTou_GetDayProfiles )
  6334. {
  6335. zclCCGetDayProfiles_t cmd;
  6336. // Parse the command buffer
  6337. cmd.issuerCalendarId = osal_build_uint32( pInMsg->pData, 4 );
  6338. pCBs->pfnTou_GetDayProfiles( &cmd, &(pInMsg->msg->srcAddr),
  6339. pInMsg->hdr.transSeqNum );
  6340. return ZCL_STATUS_CMD_HAS_RSP;
  6341. }
  6342. return ZFailure;
  6343. }
  6344. /*********************************************************************
  6345. * @fn zclSE_ProcessInCmd_Tou_GetWeekProfiles
  6346. *
  6347. * @brief process in the received Get Week Profiles
  6348. *
  6349. * @param pInMsg - pointer to the incoming message
  6350. * @param pCBs - pointer to the application call back function
  6351. *
  6352. * @return ZStatus_t - ZFailure @ Unsupported
  6353. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6354. * not need default rsp
  6355. */
  6356. static ZStatus_t zclSE_ProcessInCmd_Tou_GetWeekProfiles( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  6357. {
  6358. if ( pCBs->pfnTou_GetWeekProfiles )
  6359. {
  6360. zclCCGetWeekProfiles_t cmd;
  6361. // Parse the command buffer
  6362. cmd.issuerCalendarId = osal_build_uint32( pInMsg->pData, 4 );
  6363. pCBs->pfnTou_GetWeekProfiles( &cmd, &(pInMsg->msg->srcAddr),
  6364. pInMsg->hdr.transSeqNum );
  6365. return ZCL_STATUS_CMD_HAS_RSP;
  6366. }
  6367. return ZFailure;
  6368. }
  6369. /*********************************************************************
  6370. * @fn zclSE_ProcessInCmd_Tou_GetSeasons
  6371. *
  6372. * @brief process in the received Get Seasons
  6373. *
  6374. * @param pInMsg - pointer to the incoming message
  6375. * @param pCBs - pointer to the application call back function
  6376. *
  6377. * @return ZStatus_t - ZFailure @ Unsupported
  6378. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6379. * not need default rsp
  6380. */
  6381. static ZStatus_t zclSE_ProcessInCmd_Tou_GetSeasons( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  6382. {
  6383. if ( pCBs->pfnTou_GetSeasons )
  6384. {
  6385. zclCCGetSeasons_t cmd;
  6386. // Parse the command buffer
  6387. cmd.issuerCalendarId = osal_build_uint32( pInMsg->pData, 4 );
  6388. pCBs->pfnTou_GetSeasons( &cmd, &(pInMsg->msg->srcAddr),
  6389. pInMsg->hdr.transSeqNum );
  6390. return ZCL_STATUS_CMD_HAS_RSP;
  6391. }
  6392. return ZFailure;
  6393. }
  6394. /*********************************************************************
  6395. * @fn zclSE_ProcessInCmd_Tou_GetSpecialDays
  6396. *
  6397. * @brief process in the received Get Special Days
  6398. *
  6399. * @param pInMsg - pointer to the incoming message
  6400. * @param pCBs - pointer to the application call back function
  6401. *
  6402. * @return ZStatus_t - ZFailure @ Unsupported
  6403. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6404. * not need default rsp
  6405. */
  6406. static ZStatus_t zclSE_ProcessInCmd_Tou_GetSpecialDays( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  6407. {
  6408. if ( pCBs->pfnTou_GetSpecialDays )
  6409. {
  6410. zclCCGetSpecialDays_t cmd;
  6411. // Parse the command buffer
  6412. cmd.startTime = osal_build_uint32( pInMsg->pData, 4 );
  6413. cmd.numOfEvents = pInMsg->pData[4];
  6414. cmd.calendarType = pInMsg->pData[5];
  6415. pCBs->pfnTou_GetSpecialDays( &cmd, &(pInMsg->msg->srcAddr),
  6416. pInMsg->hdr.transSeqNum );
  6417. return ZCL_STATUS_CMD_HAS_RSP;
  6418. }
  6419. return ZFailure;
  6420. }
  6421. #endif // SE_UK_EXT
  6422. #endif // ZCL_TOU
  6423. #ifdef ZCL_DEVICE_MGMT
  6424. #ifdef SE_UK_EXT
  6425. /*********************************************************************
  6426. * @fn zclSE_ProcessInDeviceMgmtCmds
  6427. *
  6428. * @brief Callback from ZCL to process incoming Commands specific
  6429. * to this cluster library on a command ID basis
  6430. *
  6431. * @param pInMsg - pointer to the incoming message
  6432. * @param pCBs - pointer to the application call back function
  6433. *
  6434. * @return ZStatus_t
  6435. */
  6436. static ZStatus_t zclSE_ProcessInDeviceMgmtCmds( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  6437. {
  6438. ZStatus_t stat;
  6439. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  6440. {
  6441. // Process Client commands, received by Server
  6442. switch ( pInMsg->hdr.commandID )
  6443. {
  6444. case COMMAND_SE_GET_CHANGE_OF_TENANCY:
  6445. stat = zclSE_ProcessInCmd_DeviceMgmt_GetChangeTenancy( pInMsg, pCBs );
  6446. break;
  6447. case COMMAND_SE_GET_CHANGE_OF_SUPPLIER:
  6448. stat = zclSE_ProcessInCmd_DeviceMgmt_GetChangeSupplier( pInMsg, pCBs );
  6449. break;
  6450. case COMMAND_SE_GET_CHANGE_SUPPLY:
  6451. stat = zclSE_ProcessInCmd_DeviceMgmt_GetChangeSupply( pInMsg, pCBs );
  6452. break;
  6453. case COMMAND_SE_SUPPLY_STATUS_RESPONSE:
  6454. stat = zclSE_ProcessInCmd_DeviceMgmt_SupplyStatusResponse( pInMsg, pCBs );
  6455. break;
  6456. case COMMAND_SE_GET_PASSWORD:
  6457. stat = zclSE_ProcessInCmd_DeviceMgmt_GetPassword( pInMsg, pCBs );
  6458. break;
  6459. default:
  6460. stat = ZFailure;
  6461. break;
  6462. }
  6463. }
  6464. else
  6465. {
  6466. // Process Server commands, received by Client
  6467. switch ( pInMsg->hdr.commandID )
  6468. {
  6469. case COMMAND_SE_PUBLISH_CHANGE_OF_TENANCY:
  6470. stat = zclSE_ProcessInCmd_DeviceMgmt_PublishChangeTenancy( pInMsg, pCBs );
  6471. break;
  6472. case COMMAND_SE_PUBLISH_CHANGE_OF_SUPPLIER:
  6473. stat = zclSE_ProcessInCmd_DeviceMgmt_PublishChangeSupplier( pInMsg, pCBs );
  6474. break;
  6475. case COMMAND_SE_CHANGE_SUPPLY:
  6476. stat = zclSE_ProcessInCmd_DeviceMgmt_ChangeSupply( pInMsg, pCBs );
  6477. break;
  6478. case COMMAND_SE_CHANGE_PASSWORD:
  6479. stat = zclSE_ProcessInCmd_DeviceMgmt_ChangePassword( pInMsg, pCBs );
  6480. break;
  6481. case COMMAND_SE_LOCAL_CHANGE_SUPPLY:
  6482. stat = zclSE_ProcessInCmd_DeviceMgmt_LocalChangeSupply( pInMsg, pCBs );
  6483. break;
  6484. default:
  6485. stat = ZFailure;
  6486. break;
  6487. }
  6488. }
  6489. return ( stat );
  6490. }
  6491. /*********************************************************************
  6492. * @fn zclSE_ProcessInCmd_DeviceMgmt_GetChangeTenancy
  6493. *
  6494. * @brief Process in the received Get Change Of Tenancy
  6495. *
  6496. * @param pInMsg - pointer to the incoming message
  6497. * @param pCBs - pointer to the application call back function
  6498. *
  6499. * @return ZStatus_t - ZFailure @ Unsupported
  6500. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6501. * not need default rsp
  6502. */
  6503. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_GetChangeTenancy( zclIncoming_t *pInMsg,
  6504. zclSE_AppCallbacks_t *pCBs )
  6505. {
  6506. if ( pCBs->pfnDeviceMgmt_GetChangeTenancy )
  6507. {
  6508. pCBs->pfnDeviceMgmt_GetChangeTenancy( &(pInMsg->msg->srcAddr),
  6509. pInMsg->hdr.transSeqNum );
  6510. return ZCL_STATUS_CMD_HAS_RSP;
  6511. }
  6512. return ZFailure;
  6513. }
  6514. /*********************************************************************
  6515. * @fn zclSE_ProcessInCmd_DeviceMgmt_GetChangeSupplier
  6516. *
  6517. * @brief Process in the received Get Change Of Supplier
  6518. *
  6519. * @param pInMsg - pointer to the incoming message
  6520. * @param pCBs - pointer to the application call back function
  6521. *
  6522. * @return ZStatus_t - ZFailure @ Unsupported
  6523. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6524. * not need default rsp
  6525. */
  6526. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_GetChangeSupplier( zclIncoming_t *pInMsg,
  6527. zclSE_AppCallbacks_t *pCBs )
  6528. {
  6529. if ( pCBs->pfnDeviceMgmt_GetChangeSupplier )
  6530. {
  6531. pCBs->pfnDeviceMgmt_GetChangeSupplier( &(pInMsg->msg->srcAddr),
  6532. pInMsg->hdr.transSeqNum );
  6533. return ZCL_STATUS_CMD_HAS_RSP;
  6534. }
  6535. return ZFailure;
  6536. }
  6537. /*********************************************************************
  6538. * @fn zclSE_ProcessInCmd_DeviceMgmt_GetChangeSupply
  6539. *
  6540. * @brief Process in the received Get Change Supply
  6541. *
  6542. * @param pInMsg - pointer to the incoming message
  6543. * @param pCBs - pointer to the application call back function
  6544. *
  6545. * @return ZStatus_t - ZFailure @ Unsupported
  6546. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6547. * not need default rsp
  6548. */
  6549. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_GetChangeSupply( zclIncoming_t *pInMsg,
  6550. zclSE_AppCallbacks_t *pCBs )
  6551. {
  6552. if ( pCBs->pfnDeviceMgmt_GetChangeSupply )
  6553. {
  6554. pCBs->pfnDeviceMgmt_GetChangeSupply( &(pInMsg->msg->srcAddr),
  6555. pInMsg->hdr.transSeqNum );
  6556. return ZCL_STATUS_CMD_HAS_RSP;
  6557. }
  6558. return ZFailure;
  6559. }
  6560. /*********************************************************************
  6561. * @fn zclSE_ProcessInCmd_DeviceMgmt_SupplyStatusResponse
  6562. *
  6563. * @brief Process in the received Supply Status Response
  6564. *
  6565. * @param pInMsg - pointer to the incoming message
  6566. * @param pCBs - pointer to the application call back function
  6567. *
  6568. * @return ZStatus_t - ZFailure @ Unsupported
  6569. * ZSuccess @ Supported and send default rsp
  6570. */
  6571. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_SupplyStatusResponse( zclIncoming_t *pInMsg,
  6572. zclSE_AppCallbacks_t *pCBs )
  6573. {
  6574. if ( pCBs->pfnDeviceMgmt_SupplyStatusResponse )
  6575. {
  6576. zclCCSupplyStatusResponse_t cmd;
  6577. cmd.supplierId = osal_build_uint32( pInMsg->pData, 4);
  6578. cmd.issuerEventId = osal_build_uint32( &pInMsg->pData[4], 4);
  6579. cmd.implementationDateTime = osal_build_uint32( &pInMsg->pData[8], 4);
  6580. cmd.supplyStatus = pInMsg->pData[12];
  6581. pCBs->pfnDeviceMgmt_SupplyStatusResponse( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  6582. return ZSuccess;
  6583. }
  6584. return ZFailure;
  6585. }
  6586. /*********************************************************************
  6587. * @fn zclSE_ProcessInCmd_DeviceMgmt_GetPassword
  6588. *
  6589. * @brief Process in the received Get Password
  6590. *
  6591. * @param pInMsg - pointer to the incoming message
  6592. * @param pCBs - pointer to the application call back function
  6593. *
  6594. * @return ZStatus_t - ZFailure @ Unsupported
  6595. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6596. * not need default rsp
  6597. */
  6598. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_GetPassword( zclIncoming_t *pInMsg,
  6599. zclSE_AppCallbacks_t *pCBs )
  6600. {
  6601. if ( pCBs->pfnDeviceMgmt_GetPassword )
  6602. {
  6603. zclCCGetPassword_t cmd;
  6604. cmd.passwordLevel = pInMsg->pData[0];
  6605. pCBs->pfnDeviceMgmt_GetPassword( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  6606. return ZCL_STATUS_CMD_HAS_RSP;
  6607. }
  6608. return ZFailure;
  6609. }
  6610. /*********************************************************************
  6611. * @fn zclSE_ProcessInCmd_DeviceMgmt_PublishChangeTenancy
  6612. *
  6613. * @brief Process in the received Publish Change of Tenancy
  6614. *
  6615. * @param pInMsg - pointer to the incoming message
  6616. * @param pCBs - pointer to the application call back function
  6617. *
  6618. * @return ZStatus_t - ZFailure @ Unsupported
  6619. * ZSuccess @ Supported and need default rsp
  6620. */
  6621. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_PublishChangeTenancy( zclIncoming_t *pInMsg,
  6622. zclSE_AppCallbacks_t *pCBs )
  6623. {
  6624. if ( pCBs->pfnDeviceMgmt_PublishChangeTenancy )
  6625. {
  6626. zclCCPublishChangeTenancy_t cmd;
  6627. // Parse the command
  6628. zclSE_ParseInCmd_PublishChangeTenancy( &cmd, &(pInMsg->pData[0]),
  6629. pInMsg->pDataLen );
  6630. pCBs->pfnDeviceMgmt_PublishChangeTenancy( &cmd, &(pInMsg->msg->srcAddr),
  6631. pInMsg->hdr.transSeqNum );
  6632. return ZSuccess;
  6633. }
  6634. return ZFailure;
  6635. }
  6636. /*********************************************************************
  6637. * @fn zclSE_ProcessInCmd_DeviceMgmt_PublishChangeSupplier
  6638. *
  6639. * @brief Process in the received Publish Change of Supplier
  6640. *
  6641. * @param pInMsg - pointer to the incoming message
  6642. * @param pCBs - pointer to the application call back function
  6643. *
  6644. * @return ZStatus_t - ZFailure @ Unsupported
  6645. * ZSuccess @ Supported and need default rsp
  6646. */
  6647. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_PublishChangeSupplier( zclIncoming_t *pInMsg,
  6648. zclSE_AppCallbacks_t *pCBs )
  6649. {
  6650. if ( pCBs->pfnDeviceMgmt_PublishChangeSupplier )
  6651. {
  6652. zclCCPublishChangeSupplier_t cmd;
  6653. // Parse the command
  6654. zclSE_ParseInCmd_PublishChangeSupplier( &cmd, &(pInMsg->pData[0]),
  6655. pInMsg->pDataLen );
  6656. pCBs->pfnDeviceMgmt_PublishChangeSupplier( &cmd, &(pInMsg->msg->srcAddr),
  6657. pInMsg->hdr.transSeqNum );
  6658. return ZSuccess;
  6659. }
  6660. return ZFailure;
  6661. }
  6662. /*********************************************************************
  6663. * @fn zclSE_ProcessInCmd_DeviceMgmt_ChangeSupply
  6664. *
  6665. * @brief Process in the received Change Supply
  6666. *
  6667. * @param pInMsg - pointer to the incoming message
  6668. * @param pCBs - pointer to the application call back function
  6669. *
  6670. * @return ZStatus_t - ZFailure @ Unsupported
  6671. * ZCL_STATUS_CMD_HAS_RSP @ Supported and do
  6672. * not need default rsp
  6673. */
  6674. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_ChangeSupply( zclIncoming_t *pInMsg,
  6675. zclSE_AppCallbacks_t *pCBs )
  6676. {
  6677. if ( pCBs->pfnDeviceMgmt_ChangeSupply )
  6678. {
  6679. zclCCChangeSupply_t cmd;
  6680. // Parse the command
  6681. zclSE_ParseInCmd_ChangeSupply( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  6682. pCBs->pfnDeviceMgmt_ChangeSupply( &cmd, &(pInMsg->msg->srcAddr),
  6683. pInMsg->hdr.transSeqNum );
  6684. return ZCL_STATUS_CMD_HAS_RSP;
  6685. }
  6686. return ZFailure;
  6687. }
  6688. /*********************************************************************
  6689. * @fn zclSE_ProcessInCmd_DeviceMgmt_ChangePassword
  6690. *
  6691. * @brief Process in the received Change Password
  6692. *
  6693. * @param pInMsg - pointer to the incoming message
  6694. * @param pCBs - pointer to the application call back function
  6695. *
  6696. * @return ZStatus_t - ZFailure @ Unsupported
  6697. * ZSuccess @ Supported and need default rsp
  6698. */
  6699. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_ChangePassword( zclIncoming_t *pInMsg,
  6700. zclSE_AppCallbacks_t *pCBs )
  6701. {
  6702. if ( pCBs->pfnDeviceMgmt_ChangePassword )
  6703. {
  6704. zclCCChangePassword_t cmd;
  6705. // Parse the command
  6706. zclSE_ParseInCmd_ChangePassword( &cmd, &(pInMsg->pData[0]), pInMsg->pDataLen );
  6707. pCBs->pfnDeviceMgmt_ChangePassword( &cmd, &(pInMsg->msg->srcAddr),
  6708. pInMsg->hdr.transSeqNum );
  6709. return ZSuccess;
  6710. }
  6711. return ZFailure;
  6712. }
  6713. /*********************************************************************
  6714. * @fn zclSE_ProcessInCmd_DeviceMgmt_LocalChangeSupply
  6715. *
  6716. * @brief Process in the received Local Change Supply
  6717. *
  6718. * @param pInMsg - pointer to the incoming message
  6719. * @param pCBs - pointer to the application call back function
  6720. *
  6721. * @return ZStatus_t - ZFailure @ Unsupported
  6722. * ZSuccess @ Supported and need default rsp
  6723. */
  6724. static ZStatus_t zclSE_ProcessInCmd_DeviceMgmt_LocalChangeSupply( zclIncoming_t *pInMsg, zclSE_AppCallbacks_t *pCBs )
  6725. {
  6726. if ( pCBs->pfnDeviceMgmt_LocalChangeSupply )
  6727. {
  6728. zclCCLocalChangeSupply_t cmd;
  6729. cmd.propSupplyStatus = pInMsg->pData[0];
  6730. pCBs->pfnDeviceMgmt_LocalChangeSupply( &cmd, &(pInMsg->msg->srcAddr),
  6731. pInMsg->hdr.transSeqNum );
  6732. return ZSuccess;
  6733. }
  6734. return ZFailure;
  6735. }
  6736. #endif // SE_UK_EXT
  6737. #endif // ZCL_DEVICE_MGMT
  6738. #ifdef ZCL_PRICING
  6739. /*********************************************************************
  6740. * @fn zclSE_ParseInCmd_PublishPrice
  6741. *
  6742. * @brief Parse received Publish Price Command.
  6743. *
  6744. * @param pCmd - pointer to the output data struct
  6745. * @param buf - pointer to the input data buffer
  6746. * @param len - length of the input buffer
  6747. *
  6748. * @return ZStatus_t - ZSuccess @ Parse successful
  6749. * ZMemError @ Memory allocation failure
  6750. */
  6751. ZStatus_t zclSE_ParseInCmd_PublishPrice( zclCCPublishPrice_t *pCmd, uint8 *buf, uint8 len )
  6752. {
  6753. uint8 originalLen; // stores octet string original length
  6754. // Parse the command buffer
  6755. pCmd->providerId = osal_build_uint32( buf, 4 );
  6756. buf += 4;
  6757. // Notice that rate label is a variable length UTF-8 string
  6758. pCmd->rateLabel.strLen = *buf++;
  6759. if ( pCmd->rateLabel.strLen == SE_OPTIONAL_FIELD_UINT8 )
  6760. {
  6761. // If character count is 0xFF, set string length to 0
  6762. pCmd->rateLabel.strLen = 0;
  6763. }
  6764. if ( pCmd->rateLabel.strLen != 0 )
  6765. {
  6766. originalLen = pCmd->rateLabel.strLen; //save original length
  6767. // truncate rate label to maximum size
  6768. if ( pCmd->rateLabel.strLen > (SE_RATE_LABEL_LEN-1) )
  6769. {
  6770. pCmd->rateLabel.strLen = (SE_RATE_LABEL_LEN-1);
  6771. }
  6772. pCmd->rateLabel.pStr = osal_mem_alloc( pCmd->rateLabel.strLen );
  6773. if ( pCmd->rateLabel.pStr == NULL )
  6774. {
  6775. return ZMemError;
  6776. }
  6777. osal_memcpy( pCmd->rateLabel.pStr, buf, pCmd->rateLabel.strLen );
  6778. buf += originalLen; // move pointer original length of received string
  6779. }
  6780. else
  6781. {
  6782. pCmd->rateLabel.pStr = NULL;
  6783. }
  6784. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  6785. buf += 4;
  6786. pCmd->currentTime = osal_build_uint32( buf, 4 );
  6787. buf += 4;
  6788. pCmd->unitOfMeasure = *buf++;
  6789. pCmd->currency = BUILD_UINT16( buf[0], buf[1] );
  6790. buf += 2;
  6791. pCmd->priceTrailingDigit = *buf++;
  6792. pCmd->numberOfPriceTiers = *buf++;
  6793. pCmd->startTime = osal_build_uint32( buf, 4 );
  6794. buf += 4;
  6795. pCmd->durationInMinutes = BUILD_UINT16( buf[0], buf[1] );
  6796. buf += 2;
  6797. pCmd->price = osal_build_uint32( buf, 4 );
  6798. buf += 4;
  6799. pCmd->priceRatio = *buf++;
  6800. pCmd->generationPrice = osal_build_uint32( buf, 4 );
  6801. buf += 4;
  6802. pCmd->generationPriceRatio = *buf++;
  6803. // SE 1.1 fields
  6804. if ((len - pCmd->rateLabel.strLen) > PACKET_LEN_SE_PUBLISH_PRICE_SE_1_0)
  6805. {
  6806. pCmd->alternateCostDelivered = osal_build_uint32( buf, 4 );
  6807. buf += 4;
  6808. pCmd->alternateCostUnit = *buf++;
  6809. pCmd->alternateCostTrailingDigit = *buf++;
  6810. pCmd->numberOfBlockThresholds = *buf++;
  6811. pCmd->priceControl = *buf;
  6812. }
  6813. else
  6814. {
  6815. // for backwards compatibility with SE 1.0
  6816. pCmd->alternateCostDelivered = SE_OPTIONAL_FIELD_UINT32;
  6817. pCmd->alternateCostUnit = SE_OPTIONAL_FIELD_UINT8;
  6818. pCmd->alternateCostTrailingDigit = SE_OPTIONAL_FIELD_UINT8;
  6819. pCmd->numberOfBlockThresholds = SE_OPTIONAL_FIELD_UINT8;
  6820. pCmd->priceControl = SE_OPTIONAL_FIELD_UINT8;
  6821. }
  6822. return ZSuccess;
  6823. }
  6824. /*********************************************************************
  6825. * @fn zclSE_ParseInCmd_PublishBlockPeriod
  6826. *
  6827. * @brief Parse received Publish Block Period Command.
  6828. *
  6829. * @param pCmd - pointer to the output data struct
  6830. * @param buf - pointer to the input data buffer
  6831. * @param len - length of the input buffer
  6832. *
  6833. * @return none
  6834. */
  6835. void zclSE_ParseInCmd_PublishBlockPeriod( zclCCPublishBlockPeriod_t *pCmd,
  6836. uint8 *buf, uint8 len )
  6837. {
  6838. (void)len; // Intentionally unreferenced parameter
  6839. // Parse the command buffer
  6840. pCmd->providerId = osal_build_uint32( buf, 4 );
  6841. buf += 4;
  6842. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  6843. buf += 4;
  6844. pCmd->blockPeriodStartTime = osal_build_uint32( buf, 4 );
  6845. buf += 4;
  6846. pCmd->blockPeriodDurInMins = osal_build_uint32( buf, 3 );
  6847. buf += 3;
  6848. pCmd->numPriceTiersAndBlock = *buf++;
  6849. #ifdef SE_UK_EXT
  6850. pCmd->tariffType = *buf++;
  6851. #endif
  6852. pCmd->blockPeriodControl = *buf;
  6853. }
  6854. #ifdef SE_UK_EXT
  6855. /*********************************************************************
  6856. * @fn zclSE_ParseInCmd_PublishTariffInfomation
  6857. *
  6858. * @brief Parse received Publish Tariff Info.
  6859. *
  6860. * @param pCmd - pointer to the output data struct
  6861. * @param buf - pointer to the input data buffer
  6862. * @param len - length of the input buffer
  6863. *
  6864. * @return none
  6865. */
  6866. void zclSE_ParseInCmd_PublishTariffInformation( zclCCPublishTariffInformation_t *pCmd,
  6867. uint8 *buf, uint8 len )
  6868. {
  6869. uint8 fieldLen;
  6870. (void)len; // Intentionally unreferenced parameter
  6871. // Parse the command buffer
  6872. pCmd->supplierId = osal_build_uint32( buf, 4 );
  6873. buf += 4;
  6874. pCmd->issuerTariffId = osal_build_uint32( buf, 4 );
  6875. buf += 4;
  6876. pCmd->startTime = osal_build_uint32( buf, 4 );
  6877. buf += 4;
  6878. pCmd->tariffType = *buf++;
  6879. fieldLen = zclSE_Parse_UTF8String(buf, &pCmd->tarifLabel, SE_TARIFF_LABEL_LEN);
  6880. buf += fieldLen;
  6881. pCmd->numPriceTiersInUse = *buf++;
  6882. pCmd->numBlockThresholdsInUse = *buf++;
  6883. pCmd->unitOfMeasure = *buf++;
  6884. pCmd->currency = BUILD_UINT16( buf[0], buf[1] );
  6885. buf += 2;
  6886. pCmd->priceTrailingDigit = *buf++;
  6887. pCmd->standingCharge = osal_build_uint32( buf, 4 );
  6888. buf += 4;
  6889. pCmd->tierBlockMode = *buf++;
  6890. pCmd->blockThresholdMask = BUILD_UINT16( buf[0], buf[1] );
  6891. buf += 2;
  6892. pCmd->BlockThresholdMultiplier = osal_build_uint32( buf, 3 );
  6893. buf += 3;
  6894. pCmd->BlockThresholdDivisor = osal_build_uint32( buf, 3 );
  6895. }
  6896. /*********************************************************************
  6897. * @fn zclSE_ParseInCmd_PublishPriceMatrix
  6898. *
  6899. * @brief Parse received Publish Price Matrix.
  6900. *
  6901. * @param pCmd - pointer to the output data struct
  6902. * @param buf - pointer to the input data buffer
  6903. * @param len - length of the input buffer
  6904. *
  6905. * @return ZStatus_t - ZSuccess @ Parse successful
  6906. * ZMemError @ Memory allocation failure
  6907. */
  6908. ZStatus_t zclSE_ParseInCmd_PublishPriceMatrix( zclCCPublishPriceMatrix_t *pCmd,
  6909. uint8 *buf, uint8 len )
  6910. {
  6911. // Parse the command buffer
  6912. pCmd->issuerTariffId = osal_build_uint32( buf, 4 );
  6913. buf += 4;
  6914. pCmd->commandIndex = *buf++;
  6915. pCmd->numElements = (len - PACKET_LEN_SE_MIN_PUBLISH_PRICE_MATRIX) / sizeof (uint32);
  6916. pCmd->pTierBlockPrice = NULL;
  6917. if ( pCmd->numElements )
  6918. {
  6919. pCmd->pTierBlockPrice = osal_mem_alloc(sizeof (uint32) * pCmd->numElements);
  6920. if ( pCmd->pTierBlockPrice == NULL )
  6921. {
  6922. return ZMemError;
  6923. }
  6924. uint8 i;
  6925. for ( i = 0; i < pCmd->numElements; i++ )
  6926. {
  6927. pCmd->pTierBlockPrice[i] = osal_build_uint32( buf, 4 );
  6928. buf += 4;
  6929. }
  6930. }
  6931. return ZSuccess;
  6932. }
  6933. /*********************************************************************
  6934. * @fn zclSE_ParseInCmd_PublishBlockThresholds
  6935. *
  6936. * @brief Parse received Publish Block Thresholds.
  6937. *
  6938. * @param pCmd - pointer to the output data struct
  6939. * @param buf - pointer to the input data buffer
  6940. * @param len - length of the input buffer
  6941. *
  6942. * @return ZStatus_t - ZSuccess @ Parse successful
  6943. * ZMemError @ Memory allocation failure
  6944. */
  6945. ZStatus_t zclSE_ParseInCmd_PublishBlockThresholds( zclCCPublishBlockThresholds_t *pCmd,
  6946. uint8 *buf, uint8 len )
  6947. {
  6948. // Parse the command buffer
  6949. pCmd->issuerTariffId = osal_build_uint32( buf, 4 );
  6950. buf += 4;
  6951. pCmd->commandIndex = *buf++;
  6952. pCmd->numElements = (len - PACKET_LEN_SE_MIN_PUBLISH_BLOCK_THRESHOLD) / 6;
  6953. pCmd->pTierBlockThreshold = NULL;
  6954. if ( pCmd->numElements )
  6955. {
  6956. pCmd->pTierBlockThreshold = osal_mem_alloc(6 * pCmd->numElements);
  6957. if ( pCmd->pTierBlockThreshold == NULL )
  6958. {
  6959. return ZMemError;
  6960. }
  6961. uint8 i;
  6962. for ( i = 0; i < pCmd->numElements; i++ )
  6963. {
  6964. osal_memcpy( pCmd->pTierBlockThreshold[i], buf, 6 );
  6965. buf += 6;
  6966. }
  6967. }
  6968. return ZSuccess;
  6969. }
  6970. /*********************************************************************
  6971. * @fn zclSE_ParseInCmd_PublishConversionFactor
  6972. *
  6973. * @brief Parse received Publish Conversion Factor.
  6974. *
  6975. * @param pCmd - pointer to the output data struct
  6976. * @param buf - pointer to the input data buffer
  6977. * @param len - length of the input buffer
  6978. *
  6979. * @return none
  6980. */
  6981. void zclSE_ParseInCmd_PublishConversionFactor( zclCCPublishConversionFactor_t *pCmd,
  6982. uint8 *buf, uint8 len )
  6983. {
  6984. (void)len; // Intentionally unreferenced parameter
  6985. // Parse the command buffer
  6986. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  6987. buf += 4;
  6988. pCmd->startTime = osal_build_uint32( buf, 4 );
  6989. buf += 4;
  6990. pCmd->conversionFactor = osal_build_uint32( buf, 4 );
  6991. buf += 4;
  6992. pCmd->trailingDigit = *buf;
  6993. }
  6994. /*********************************************************************
  6995. * @fn zclSE_ParseInCmd_PublishCalorificValue
  6996. *
  6997. * @brief Parse received Publish Calorific Value.
  6998. *
  6999. * @param pCmd - pointer to the output data struct
  7000. * @param buf - pointer to the input data buffer
  7001. * @param len - length of the input buffer
  7002. *
  7003. * @return none
  7004. */
  7005. void zclSE_ParseInCmd_PublishCalorificValue( zclCCPublishCalorificValue_t *pCmd,
  7006. uint8 *buf, uint8 len )
  7007. {
  7008. (void)len; // Intentionally unreferenced parameter
  7009. // Parse the command buffer
  7010. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  7011. buf += 4;
  7012. pCmd->startTime = osal_build_uint32( buf, 4 );
  7013. buf += 4;
  7014. pCmd->calorificValue = osal_build_uint32( buf, 4 );
  7015. buf += 4;
  7016. pCmd->calorificValueUnit = *buf++;
  7017. pCmd->trailingDigit = *buf;
  7018. }
  7019. /*********************************************************************
  7020. * @fn zclSE_ParseInCmd_PublishCO2Value
  7021. *
  7022. * @brief Parse received Publish CO2 Value.
  7023. *
  7024. * @param pCmd - pointer to the output data struct
  7025. * @param buf - pointer to the input data buffer
  7026. * @param len - length of the input buffer
  7027. *
  7028. * @return none
  7029. */
  7030. void zclSE_ParseInCmd_PublishCO2Value( zclCCPublishCO2Value_t *pCmd,
  7031. uint8 *buf, uint8 len )
  7032. {
  7033. (void)len; // Intentionally unreferenced parameter
  7034. // Parse the command buffer
  7035. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  7036. buf += 4;
  7037. pCmd->startTime = osal_build_uint32( buf, 4 );
  7038. buf += 4;
  7039. pCmd->tariffType = *buf++;
  7040. pCmd->CO2Value = osal_build_uint32( buf, 4 );
  7041. buf += 4;
  7042. pCmd->CO2ValueUnit = *buf++;
  7043. pCmd->trailingDigit = *buf;
  7044. }
  7045. /*********************************************************************
  7046. * @fn zclSE_ParseInCmd_PublishCPPEvent
  7047. *
  7048. * @brief Parse received Publish CPP Event.
  7049. *
  7050. * @param pCmd - pointer to the output data struct
  7051. * @param buf - pointer to the input data buffer
  7052. * @param len - length of the input buffer
  7053. *
  7054. * @return none
  7055. */
  7056. void zclSE_ParseInCmd_PublishCPPEvent( zclCCPublishCPPEvent_t *pCmd,
  7057. uint8 *buf, uint8 len )
  7058. {
  7059. (void)len; // Intentionally unreferenced parameter
  7060. // Parse the command buffer
  7061. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  7062. buf += 4;
  7063. pCmd->startTime = osal_build_uint32( buf, 4 );
  7064. buf += 4;
  7065. pCmd->durationInMinutes = BUILD_UINT16( buf[0], buf[1] );
  7066. buf += 2;
  7067. pCmd->tariffType = *buf++;
  7068. pCmd->CPPPriceTier = *buf++;
  7069. pCmd->CPPAuth = *buf;
  7070. }
  7071. /*********************************************************************
  7072. * @fn zclSE_ParseInCmd_PublishBillingPeriod
  7073. *
  7074. * @brief Parse received Publish Billing Period.
  7075. *
  7076. * @param pCmd - pointer to the output data struct
  7077. * @param buf - pointer to the input data buffer
  7078. * @param len - length of the input buffer
  7079. *
  7080. * @return none
  7081. */
  7082. void zclSE_ParseInCmd_PublishBillingPeriod( zclCCPublishBillingPeriod_t *pCmd,
  7083. uint8 *buf, uint8 len )
  7084. {
  7085. (void)len; // Intentionally unreferenced parameter
  7086. // Parse the command buffer
  7087. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  7088. buf += 4;
  7089. pCmd->startTime = osal_build_uint32( buf, 4 );
  7090. buf += 4;
  7091. pCmd->duration = osal_build_uint32( buf, 3 );
  7092. buf += 3;
  7093. pCmd->tariffType = *buf;
  7094. }
  7095. /*********************************************************************
  7096. * @fn zclSE_ParseInCmd_PublishConsolidatedBill
  7097. *
  7098. * @brief Parse received Publish Consolidated Bill.
  7099. *
  7100. * @param pCmd - pointer to the output data struct
  7101. * @param buf - pointer to the input data buffer
  7102. * @param len - length of the input buffer
  7103. *
  7104. * @return none
  7105. */
  7106. void zclSE_ParseInCmd_PublishConsolidatedBill( zclCCPublishConsolidatedBill_t *pCmd,
  7107. uint8 *buf, uint8 len )
  7108. {
  7109. (void)len; // Intentionally unreferenced parameter
  7110. // Parse the command buffer
  7111. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  7112. buf += 4;
  7113. pCmd->startTime = osal_build_uint32( buf, 4 );
  7114. buf += 4;
  7115. pCmd->duration = osal_build_uint32( buf, 3 );
  7116. buf += 3;
  7117. pCmd->tariffType = *buf++;
  7118. pCmd->consolidatedBill = osal_build_uint32( buf, 4 );
  7119. buf += 4;
  7120. pCmd->currency = BUILD_UINT16( buf[0], buf[1] );
  7121. buf += 2;
  7122. pCmd->trailingDigit = *buf;
  7123. }
  7124. /*********************************************************************
  7125. * @fn zclSE_ParseInCmd_PublishCreditPaymentInfo
  7126. *
  7127. * @brief Parse received Publish Credit Payment Info.
  7128. *
  7129. * @param pCmd - pointer to the output data struct
  7130. * @param buf - pointer to the input data buffer
  7131. * @param len - length of the input buffer
  7132. *
  7133. * @return none
  7134. */
  7135. void zclSE_ParseInCmd_PublishCreditPaymentInfo( zclCCPublishCreditPaymentInfo_t *pCmd,
  7136. uint8 *buf, uint8 len )
  7137. {
  7138. // Parse the command buffer
  7139. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  7140. buf += 4;
  7141. pCmd->paymentDueDate = osal_build_uint32( buf, 4 );
  7142. buf += 4;
  7143. pCmd->creditPaymentOverdueAmt = osal_build_uint32( buf, 4 );
  7144. buf += 4;
  7145. pCmd->creditPaymentStatus = *buf++;
  7146. pCmd->creditPayment = osal_build_uint32( buf, 4 );
  7147. buf += 4;
  7148. pCmd->creditPaymentDate = osal_build_uint32( buf, 4 );
  7149. buf += 4;
  7150. (void)zclSE_Parse_UTF8String(buf, &pCmd->creditPaymentRef, SE_CREDIT_PAYMENT_REF_LEN);
  7151. }
  7152. /*********************************************************************
  7153. * @fn zclSE_ParseInCmd_GetTariffInformation
  7154. *
  7155. * @brief Parse received Get Tariff Information.
  7156. *
  7157. * @param pCmd - pointer to the output data struct
  7158. * @param buf - pointer to the input data buffer
  7159. * @param len - length of the input buffer
  7160. *
  7161. * @return none
  7162. */
  7163. void zclSE_ParseInCmd_GetTariffInformation( zclCCGetTariffInformation_t *pCmd,
  7164. uint8 *buf, uint8 len )
  7165. {
  7166. (void)len; // Intentionally unreferenced parameter
  7167. // Parse the command buffer
  7168. pCmd->startTime = osal_build_uint32( buf, 4 );
  7169. buf += 4;
  7170. pCmd->numEvents = *buf++;
  7171. pCmd->tariffType = *buf;
  7172. }
  7173. /*********************************************************************
  7174. * @fn zclSE_ParseInCmd_GetConversionFactor
  7175. *
  7176. * @brief Parse received Get Conversion Factor.
  7177. *
  7178. * @param pCmd - pointer to the output data struct
  7179. * @param buf - pointer to the input data buffer
  7180. * @param len - length of the input buffer
  7181. *
  7182. * @return none
  7183. */
  7184. void zclSE_ParseInCmd_GetConversionFactor( zclCCGetConversionFactor_t *pCmd,
  7185. uint8 *buf, uint8 len )
  7186. {
  7187. (void)len; // Intentionally unreferenced parameter
  7188. // Parse the command buffer
  7189. pCmd->startTime = osal_build_uint32( buf, 4 );
  7190. buf += 4;
  7191. pCmd->numEvents = *buf;
  7192. }
  7193. /*********************************************************************
  7194. * @fn zclSE_ParseInCmd_GetCalorificValue
  7195. *
  7196. * @brief Parse received Get Calorific Value.
  7197. *
  7198. * @param pCmd - pointer to the output data struct
  7199. * @param buf - pointer to the input data buffer
  7200. * @param len - length of the input buffer
  7201. *
  7202. * @return none
  7203. */
  7204. void zclSE_ParseInCmd_GetCalorificValue( zclCCGetCalorificValue_t *pCmd,
  7205. uint8 *buf, uint8 len )
  7206. {
  7207. (void)len; // Intentionally unreferenced parameter
  7208. // Parse the command buffer
  7209. pCmd->startTime = osal_build_uint32( buf, 4 );
  7210. buf += 4;
  7211. pCmd->numEvents = *buf;
  7212. }
  7213. /*********************************************************************
  7214. * @fn zclSE_ParseInCmd_GetCO2Value
  7215. *
  7216. * @brief Parse received Get CO2 Value.
  7217. *
  7218. * @param pCmd - pointer to the output data struct
  7219. * @param buf - pointer to the input data buffer
  7220. * @param len - length of the input buffer
  7221. *
  7222. * @return none
  7223. */
  7224. void zclSE_ParseInCmd_GetCO2Value( zclCCGetCO2Value_t *pCmd, uint8 *buf, uint8 len )
  7225. {
  7226. (void)len; // Intentionally unreferenced parameter
  7227. // Parse the command buffer
  7228. pCmd->startTime = osal_build_uint32( buf, 4 );
  7229. buf += 4;
  7230. pCmd->numEvents = *buf++;
  7231. pCmd->tariffType = *buf;
  7232. }
  7233. /*********************************************************************
  7234. * @fn zclSE_ParseInCmd_GetBillingPeriod
  7235. *
  7236. * @brief Parse received Get Billing Period.
  7237. *
  7238. * @param pCmd - pointer to the output data struct
  7239. * @param buf - pointer to the input data buffer
  7240. * @param len - length of the input buffer
  7241. *
  7242. * @return none
  7243. */
  7244. void zclSE_ParseInCmd_GetBillingPeriod( zclCCGetBillingPeriod_t *pCmd,
  7245. uint8 *buf, uint8 len )
  7246. {
  7247. (void)len; // Intentionally unreferenced parameter
  7248. // Parse the command buffer
  7249. pCmd->startTime = osal_build_uint32( buf, 4 );
  7250. buf += 4;
  7251. pCmd->numEvents = *buf++;
  7252. pCmd->tariffType = *buf;
  7253. }
  7254. /*********************************************************************
  7255. * @fn zclSE_ParseInCmd_GetConsolidatedBill
  7256. *
  7257. * @brief Parse received Get Consolidated Bill.
  7258. *
  7259. * @param pCmd - pointer to the output data struct
  7260. * @param buf - pointer to the input data buffer
  7261. * @param len - length of the input buffer
  7262. *
  7263. * @return none
  7264. */
  7265. void zclSE_ParseInCmd_GetConsolidatedBill( zclCCGetConsolidatedBill_t *pCmd,
  7266. uint8 *buf, uint8 len )
  7267. {
  7268. (void)len; // Intentionally unreferenced parameter
  7269. // Parse the command buffer
  7270. pCmd->startTime = osal_build_uint32( buf, 4 );
  7271. buf += 4;
  7272. pCmd->numEvents = *buf++;
  7273. pCmd->tariffType = *buf;
  7274. }
  7275. /*********************************************************************
  7276. * @fn zclSE_ParseInCmd_CPPEventResponse
  7277. *
  7278. * @brief Parse received CPP Event Response.
  7279. *
  7280. * @param pCmd - pointer to the output data struct
  7281. * @param buf - pointer to the input data buffer
  7282. * @param len - length of the input buffer
  7283. *
  7284. * @return none
  7285. */
  7286. void zclSE_ParseInCmd_CPPEventResponse( zclCCCPPEventResponse_t *pCmd,
  7287. uint8 *buf, uint8 len )
  7288. {
  7289. (void)len; // Intentionally unreferenced parameter
  7290. // Parse the command buffer
  7291. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  7292. buf += 4;
  7293. pCmd->CPPAuth = *buf;
  7294. }
  7295. #endif // SE_UK_EXT
  7296. #endif // ZCL_PRICING
  7297. #ifdef ZCL_MESSAGE
  7298. /*********************************************************************
  7299. * @fn zclSE_ParseInCmd_DisplayMessage
  7300. *
  7301. * @brief Parse received Display Message Command.
  7302. *
  7303. * @param pCmd - pointer to the output data struct
  7304. * @param buf - pointer to the input data buffer
  7305. * @param len - length of the input buffer
  7306. *
  7307. * @return ZStatus_t - ZSuccess @ Parse successful
  7308. * ZMemError @ Memory allocation failure
  7309. */
  7310. ZStatus_t zclSE_ParseInCmd_DisplayMessage( zclCCDisplayMessage_t *pCmd, uint8 *buf, uint8 len )
  7311. {
  7312. (void)len; // Intentionally unreferenced parameter
  7313. pCmd->messageId = osal_build_uint32( buf, 4 );
  7314. // Message control bitmap
  7315. osal_memset ( &(pCmd->messageCtrl), 0, sizeof( zclMessageCtrl_t ) );
  7316. pCmd->messageCtrl.transmissionMode = buf[4] & 0x03; // bit 0&1
  7317. pCmd->messageCtrl.importance = ( buf[4] >> SE_PROFILE_MSGCTRL_IMPORTANCE ) & 0x03; // bit 2&3
  7318. #if defined ( SE_UK_EXT )
  7319. pCmd->messageCtrl.pinRequired = ( buf[4] >> SE_PROFILE_MSGCTRL_PINREQUIRED ) & 0x01; // bit 4
  7320. pCmd->messageCtrl.acceptanceRequired = ( buf[4] >> SE_PROFILE_MSGCTRL_ACCEPTREQUIRED ) & 0x01; // bit 5
  7321. #endif
  7322. pCmd->messageCtrl.confirmationRequired = ( buf[4] >> SE_PROFILE_MSGCTRL_CONFREQUIRED ) & 0x01; // bit 7
  7323. pCmd->startTime = osal_build_uint32( &(buf[5]), 4 );
  7324. pCmd->durationInMinutes = BUILD_UINT16( buf[9], buf[10] );
  7325. pCmd->msgString.strLen = buf[11];
  7326. // Copy the message string
  7327. if ( pCmd->msgString.strLen != 0 )
  7328. {
  7329. pCmd->msgString.pStr = osal_mem_alloc( pCmd->msgString.strLen );
  7330. if ( pCmd->msgString.pStr == NULL )
  7331. {
  7332. return ZMemError;
  7333. }
  7334. osal_memcpy( pCmd->msgString.pStr, &(buf[12]), pCmd->msgString.strLen );
  7335. }
  7336. else
  7337. {
  7338. pCmd->msgString.pStr = NULL;
  7339. }
  7340. return ZSuccess;
  7341. }
  7342. /*********************************************************************
  7343. * @fn zclSE_ParseInCmd_CancelMessage
  7344. *
  7345. * @brief Parse received Cancel Message Command.
  7346. *
  7347. * @param pCmd - pointer to the output data struct
  7348. * @param buf - pointer to the input data buffer
  7349. * @param len - length of the input buffer
  7350. *
  7351. * @return none
  7352. */
  7353. void zclSE_ParseInCmd_CancelMessage( zclCCCancelMessage_t *pCmd, uint8 *buf, uint8 len )
  7354. {
  7355. (void)len; // Intentionally unreferenced parameter
  7356. pCmd->messageId = osal_build_uint32( buf, 4 );
  7357. // Message control bitmap
  7358. osal_memset ( &(pCmd->messageCtrl), 0, sizeof( zclMessageCtrl_t ) );
  7359. pCmd->messageCtrl.transmissionMode = buf[4] & 0x03; // bit 0&1
  7360. pCmd->messageCtrl.importance = ( buf[4] >> SE_PROFILE_MSGCTRL_IMPORTANCE ) & 0x03; // bit 2&3
  7361. #if defined ( SE_UK_EXT )
  7362. pCmd->messageCtrl.pinRequired = ( buf[4] >> SE_PROFILE_MSGCTRL_PINREQUIRED ) & 0x01; // bit 4
  7363. pCmd->messageCtrl.acceptanceRequired = ( buf[4] >> SE_PROFILE_MSGCTRL_ACCEPTREQUIRED ) & 0x01; // bit 5
  7364. #endif
  7365. pCmd->messageCtrl.confirmationRequired = ( buf[4] >> SE_PROFILE_MSGCTRL_CONFREQUIRED ) & 0x01; // bit 7
  7366. }
  7367. /*********************************************************************
  7368. * @fn zclSE_ParseInCmd_MessageConfirmation
  7369. *
  7370. * @brief Parse received Message Confirmation Command.
  7371. *
  7372. * @param pCmd - pointer to the output data struct
  7373. * @param buf - pointer to the input data buffer
  7374. * @param len - length of the input buffer
  7375. *
  7376. * @return none
  7377. */
  7378. void zclSE_ParseInCmd_MessageConfirmation( zclCCMessageConfirmation_t *pCmd,
  7379. uint8 *buf, uint8 len )
  7380. {
  7381. pCmd->messageId = osal_build_uint32( buf, 4 );
  7382. pCmd->confirmTime = osal_build_uint32( &(buf[4]), 4 );
  7383. #if defined ( SE_UK_EXT )
  7384. pCmd->msgString.strLen = buf[8];
  7385. #else
  7386. pCmd->msgString.strLen = 0;
  7387. #endif
  7388. // Point to the Message Response string
  7389. if ( pCmd->msgString.strLen != 0 )
  7390. {
  7391. pCmd->msgString.pStr = &(buf[9]);
  7392. }
  7393. else
  7394. {
  7395. pCmd->msgString.pStr = NULL;
  7396. }
  7397. }
  7398. #endif // ZCL_MESSAGE
  7399. #ifdef ZCL_LOAD_CONTROL
  7400. /*********************************************************************
  7401. * @fn zclSE_ParseInCmd_LoadControlEvent
  7402. *
  7403. * @brief Parse received Load Control Event.
  7404. *
  7405. * @param pCmd - pointer to the output data struct
  7406. * @param buf - pointer to the input data buffer
  7407. * @param len - length of the input buffer
  7408. *
  7409. * @return none
  7410. */
  7411. void zclSE_ParseInCmd_LoadControlEvent( zclCCLoadControlEvent_t *pCmd,
  7412. uint8 *buf, uint8 len )
  7413. {
  7414. (void)len; // Intentionally unreferenced parameter
  7415. // Maybe add checking for buffer length later
  7416. // Skipped right now to leave MT input to guarantee
  7417. // proper buffer length
  7418. pCmd->issuerEvent = osal_build_uint32( buf, 4 );
  7419. buf += 4;
  7420. pCmd->deviceGroupClass = osal_build_uint32( buf, 3 );
  7421. buf += 3;
  7422. pCmd->startTime = osal_build_uint32( buf, 4 );
  7423. buf += 4;
  7424. pCmd->durationInMinutes = BUILD_UINT16( buf[0], buf[1] );
  7425. buf += 2;
  7426. pCmd->criticalityLevel = *buf++;
  7427. pCmd->coolingTemperatureOffset = *buf++;
  7428. pCmd->heatingTemperatureOffset = *buf++;
  7429. pCmd->coolingTemperatureSetPoint = BUILD_UINT16( buf[0], buf[1] );
  7430. buf += 2;
  7431. pCmd->heatingTemperatureSetPoint = BUILD_UINT16( buf[0], buf[1] );
  7432. buf += 2;
  7433. pCmd->averageLoadAdjustmentPercentage = *buf++;
  7434. pCmd->dutyCycle = *buf++;
  7435. pCmd->eventControl = *buf;
  7436. }
  7437. /*********************************************************************
  7438. * @fn zclSE_ParseInCmd_CancelLoadControlEvent
  7439. *
  7440. * @brief Parse received Cancel Load Control Event Command.
  7441. *
  7442. * @param pCmd - pointer to the output data struct
  7443. * @param buf - pointer to the input data buffer
  7444. * @param len - length of the input buffer
  7445. *
  7446. * @return none
  7447. */
  7448. void zclSE_ParseInCmd_CancelLoadControlEvent( zclCCCancelLoadControlEvent_t *pCmd,
  7449. uint8 *buf, uint8 len )
  7450. {
  7451. (void)len; // Intentionally unreferenced parameter
  7452. // Maybe add checking for buffer length later
  7453. // Skipped right now to leave MT input to guarantee
  7454. // proper buffer length
  7455. pCmd->issuerEventID = osal_build_uint32( buf, 4 );
  7456. buf += 4;
  7457. pCmd->deviceGroupClass = osal_build_uint32( buf, 3 );
  7458. buf += 3;
  7459. pCmd->cancelControl = *buf++;
  7460. pCmd->effectiveTime = osal_build_uint32( buf, 4 );
  7461. }
  7462. /*********************************************************************
  7463. * @fn zclSE_ParseInCmd_ReportEventStatus
  7464. *
  7465. * @brief Parse received Report Event Status.
  7466. *
  7467. * @param pCmd - pointer to the output data struct
  7468. * @param buf - pointer to the input data buffer
  7469. * @param len - length of the input buffer
  7470. *
  7471. * @return none
  7472. */
  7473. void zclSE_ParseInCmd_ReportEventStatus( zclCCReportEventStatus_t *pCmd,
  7474. uint8 *buf, uint8 len )
  7475. {
  7476. (void)len; // Intentionally unreferenced parameter
  7477. // Maybe add checking for buffer length later
  7478. // Skipped right now to leave MT input to guarantee
  7479. // proper buffer length
  7480. pCmd->issuerEventID = osal_build_uint32( buf, 4 );
  7481. buf += 4;
  7482. pCmd->eventStatus = *buf++;
  7483. pCmd->eventStartTime = osal_build_uint32( buf, 4 );
  7484. buf += 4;
  7485. pCmd->criticalityLevelApplied = *buf++;
  7486. pCmd->coolingTemperatureSetPointApplied = BUILD_UINT16( buf[0], buf[1] );
  7487. buf += 2;
  7488. pCmd->heatingTemperatureSetPointApplied = BUILD_UINT16( buf[0], buf[1] );
  7489. buf += 2;
  7490. pCmd->averageLoadAdjustment = *buf++;
  7491. pCmd->dutyCycleApplied = *buf++;
  7492. pCmd->eventControl = *buf++;
  7493. pCmd->signatureType = *buf++;
  7494. osal_memcpy( pCmd->signature, buf, SE_PROFILE_SIGNATURE_LENGTH );
  7495. }
  7496. #endif // ZCL_LOAD_CONTROL
  7497. #ifdef ZCL_PREPAYMENT
  7498. /*********************************************************************
  7499. * @fn zclSE_ParseInCmd_SelAvailEmergencyCredit
  7500. *
  7501. * @brief Parse received Select Available Emergency Credit Command.
  7502. *
  7503. * @param pCmd - pointer to the output data struct
  7504. * @param buf - pointer to the input data buffer
  7505. * @param len - length of the input buffer
  7506. *
  7507. * @return none
  7508. */
  7509. void zclSE_ParseInCmd_SelAvailEmergencyCredit( zclCCSelAvailEmergencyCredit_t *pCmd,
  7510. uint8 *buf, uint8 len )
  7511. {
  7512. (void)len; // Intentionally unreferenced parameter
  7513. uint8 originalLen; // stores octet string original length
  7514. // Parse the command buffer
  7515. pCmd->commandDateTime = osal_build_uint32( buf, 4 );
  7516. buf += 4;
  7517. pCmd->originatingDevice = *buf++;
  7518. // Notice that site ID is a variable length UTF-8 string
  7519. pCmd->siteId.strLen = *buf++;
  7520. if ( pCmd->siteId.strLen == SE_OPTIONAL_FIELD_UINT8 )
  7521. {
  7522. // If character count is 0xFF, set string length to 0
  7523. pCmd->siteId.strLen = 0;
  7524. }
  7525. if ( pCmd->siteId.strLen != 0 )
  7526. {
  7527. originalLen = pCmd->siteId.strLen; //save original length
  7528. // truncate Site ID to maximum size
  7529. if ( pCmd->siteId.strLen > (SE_SITE_ID_LEN-1) )
  7530. {
  7531. pCmd->siteId.strLen = (SE_SITE_ID_LEN-1);
  7532. }
  7533. pCmd->siteId.pStr = buf;
  7534. buf += originalLen; // move pointer original length of received string
  7535. }
  7536. else
  7537. {
  7538. pCmd->siteId.pStr = NULL;
  7539. }
  7540. // Notice that meterSerialNumber is a variable length UTF-8 string
  7541. pCmd->meterSerialNumber.strLen = *buf++;
  7542. if ( pCmd->meterSerialNumber.strLen == SE_OPTIONAL_FIELD_UINT8 )
  7543. {
  7544. // If character count is 0xFF, set string length to 0
  7545. pCmd->meterSerialNumber.strLen = 0;
  7546. }
  7547. if ( pCmd->meterSerialNumber.strLen != 0 )
  7548. {
  7549. originalLen = pCmd->meterSerialNumber.strLen; //save original length
  7550. // truncate Meter Serial Number to maximum size
  7551. if ( pCmd->meterSerialNumber.strLen > (SE_METER_SERIAL_NUM_LEN-1) )
  7552. {
  7553. pCmd->meterSerialNumber.strLen = (SE_METER_SERIAL_NUM_LEN-1);
  7554. }
  7555. pCmd->meterSerialNumber.pStr = buf;
  7556. buf += originalLen; // move pointer original length of received string
  7557. }
  7558. else
  7559. {
  7560. pCmd->meterSerialNumber.pStr = NULL;
  7561. }
  7562. }
  7563. #ifndef SE_UK_EXT
  7564. /*********************************************************************
  7565. * @fn zclSE_ParseInCmd_ChangeSupply
  7566. *
  7567. * @brief Parse received Change Supply Command.
  7568. *
  7569. * @param pCmd - pointer to the output data struct
  7570. * @param buf - pointer to the input data buffer
  7571. * @param len - length of the input buffer
  7572. *
  7573. * @return none
  7574. */
  7575. void zclSE_ParseInCmd_ChangeSupply( zclCCChangeSupply_t *pCmd, uint8 *buf, uint8 len )
  7576. {
  7577. (void)len; // Intentionally unreferenced parameter
  7578. uint8 originalLen; // stores octet string original length
  7579. // Parse the command buffer
  7580. pCmd->providerId = osal_build_uint32( buf, 4 );
  7581. buf += 4;
  7582. pCmd->requestDateTime = osal_build_uint32( buf, 4 );
  7583. buf += 4;
  7584. // Notice that site ID is a variable length UTF-8 string
  7585. pCmd->siteId.strLen = *buf++;
  7586. if ( pCmd->siteId.strLen == SE_OPTIONAL_FIELD_UINT8 )
  7587. {
  7588. // If character count is 0xFF, set string length to 0
  7589. pCmd->siteId.strLen = 0;
  7590. }
  7591. if ( pCmd->siteId.strLen != 0 )
  7592. {
  7593. originalLen = pCmd->siteId.strLen; //save original length
  7594. // truncate Site ID to maximum size
  7595. if ( pCmd->siteId.strLen > (SE_SITE_ID_LEN-1) )
  7596. {
  7597. pCmd->siteId.strLen = (SE_SITE_ID_LEN-1);
  7598. }
  7599. pCmd->siteId.pStr = buf;
  7600. buf += originalLen; // move pointer original length of received string
  7601. }
  7602. else
  7603. {
  7604. pCmd->siteId.pStr = NULL;
  7605. }
  7606. // Notice that meterSerialNumber is a variable length UTF-8 string
  7607. pCmd->meterSerialNumber.strLen = *buf++;
  7608. if ( pCmd->meterSerialNumber.strLen == SE_OPTIONAL_FIELD_UINT8 )
  7609. {
  7610. // If character count is 0xFF, set string length to 0
  7611. pCmd->meterSerialNumber.strLen = 0;
  7612. }
  7613. if ( pCmd->meterSerialNumber.strLen != 0 )
  7614. {
  7615. originalLen = pCmd->meterSerialNumber.strLen; //save original length
  7616. // truncate Meter Serial Number to maximum size
  7617. if ( pCmd->meterSerialNumber.strLen > (SE_METER_SERIAL_NUM_LEN-1) )
  7618. {
  7619. pCmd->meterSerialNumber.strLen = (SE_METER_SERIAL_NUM_LEN-1);
  7620. }
  7621. pCmd->meterSerialNumber.pStr = buf;
  7622. buf += originalLen; // move pointer original length of received string
  7623. }
  7624. else
  7625. {
  7626. pCmd->meterSerialNumber.pStr = NULL;
  7627. }
  7628. pCmd->implementationDateTime = osal_build_uint32( buf, 4 );
  7629. buf += 4;
  7630. pCmd->proposedSupplyStatus = *buf++;
  7631. pCmd->origIdSupplyControlBits = *buf;
  7632. }
  7633. #endif // not defined SE_UK_EXT
  7634. #ifdef SE_UK_EXT
  7635. /*********************************************************************
  7636. * @fn zclSE_ParseInCmd_ChangeDebt
  7637. *
  7638. * @brief Parse received Change Debt Command.
  7639. *
  7640. * @param pCmd - pointer to the output data struct
  7641. * @param buf - pointer to the input data buffer
  7642. * @param len - length of the input buffer
  7643. *
  7644. * @return none
  7645. */
  7646. void zclSE_ParseInCmd_ChangeDebt( zclCCChangeDebt_t *pCmd, uint8 *buf, uint8 len )
  7647. {
  7648. (void)len; // Intentionally unreferenced parameter
  7649. uint8 fieldLen;
  7650. // Parse the command buffer
  7651. pCmd->cmdIssueTime = osal_build_uint32( buf, 4 );
  7652. buf += 4;
  7653. fieldLen = zclSE_Parse_UTF8String(buf, &pCmd->debtLabel, SE_DEBT_LABEL_LEN);
  7654. buf += fieldLen;
  7655. pCmd->debtAmount = osal_build_uint32( buf, 4 );
  7656. buf += 4;
  7657. pCmd->debtRecoveryMethod = *buf++;
  7658. pCmd->debtType = *buf++;
  7659. pCmd->recoveryStartTime = osal_build_uint32( buf, 4 );
  7660. buf += 4;
  7661. pCmd->debtRecoveryCollectionTime = BUILD_UINT16( buf[0], buf[1] );
  7662. buf += 2;
  7663. pCmd->debtRecoveryFrequency = osal_build_uint32( buf, 4 );
  7664. buf += 4;
  7665. pCmd->debtRecoveryAmt = osal_build_uint32( buf, 4 );
  7666. buf += 4;
  7667. pCmd->debtRecoveryBalancePct = BUILD_UINT16( buf[0], buf[1] );
  7668. buf += 2;
  7669. pCmd->debtRecoveryMaxMissed = *buf++;
  7670. (void)zclSE_Parse_UTF8String(buf, &pCmd->signature, SE_SIGNATURE_LEN);
  7671. }
  7672. /*********************************************************************
  7673. * @fn zclSE_ParseInCmd_EmergencyCreditSetup
  7674. *
  7675. * @brief Parse received Emergency Credit Setup Command.
  7676. *
  7677. * @param pCmd - pointer to the output data struct
  7678. * @param buf - pointer to the input data buffer
  7679. * @param len - length of the input buffer
  7680. *
  7681. * @return none
  7682. */
  7683. void zclSE_ParseInCmd_EmergencyCreditSetup( zclCCEmergencyCreditSetup_t *pCmd,
  7684. uint8 *buf, uint8 len )
  7685. {
  7686. (void)len; // Intentionally unreferenced parameter
  7687. pCmd->cmdIssueTime = osal_build_uint32( buf, 4 );
  7688. buf += 4;
  7689. pCmd->emergencyCreditLimit = osal_build_uint32( buf, 4 );
  7690. buf += 4;
  7691. pCmd->emergencyCreditThreshold = osal_build_uint32( buf, 4 );
  7692. }
  7693. /*********************************************************************
  7694. * @fn zclSE_ParseInCmd_ConsumerTopup
  7695. *
  7696. * @brief Parse received Consumer Topup Command.
  7697. *
  7698. * @param pCmd - pointer to the output data struct
  7699. * @param buf - pointer to the input data buffer
  7700. * @param len - length of the input buffer
  7701. *
  7702. * @return none
  7703. */
  7704. void zclSE_ParseInCmd_ConsumerTopup( zclCCConsumerTopup_t *pCmd, uint8 *buf, uint8 len )
  7705. {
  7706. (void)len; // Intentionally unreferenced parameter
  7707. pCmd->originatingDevice = *buf++;
  7708. (void)zclSE_Parse_UTF8String(buf, &pCmd->topupCode, SE_TOPUP_CODE_LEN);
  7709. }
  7710. /*********************************************************************
  7711. * @fn zclSE_ParseInCmd_CreditAdjustment
  7712. *
  7713. * @brief Parse received Credit Adjustment Command.
  7714. *
  7715. * @param pCmd - pointer to the output data struct
  7716. * @param buf - pointer to the input data buffer
  7717. * @param len - length of the input buffer
  7718. *
  7719. * @return none
  7720. */
  7721. void zclSE_ParseInCmd_CreditAdjustment( zclCCCreditAdjustment_t *pCmd,
  7722. uint8 *buf, uint8 len )
  7723. {
  7724. (void)len; // Intentionally unreferenced parameter
  7725. pCmd->cmdIssueTime = osal_build_uint32( buf, 4 );
  7726. buf += 4;
  7727. pCmd->creditAdjustmentType = *buf++;
  7728. osal_memcpy( pCmd->creditAdjustmentValue, buf, 6 );
  7729. buf += 6;
  7730. (void)zclSE_Parse_UTF8String(buf, &pCmd->signature, SE_SIGNATURE_LEN);
  7731. }
  7732. /*********************************************************************
  7733. * @fn zclSE_ParseInCmd_ChangePaymentMode
  7734. *
  7735. * @brief Parse received Change Payment Mode Command.
  7736. *
  7737. * @param pCmd - pointer to the output data struct
  7738. * @param buf - pointer to the input data buffer
  7739. * @param len - length of the input buffer
  7740. *
  7741. * @return none
  7742. */
  7743. void zclSE_ParseInCmd_ChangePaymentMode( zclCCChangePaymentMode_t *pCmd,
  7744. uint8 *buf, uint8 len )
  7745. {
  7746. (void)len; // Intentionally unreferenced parameter
  7747. pCmd->supplierId = osal_build_uint32( buf, 4 );
  7748. buf += 4;
  7749. pCmd->modeEventId = osal_build_uint32( buf, 4 );
  7750. buf += 4;
  7751. pCmd->implementationDate = osal_build_uint32( buf, 4 );
  7752. buf += 4;
  7753. pCmd->proposedPaymentControl = *buf++;
  7754. pCmd->cutOffValue = osal_build_uint32( buf, 4 );
  7755. buf += 4;
  7756. (void)zclSE_Parse_UTF8String(buf, &pCmd->signature, SE_SIGNATURE_LEN);
  7757. }
  7758. /*********************************************************************
  7759. * @fn zclSE_ParseInCmd_GetPrepaySnapshot
  7760. *
  7761. * @brief Parse received Get Prepay Snapshot Command.
  7762. *
  7763. * @param pCmd - pointer to the output data struct
  7764. * @param buf - pointer to the input data buffer
  7765. * @param len - length of the input buffer
  7766. *
  7767. * @return none
  7768. */
  7769. void zclSE_ParseInCmd_GetPrepaySnapshot( zclCCGetPrepaySnapshot_t *pCmd,
  7770. uint8 *buf, uint8 len )
  7771. {
  7772. (void)len; // Intentionally unreferenced parameter
  7773. pCmd->startTime = osal_build_uint32( buf, 4 );
  7774. pCmd->numberOfSnapshots = buf[4];
  7775. pCmd->snapshotCause = BUILD_UINT16( buf[5], buf[6] );
  7776. }
  7777. /*********************************************************************
  7778. * @fn zclSE_ParseInCmd_GetDebtRepaymentLog
  7779. *
  7780. * @brief Parse received Get Debt Repayment Log Command.
  7781. *
  7782. * @param pCmd - pointer to the output data struct
  7783. * @param buf - pointer to the input data buffer
  7784. * @param len - length of the input buffer
  7785. *
  7786. * @return none
  7787. */
  7788. void zclSE_ParseInCmd_GetDebtRepaymentLog( zclCCGetDebtRepaymentLog_t *pCmd,
  7789. uint8 *buf, uint8 len )
  7790. {
  7791. (void)len; // Intentionally unreferenced parameter
  7792. pCmd->numberOfDebt = buf[0];
  7793. pCmd->debtType = buf[1];
  7794. }
  7795. /*********************************************************************
  7796. * @fn zclSE_ParseInCmd_GetPrepaySnapshotResponse
  7797. *
  7798. * @brief Parse received Get Prepay Snapshot Response Command.
  7799. *
  7800. * @param pCmd - pointer to the output data struct
  7801. * @param buf - pointer to the input data buffer
  7802. * @param len - length of the input buffer
  7803. *
  7804. * @return none
  7805. */
  7806. void zclSE_ParseInCmd_GetPrepaySnapshotResponse( zclCCGetPrepaySnapshotResponse_t *pCmd,
  7807. uint8 *buf, uint8 len )
  7808. {
  7809. (void)len; // Intentionally unreferenced parameter
  7810. pCmd->eventIssuerId = osal_build_uint32( buf, 4 );
  7811. pCmd->snapshotTime = osal_build_uint32( buf+4, 4 );
  7812. pCmd->commandIndex = buf[8];
  7813. pCmd->snapshotCause = BUILD_UINT16( buf[9], buf[10] );
  7814. pCmd->snapshotPayloadType = buf[11];
  7815. buf += 12;
  7816. if ( pCmd->snapshotPayloadType == SE_SNAPSHOT_TYPE_DEBIT_CREDIT_ADDITION )
  7817. {
  7818. pCmd->payload.type1DebtRemaining = osal_build_uint32( buf, 4 );
  7819. pCmd->payload.type2DebtRemaining = osal_build_uint32( buf+4, 4 );
  7820. pCmd->payload.type3DebtRemaining = osal_build_uint32( buf+8, 4 );
  7821. pCmd->payload.emergencyCreditRemaining = osal_build_uint32( buf+12, 4 );
  7822. pCmd->payload.creditRemaining = osal_build_uint32( buf+16, 4 );
  7823. }
  7824. }
  7825. /*********************************************************************
  7826. * @fn zclSE_ParseInCmd_ChangePaymentModeResponse
  7827. *
  7828. * @brief Parse received Change Payment Mode Response Command.
  7829. *
  7830. * @param pCmd - pointer to the output data struct
  7831. * @param buf - pointer to the input data buffer
  7832. * @param len - length of the input buffer
  7833. *
  7834. * @return none
  7835. */
  7836. void zclSE_ParseInCmd_ChangePaymentModeResponse( zclCCChangePaymentModeResponse_t *pCmd,
  7837. uint8 *buf, uint8 len )
  7838. {
  7839. (void)len; // Intentionally unreferenced parameter
  7840. pCmd->friendlyCredit = *buf++;
  7841. pCmd->friendlyCreditCalendar = osal_build_uint32( buf, 4 );
  7842. pCmd->emergencyCreditLimit = osal_build_uint32( buf+4, 4 );
  7843. pCmd->cmergencyCreditThreshold = osal_build_uint32( buf+8, 4 );
  7844. }
  7845. /*********************************************************************
  7846. * @fn zclSE_ParseInCmd_ConsumerTopupResponse
  7847. *
  7848. * @brief Parse received ConsumerTopupResponse Command.
  7849. *
  7850. * @param pCmd - pointer to the output data struct
  7851. * @param buf - pointer to the input data buffer
  7852. * @param len - length of the input buffer
  7853. *
  7854. * @return none
  7855. */
  7856. void zclSE_ParseInCmd_ConsumerTopupResponse( zclCCConsumerTopupResponse_t *pCmd,
  7857. uint8 *buf, uint8 len )
  7858. {
  7859. (void)len; // Intentionally unreferenced parameter
  7860. pCmd->resultType = *buf++;
  7861. pCmd->topupValue = osal_build_uint32( buf, 4 );
  7862. buf += 4;
  7863. pCmd->sourceofTopup = *buf++;
  7864. pCmd->creditRemaining = osal_build_uint32( buf, 4 );
  7865. }
  7866. /*********************************************************************
  7867. * @fn zclSE_ParseInCmd_PublishTopupLog
  7868. *
  7869. * @brief Parse received Publish Topup Log Command.
  7870. *
  7871. * @param pCmd - pointer to the output data struct
  7872. * @param buf - pointer to the input data buffer
  7873. * @param len - length of the input buffer
  7874. *
  7875. * @return ZStatus_t - ZSuccess @ Parse successful
  7876. * ZMemError @ Memory allocation failure
  7877. */
  7878. ZStatus_t zclSE_ParseInCmd_PublishTopupLog( zclCCPublishTopupLog_t *pCmd,
  7879. uint8 *buf, uint8 len )
  7880. {
  7881. (void)len; // Intentionally unreferenced parameter
  7882. uint8 i, pos, numCodes = 0;
  7883. // Count the number of strings in the message
  7884. pos = 2;
  7885. while ( pos < len )
  7886. {
  7887. if (buf[pos] == 0)
  7888. {
  7889. break;
  7890. }
  7891. pos += buf[pos] + 1;
  7892. numCodes++;
  7893. }
  7894. pCmd->cmdIndex = *buf++;
  7895. pCmd->totalCmds = *buf++;
  7896. pCmd->numCodes = numCodes;
  7897. if ( numCodes )
  7898. {
  7899. pCmd->pPayload = osal_mem_alloc( sizeof(UTF8String_t) * numCodes );
  7900. if ( pCmd->pPayload == NULL )
  7901. {
  7902. return ZMemError;
  7903. }
  7904. for ( i = 0; i < numCodes; i++ )
  7905. {
  7906. uint8 fieldLen = zclSE_Parse_UTF8String(buf, &pCmd->pPayload[i], SE_TOPUP_CODE_LEN);
  7907. buf += fieldLen;
  7908. }
  7909. }
  7910. return ZSuccess;
  7911. }
  7912. /*********************************************************************
  7913. * @fn zclSE_ParseInCmd_PublishDebtLog
  7914. *
  7915. * @brief Parse received Publish Debt Log Command.
  7916. *
  7917. * @param pCmd - pointer to the output data struct
  7918. * @param buf - pointer to the input data buffer
  7919. * @param len - length of the input buffer
  7920. *
  7921. * @return ZStatus_t - ZSuccess @ Parse successful
  7922. * ZMemError @ Memory allocation failure
  7923. */
  7924. ZStatus_t zclSE_ParseInCmd_PublishDebtLog( zclCCPublishDebtLog_t *pCmd,
  7925. uint8 *buf, uint8 len )
  7926. {
  7927. uint8 i;
  7928. uint8 numDebts = (len - 2) / 13;
  7929. pCmd->cmdIndex = *buf++;
  7930. pCmd->totalCmds = *buf++;
  7931. pCmd->numDebts = numDebts;
  7932. if ( numDebts )
  7933. {
  7934. pCmd->pPayload = osal_mem_alloc( sizeof(zclCCDebtPayload_t) * numDebts );
  7935. if ( pCmd->pPayload == NULL )
  7936. {
  7937. return ZMemError;
  7938. }
  7939. for ( i = 0; i < numDebts; i++ )
  7940. {
  7941. pCmd->pPayload[i].collectionTime = osal_build_uint32( buf, 4 );
  7942. pCmd->pPayload[i].amountCollected = osal_build_uint32( buf+4, 4 );
  7943. pCmd->pPayload[i].debtType = buf[8];
  7944. pCmd->pPayload[i].outstandingDebt = osal_build_uint32( buf+9, 4 );
  7945. buf += 13;
  7946. }
  7947. }
  7948. return ZSuccess;
  7949. }
  7950. #endif // SE_UK_EXT
  7951. #endif // ZCL_PREPAYMENT
  7952. #ifdef ZCL_TUNNELING
  7953. /*********************************************************************
  7954. * @fn zclSE_ParseInCmd_TransferData
  7955. *
  7956. * @brief Parse received Transfer Data Command.
  7957. *
  7958. * @param pCmd - pointer to the output data struct
  7959. * @param buf - pointer to the input data buffer
  7960. * @param len - length of the input buffer
  7961. *
  7962. * @return none
  7963. */
  7964. void zclSE_ParseInCmd_TransferData( zclCCTransferData_t *pCmd, uint8 *buf, uint8 len )
  7965. {
  7966. pCmd->tunnelId = BUILD_UINT16( buf[0], buf[1] );
  7967. buf += 2;
  7968. pCmd->data = buf;
  7969. }
  7970. #endif // ZCL_TUNNELING
  7971. #ifdef ZCL_TOU
  7972. #ifdef SE_UK_EXT
  7973. /*********************************************************************
  7974. * @fn zclSE_ParseInCmd_PublishCalendar
  7975. *
  7976. * @brief Parse received Publish Calendar Command.
  7977. *
  7978. * @param pCmd - pointer to the output data struct
  7979. * @param buf - pointer to the input data buffer
  7980. * @param len - length of the input buffer
  7981. *
  7982. * @return none
  7983. */
  7984. void zclSE_ParseInCmd_PublishCalendar( zclCCPublishCalendar_t *pCmd,
  7985. uint8 *buf, uint8 len )
  7986. {
  7987. uint8 originalLen; // stores octet string original length
  7988. // Parse the command buffer
  7989. pCmd->issuerCalendarId = osal_build_uint32( buf, 4 );
  7990. buf += 4;
  7991. pCmd->startTime = osal_build_uint32( buf, 4 );
  7992. buf += 4;
  7993. pCmd->calendarType = *buf++;
  7994. pCmd->calendarTimeRef = *buf++;
  7995. // Notice that calendarName is a variable length UTF-8 string
  7996. pCmd->calendarName.strLen = *buf++;
  7997. if ( pCmd->calendarName.strLen == SE_OPTIONAL_FIELD_UINT8 )
  7998. {
  7999. // If character count is 0xFF, set string length to 0
  8000. pCmd->calendarName.strLen = 0;
  8001. }
  8002. if ( pCmd->calendarName.strLen != 0 )
  8003. {
  8004. originalLen = pCmd->calendarName.strLen; //save original length
  8005. // truncate rate label to maximum size
  8006. if ( pCmd->calendarName.strLen > (SE_CALENDAR_NAME_LEN-1) )
  8007. {
  8008. pCmd->calendarName.strLen = (SE_CALENDAR_NAME_LEN-1);
  8009. }
  8010. pCmd->calendarName.pStr = buf;
  8011. buf += originalLen; // move pointer original length of received string
  8012. }
  8013. else
  8014. {
  8015. pCmd->calendarName.pStr = NULL;
  8016. }
  8017. pCmd->numOfSeasons = *buf++;
  8018. pCmd->numOfWeekProfiles = *buf++;
  8019. pCmd->numOfDayProfiles = *buf;
  8020. }
  8021. /*********************************************************************
  8022. * @fn zclSE_ParseInCmd_PublishDayProfile
  8023. *
  8024. * @brief Parse received Publish Day Profile Command.
  8025. *
  8026. * @param pCmd - pointer to the output data struct
  8027. * @param buf - pointer to the input data buffer
  8028. * @param len - length of the input buffer
  8029. *
  8030. * @return ZStatus_t - ZSuccess @ Parse successful
  8031. * ZMemError @ Memory allocation failure
  8032. */
  8033. ZStatus_t zclSE_ParseInCmd_PublishDayProfile( zclCCPublishDayProfile_t *pCmd,
  8034. uint8 *buf, uint8 len )
  8035. {
  8036. // Parse the command buffer
  8037. pCmd->issuerCalendarId = osal_build_uint32( buf, 4 );
  8038. buf += 4;
  8039. pCmd->dayId = *buf++;
  8040. pCmd->totalNumSchedEnt = *buf++;
  8041. pCmd->commandIndex = *buf++;
  8042. pCmd->numTransferEntries = (len - PACKET_LEN_SE_PUBLISH_DAY_PROFILE) / SE_DAY_SCHEDULE_ENTRY_LEN;
  8043. if (pCmd->numTransferEntries)
  8044. {
  8045. if ( pCmd->issuerCalendarId <= SE_CALENDAR_TYPE_IMPORT_EXPORT_CALENDAR )
  8046. {
  8047. pCmd->pScheduleEntries = osal_mem_alloc( pCmd->numTransferEntries * sizeof( zclCCRateEntry_t ) );
  8048. if ( pCmd->pScheduleEntries != NULL )
  8049. {
  8050. zclCCRateEntry_t *pRateEntry = (zclCCRateEntry_t *)pCmd->pScheduleEntries;
  8051. uint8 i;
  8052. for ( i = 0; i < pCmd->numTransferEntries; i++ )
  8053. {
  8054. pRateEntry->startTime = BUILD_UINT16( buf[0], buf[1] );
  8055. buf += 2;
  8056. pRateEntry->activePriceTier = *buf++;
  8057. pRateEntry++;
  8058. }
  8059. }
  8060. else
  8061. {
  8062. return ZMemError;
  8063. }
  8064. }
  8065. else
  8066. {
  8067. pCmd->pScheduleEntries = osal_mem_alloc( pCmd->numTransferEntries * sizeof( zclCCFriendlyCreditEntry_t ) );
  8068. if ( pCmd->pScheduleEntries != NULL )
  8069. {
  8070. zclCCFriendlyCreditEntry_t *pFriendlyEntry = (zclCCFriendlyCreditEntry_t *)pCmd->pScheduleEntries;
  8071. uint8 i;
  8072. for ( i = 0; i < pCmd->numTransferEntries; i++ )
  8073. {
  8074. pFriendlyEntry->startTime = BUILD_UINT16( buf[0], buf[1] );
  8075. buf += 2;
  8076. pFriendlyEntry->friendCreditEnable = *buf++;
  8077. pFriendlyEntry++;
  8078. }
  8079. }
  8080. else
  8081. {
  8082. return ZMemError;
  8083. }
  8084. }
  8085. }
  8086. return ZSuccess;
  8087. }
  8088. /*********************************************************************
  8089. * @fn zclSE_ParseInCmd_PublishSeasons
  8090. *
  8091. * @brief Parse received Publish Seasons Command.
  8092. *
  8093. * @param pCmd - pointer to the output data struct
  8094. * @param buf - pointer to the input data buffer
  8095. * @param len - length of the input buffer
  8096. *
  8097. * @return ZStatus_t - ZSuccess @ Parse successful
  8098. * ZMemError @ Memory allocation failure
  8099. */
  8100. ZStatus_t zclSE_ParseInCmd_PublishSeasons( zclCCPublishSeasons_t *pCmd, uint8 *buf, uint8 len )
  8101. {
  8102. // Parse the command buffer
  8103. pCmd->issuerCalendarId = osal_build_uint32( buf, 4 );
  8104. buf += 4;
  8105. pCmd->commandIndex = *buf++;
  8106. pCmd->numTransferEntries = ( len - PACKET_LEN_SE_PUBLISH_SEASONS ) / SE_SEASON_ENTRY_LEN;
  8107. if ( pCmd->numTransferEntries )
  8108. {
  8109. pCmd->pSeasonEntry = (zclCCSeasonEntry_t *)osal_mem_alloc( pCmd->numTransferEntries *
  8110. sizeof( zclCCSeasonEntry_t ) );
  8111. if ( pCmd->pSeasonEntry != NULL )
  8112. {
  8113. uint8 i;
  8114. for ( i = 0; i < pCmd->numTransferEntries; i++ )
  8115. {
  8116. pCmd->pSeasonEntry[i].seasonStartDate = osal_build_uint32( buf, 4 );
  8117. buf += 4;
  8118. pCmd->pSeasonEntry[i].weekIdRef = *buf++;
  8119. }
  8120. }
  8121. else
  8122. {
  8123. return ZMemError;
  8124. }
  8125. }
  8126. return ZSuccess;
  8127. }
  8128. /*********************************************************************
  8129. * @fn zclSE_ParseInCmd_PublishSpecialDays
  8130. *
  8131. * @brief Parse received Publish Special Days Command.
  8132. *
  8133. * @param pCmd - pointer to the output data struct
  8134. * @param buf - pointer to the input data buffer
  8135. * @param len - length of the input buffer
  8136. *
  8137. * @return ZStatus_t - ZSuccess @ Parse successful
  8138. * ZMemError @ Memory allocation failure
  8139. */
  8140. ZStatus_t zclSE_ParseInCmd_PublishSpecialDays( zclCCPublishSpecialDays_t *pCmd,
  8141. uint8 *buf, uint8 len )
  8142. {
  8143. // Parse the command buffer
  8144. pCmd->issuerEventId = osal_build_uint32( buf, 4 );
  8145. buf += 4;
  8146. pCmd->startTime = osal_build_uint32( buf, 4 );
  8147. buf += 4;
  8148. pCmd->calendarType = *buf++;
  8149. pCmd->totalNumSpecialDays = *buf++;
  8150. pCmd->commandIndex = *buf++;
  8151. pCmd->numTransferEntries = ( len - PACKET_LEN_SE_PUBLISH_SPECIAL_DAYS ) / SE_SPECIAL_DAY_ENTRY_LEN;
  8152. if ( pCmd->numTransferEntries )
  8153. {
  8154. pCmd->pSpecialDayEntry = (zclCCSpecialDayEntry_t *)osal_mem_alloc( pCmd->numTransferEntries *
  8155. sizeof( zclCCSpecialDayEntry_t ) );
  8156. if ( pCmd->pSpecialDayEntry != NULL )
  8157. {
  8158. uint8 i;
  8159. for ( i = 0; i < pCmd->numTransferEntries; i++ )
  8160. {
  8161. pCmd->pSpecialDayEntry[i].specialDayDate = osal_build_uint32( buf, 4 );
  8162. buf += 4;
  8163. pCmd->pSpecialDayEntry[i].dayIdRef = *buf++;
  8164. }
  8165. }
  8166. else
  8167. {
  8168. return ZMemError;
  8169. }
  8170. }
  8171. return ZSuccess;
  8172. }
  8173. #endif // SE_UK_EXT
  8174. #endif // ZCL_TOU
  8175. #ifdef ZCL_DEVICE_MGMT
  8176. #ifdef SE_UK_EXT
  8177. /*********************************************************************
  8178. * @fn zclSE_ParseInCmd_PublishChangeTenancy
  8179. *
  8180. * @brief Parse received Publish Change of Tenancy Command.
  8181. *
  8182. * @param pCmd - pointer to the output data struct
  8183. * @param buf - pointer to the input data buffer
  8184. * @param len - length of the input buffer
  8185. *
  8186. * @return none
  8187. */
  8188. void zclSE_ParseInCmd_PublishChangeTenancy( zclCCPublishChangeTenancy_t *pCmd,
  8189. uint8 *buf, uint8 len )
  8190. {
  8191. (void)len; // Intentionally unreferenced parameter
  8192. // Parse the command buffer
  8193. pCmd->supplierId = osal_build_uint32( buf, 4 );
  8194. buf += 4;
  8195. pCmd->eventId = osal_build_uint32( buf, 4 );
  8196. buf += 4;
  8197. pCmd->tariffType = *buf++;
  8198. pCmd->implementationDateTime = osal_build_uint32( buf, 4 );
  8199. buf += 4;
  8200. pCmd->propTenencyChangeCtrl = osal_build_uint32( buf, 4 );
  8201. buf += 4;
  8202. pCmd->signature.strLen = *buf++;;
  8203. // Point to the Signature string
  8204. if ( pCmd->signature.strLen != 0 )
  8205. {
  8206. pCmd->signature.pStr = buf;
  8207. }
  8208. else
  8209. {
  8210. pCmd->signature.pStr = NULL;
  8211. }
  8212. }
  8213. /*********************************************************************
  8214. * @fn zclSE_ParseInCmd_PublishChangeSupplier
  8215. *
  8216. * @brief Parse received Publish Change of Supplier Command.
  8217. *
  8218. * @param pCmd - pointer to the output data struct
  8219. * @param buf - pointer to the input data buffer
  8220. * @param len - length of the input buffer
  8221. *
  8222. * @return none
  8223. */
  8224. void zclSE_ParseInCmd_PublishChangeSupplier( zclCCPublishChangeSupplier_t *pCmd,
  8225. uint8 *buf, uint8 len )
  8226. {
  8227. (void)len; // Intentionally unreferenced parameter
  8228. // Parse the command buffer
  8229. pCmd->supplierId = osal_build_uint32( buf, 4 );
  8230. buf += 4;
  8231. pCmd->eventId = osal_build_uint32( buf, 4 );
  8232. buf += 4;
  8233. pCmd->tariffType = *buf++;
  8234. pCmd->propSupplierId = osal_build_uint32( buf, 4 );
  8235. buf += 4;
  8236. pCmd->suppIdImplemDateTime = osal_build_uint32( buf, 4 );
  8237. buf += 4;
  8238. pCmd->supplierChangeCtrl = osal_build_uint32( buf, 4 );
  8239. buf += 4;
  8240. pCmd->supplierIdName.strLen = *buf++;;
  8241. // Point to the Supplier ID Name string
  8242. if ( pCmd->supplierIdName.strLen != 0 )
  8243. {
  8244. uint8 originalLen; // stores octet string original length
  8245. originalLen = pCmd->supplierIdName.strLen; //save original length
  8246. // truncate SupplierIdName to maximum size
  8247. if ( pCmd->supplierIdName.strLen > (SE_SUPPLIER_ID_NAME_LEN-1) )
  8248. {
  8249. pCmd->supplierIdName.strLen = (SE_SUPPLIER_ID_NAME_LEN-1);
  8250. }
  8251. pCmd->supplierIdName.pStr = buf;
  8252. buf += originalLen; // move pointer original length of received string
  8253. }
  8254. else
  8255. {
  8256. pCmd->supplierIdName.pStr = NULL;
  8257. }
  8258. pCmd->signature.strLen = *buf++;;
  8259. // Point to the Signature string
  8260. if ( pCmd->signature.strLen != 0 )
  8261. {
  8262. pCmd->signature.pStr = buf;
  8263. }
  8264. else
  8265. {
  8266. pCmd->signature.pStr = NULL;
  8267. }
  8268. }
  8269. /*********************************************************************
  8270. * @fn zclSE_ParseInCmd_ChangeSupply
  8271. *
  8272. * @brief Parse received Change Supply Command.
  8273. *
  8274. * @param pCmd - pointer to the output data struct
  8275. * @param buf - pointer to the input data buffer
  8276. * @param len - length of the input buffer
  8277. *
  8278. * @return none
  8279. */
  8280. void zclSE_ParseInCmd_ChangeSupply( zclCCChangeSupply_t *pCmd, uint8 *buf, uint8 len )
  8281. {
  8282. (void)len; // Intentionally unreferenced parameter
  8283. // Parse the command buffer
  8284. pCmd->supplierId = osal_build_uint32( buf, 4 );
  8285. buf += 4;
  8286. pCmd->eventId = osal_build_uint32( buf, 4 );
  8287. buf += 4;
  8288. pCmd->requestDateTime = osal_build_uint32( buf, 4 );
  8289. buf += 4;
  8290. pCmd->implementationDateTime = osal_build_uint32( buf, 4 );
  8291. buf += 4;
  8292. pCmd->proposedSupplyStatus = *buf++;
  8293. pCmd->origIdSupplyControlBits = *buf++;
  8294. pCmd->signature.strLen = *buf++;;
  8295. // Point to the Signature string
  8296. if ( pCmd->signature.strLen != 0 )
  8297. {
  8298. pCmd->signature.pStr = buf;
  8299. }
  8300. else
  8301. {
  8302. pCmd->signature.pStr = NULL;
  8303. }
  8304. }
  8305. /*********************************************************************
  8306. * @fn zclSE_ParseInCmd_ChangePassword
  8307. *
  8308. * @brief Parse received Change Password Command.
  8309. *
  8310. * @param pCmd - pointer to the output data struct
  8311. * @param buf - pointer to the input data buffer
  8312. * @param len - length of the input buffer
  8313. *
  8314. * @return none
  8315. */
  8316. void zclSE_ParseInCmd_ChangePassword( zclCCChangePassword_t *pCmd, uint8 *buf, uint8 len )
  8317. {
  8318. pCmd->passwordLevel = *buf++;
  8319. pCmd->password.strLen = *buf++;;
  8320. // Point to the Signature string
  8321. if ( pCmd->password.strLen != 0 )
  8322. {
  8323. // truncate password to maximum size
  8324. if ( pCmd->password.strLen > (SE_PASSWORD_LEN-1) )
  8325. {
  8326. pCmd->password.strLen = (SE_PASSWORD_LEN-1);
  8327. }
  8328. pCmd->password.pStr = buf;
  8329. }
  8330. else
  8331. {
  8332. pCmd->password.pStr = NULL;
  8333. }
  8334. }
  8335. #endif // SE_UK_EXT
  8336. #endif // ZCL_DEVICE_MGMT
  8337. #ifdef SE_UK_EXT
  8338. /*********************************************************************
  8339. * @fn zclSE_Parse_UTF8String
  8340. *
  8341. * @brief Called to parse a UTF8String from a message
  8342. *
  8343. * @param pBuf - pointer to the incoming message
  8344. * @param pString - pointer to the UTF8String_t
  8345. * @param maxLen - max length of the string field in pBuf
  8346. *
  8347. * @return uint8 - number of bytes parsed from pBuf
  8348. */
  8349. static uint8 zclSE_Parse_UTF8String( uint8 *pBuf, UTF8String_t *pString, uint8 maxLen )
  8350. {
  8351. uint8 originalLen = 0;
  8352. pString->strLen = *pBuf++;
  8353. if ( pString->strLen == SE_OPTIONAL_FIELD_UINT8 )
  8354. {
  8355. // If character count is 0xFF, set string length to 0
  8356. pString->strLen = 0;
  8357. }
  8358. if ( pString->strLen != 0 )
  8359. {
  8360. originalLen = pString->strLen; //save original length
  8361. // truncate to maximum size
  8362. if ( pString->strLen > (maxLen-1) )
  8363. {
  8364. pString->strLen = (maxLen-1);
  8365. }
  8366. pString->pStr = pBuf;
  8367. }
  8368. else
  8369. {
  8370. pString->pStr = NULL;
  8371. }
  8372. return originalLen + 1;
  8373. }
  8374. #endif // SE_UK_EXT
  8375. /********************************************************************************************
  8376. *********************************************************************************************/