2 * Copyright (C) 2018, 2019 "IoT.bzh"
3 * Author "Arthur Guyader" <arthur.guyader@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include <afb-timer.h>
21 #include "./socketcan-j1939.hpp"
25 class socketcan_j1939_addressclaiming_t : public socketcan_j1939_t
28 socketcan_j1939_addressclaiming_t();
29 virtual std::shared_ptr<message_t> read_message();
30 virtual int open(std::string device_name, pgn_t pgn);
31 virtual claiming_state get_state();
32 TimerHandleT *timer_handle_;
33 std::pair<uint64_t, bool> table_j1939_address_[J1939_IDLE_ADDR];
36 int claim_address(bool first_claim,bool new_address);
38 void initialize_table_j1939_address();
39 int save_addr_name(uint8_t addr,name_t name);
40 uint8_t choose_new_address();
41 uint8_t get_addr_table(name_t name);
42 void change_state(claiming_state new_state);
44 static int no_response_claiming(TimerHandleT *timerhandle);
45 static int free_timer_handle(void *timer_context);
47 uint8_t current_address_;
49 claiming_state claiming_state_;
50 std::string device_name_;